Skip to content

Commit d7025ef

Browse files
committed
aded rate and download limits updated readme
1 parent a86b686 commit d7025ef

File tree

2 files changed

+66
-7
lines changed

2 files changed

+66
-7
lines changed

Clone Website to Docker Tool/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,30 @@ This tool clones a website and packages it as a Docker-ready folder, with an opt
88
- Copy container files to your chosen destination
99
- Optionally build the Docker image (if Docker is installed)
1010
- Console shows real-time verbose output
11+
- Limit download size (MB/GB/TB)
12+
- Throttle download speed (KB/s or MB/s)
1113
- No web server or browser UI required
1214

1315
## Usage
1416
1. Install requirements:
1517
```bash
1618
pip install -r requirements.txt
1719
```
18-
(PySide6 and wget required. Install wget via Homebrew: `brew install wget`)
20+
- PySide6 and wget required.
21+
- **Windows:** Download wget from https://eternallybored.org/misc/wget/ and add to PATH.
22+
- **macOS:** Install wget via Homebrew: `brew install wget`
23+
- **Linux:** Install wget via your package manager: `sudo apt install wget` (Debian/Ubuntu) or `sudo yum install wget` (Fedora/RHEL)
1924

2025
2. Run the GUI:
2126
```bash
2227
python cw2dt.py
2328
```
2429

2530
3. Enter the website URL, Docker image name, and choose a destination folder.
26-
4. Click "Clone Website & Prepare Docker Output".
27-
5. (Optional) Enable Docker build if Docker is installed.
28-
6. Find the output in your chosen folder, ready for Docker Desktop or CLI.
31+
4. (Optional) Enable download size cap and/or throttle speed.
32+
5. Click "Clone Website & Prepare Docker Output".
33+
6. (Optional) Enable Docker build if Docker is installed.
34+
7. Find the output in your chosen folder, ready for Docker Desktop or CLI.
2935

3036
## Notes
3137
- The `cloned_sites` folder is used as a temporary cache and is cleared after each run.

Clone Website to Docker Tool/cw2dt.py

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import shutil
55
import platform
66
from PySide6.QtWidgets import (
7-
QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton, QFileDialog, QTextEdit, QCheckBox
7+
QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton, QFileDialog, QTextEdit, QCheckBox, QComboBox, QSpinBox
88
)
99
from PySide6.QtCore import Qt, QThread, Signal
1010

@@ -26,12 +26,14 @@ class CloneThread(QThread):
2626
progress = Signal(str)
2727
finished = Signal(str)
2828

29-
def __init__(self, url, docker_name, save_path, build_docker):
29+
def __init__(self, url, docker_name, save_path, build_docker, size_cap=None, throttle=None):
3030
super().__init__()
3131
self.url = url
3232
self.docker_name = docker_name
3333
self.save_path = save_path
3434
self.build_docker = build_docker
35+
self.size_cap = size_cap
36+
self.throttle = throttle
3537

3638
def run(self):
3739
log = []
@@ -62,9 +64,14 @@ def log_msg(msg):
6264
os.makedirs(temp_project_folder, exist_ok=True)
6365
# Clone website using wget
6466
log_msg(f'Cloning {self.url} to {temp_project_folder}')
67+
# Build wget command with options
6568
wget_cmd = [
6669
'wget', '-e', 'robots=off', '--mirror', '--convert-links', '--adjust-extension', '--page-requisites', '--no-parent', self.url, '-P', temp_project_folder
6770
]
71+
if self.size_cap:
72+
wget_cmd += ['--quota', str(self.size_cap)]
73+
if self.throttle:
74+
wget_cmd += ['--limit-rate', str(self.throttle)]
6875
try:
6976
result = subprocess.run(wget_cmd, capture_output=True, text=True)
7077
log_msg(result.stdout)
@@ -149,6 +156,40 @@ def __init__(self):
149156
self.build_checkbox = QCheckBox('Build Docker image after clone (requires Docker)')
150157
layout.addWidget(self.build_checkbox)
151158

