Skip to content

Commit

Permalink
Merge pull request #8 from JoshuaVandaele/1.1.5
Browse files Browse the repository at this point in the history
1.1.5
  • Loading branch information
JoshuaVandaele authored Mar 6, 2024
2 parents 3b0d106 + 5627569 commit dbebc15
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion modules/updaters/Rescuezilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, folder_path: Path, edition: str) -> None:
@cache
def _get_download_link(self) -> str:
return self.release_info["files"][
self._get_complete_normalized_file_path(absolute=False)
str(self._get_complete_normalized_file_path(absolute=False))
]

def check_integrity(self) -> bool:
Expand Down
49 changes: 32 additions & 17 deletions modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,38 @@ def download_file(url: str, local_file: Path, progress_bar: bool = True) -> None
Returns:
None
"""
logging.debug(f"[download_file] Downloading {url} to {local_file.resolve()}")
with requests.get(url, stream=True) as r:
total_size = int(r.headers.get("content-length", 0)) # Sizes in bytes

with open(local_file, "wb") as f:
if progress_bar:
with tqdm(
total=total_size,
unit="B",
desc=local_file.name,
) as pbar:
for chunk in r.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)
pbar.update(len(chunk))
else:
shutil.copyfileobj(r.raw, f)
part_file = local_file.with_suffix(".part")
logging.debug(f"[download_file] Downloading {url} to {part_file.resolve()}")

try:
with requests.get(url, stream=True) as r:
total_size = int(r.headers.get("content-length", 0)) # Sizes in bytes

with open(part_file, "wb") as f:
if progress_bar:
with tqdm(
total=total_size,
unit="B",
desc=part_file.name,
) as pbar:
for chunk in r.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)
pbar.update(len(chunk))
else:
shutil.copyfileobj(r.raw, f)
except requests.exceptions.RequestException:
logging.exception(f"Failed to download {url} to {part_file.resolve()}")
if part_file.exists():
part_file.unlink()
raise
except KeyboardInterrupt:
logging.info(f"Download of {url} to {part_file.resolve()} was cancelled")
if part_file.exists():
part_file.unlink()
raise

part_file.rename(local_file)


def windows_consumer_download(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name="sisou", # Required
version="1.1.4", # Required
version="1.1.5", # Required
description="A powerful tool to conveniently update all of your ISO files!", # Optional
long_description=long_description, # Optional
long_description_content_type="text/markdown", # Optional
Expand Down

0 comments on commit dbebc15

Please sign in to comment.