159+
# Download size cap controls
160+
self.size_cap_checkbox = QCheckBox('Limit download size')
161+
layout.addWidget(self.size_cap_checkbox)
162+
size_hbox = QHBoxLayout()
163+
self.size_cap_value = QSpinBox()
164+
self.size_cap_value.setRange(1, 1000000)
165+
self.size_cap_value.setValue(100)
166+
size_hbox.addWidget(self.size_cap_value)
167+
self.size_cap_unit = QComboBox()
168+
self.size_cap_unit.addItems(['MB', 'GB', 'TB'])
169+
size_hbox.addWidget(self.size_cap_unit)
170+
layout.addLayout(size_hbox)
171+
self.size_cap_checkbox.stateChanged.connect(lambda: self.size_cap_value.setEnabled(self.size_cap_checkbox.isChecked()))
172+
self.size_cap_checkbox.stateChanged.connect(lambda: self.size_cap_unit.setEnabled(self.size_cap_checkbox.isChecked()))
173+
self.size_cap_value.setEnabled(False)
174+
self.size_cap_unit.setEnabled(False)
175+
176+
# Download speed throttle controls
177+
self.throttle_checkbox = QCheckBox('Throttle download speed')
178+
layout.addWidget(self.throttle_checkbox)
179+
throttle_hbox = QHBoxLayout()
180+
self.throttle_value = QSpinBox()
181+
self.throttle_value.setRange(1, 1000000)
182+
self.throttle_value.setValue(1024)
183+
throttle_hbox.addWidget(self.throttle_value)
184+
self.throttle_unit = QComboBox()
185+
self.throttle_unit.addItems(['KB/s', 'MB/s'])
186+
throttle_hbox.addWidget(self.throttle_unit)
187+
layout.addLayout(throttle_hbox)
188+
self.throttle_checkbox.stateChanged.connect(lambda: self.throttle_value.setEnabled(self.throttle_checkbox.isChecked()))
189+
self.throttle_checkbox.stateChanged.connect(lambda: self.throttle_unit.setEnabled(self.throttle_checkbox.isChecked()))
190+
self.throttle_value.setEnabled(False)
191+
self.throttle_unit.setEnabled(False)
192+
152193
self.start_btn = QPushButton('Clone Website & Prepare Docker Output')
153194
self.start_btn.clicked.connect(self.start_clone)
154195
self.start_btn.setEnabled(False)
@@ -185,12 +226,24 @@ def start_clone(self):
185226
docker_name = self.docker_name_input.text().strip()
186227
save_path = self.save_path_display.text().strip()
187228
build_docker = self.build_checkbox.isChecked()
229+
# New options
230+
size_cap = None
231+
if self.size_cap_checkbox.isChecked():
232+
value = self.size_cap_value.value()
233+
unit = self.size_cap_unit.currentText()
234+
multiplier = {'MB': 1024*1024, 'GB': 1024*1024*1024, 'TB': 1024*1024*1024*1024}[unit]
235+
size_cap = value * multiplier
236+
throttle = None
237+
if self.throttle_checkbox.isChecked():
238+
value = self.throttle_value.value()
239+
unit = self.throttle_unit.currentText()
240+
throttle = value * (1024 if unit == 'KB/s' else 1024*1024)
188241
# Prevent Docker build if Docker name is empty and build is checked
189242
if build_docker and not docker_name:
190243
self.console.append('Docker image name is required to build the image.')
191244
return
192245
self.console.clear()
193-
self.clone_thread = CloneThread(url, docker_name, save_path, build_docker)
246+
self.clone_thread = CloneThread(url, docker_name, save_path, build_docker, size_cap=size_cap, throttle=throttle)
194247
self.clone_thread.progress.connect(self.update_console)
195248
self.clone_thread.finished.connect(self.clone_finished)
196249
self.clone_thread.start()

0 commit comments

Comments
 (0)