Skip to content

Commit

Permalink
Make Ruff happy
Browse files Browse the repository at this point in the history
  • Loading branch information
moi90 committed Oct 18, 2024
1 parent 73342ce commit edadd79
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/pyecotaxa/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,26 +279,23 @@ def _get_job_file_remote(self, project_id, job_id, *, target_directory: str) ->

try:
self._notify_observers(
project_id, description=f"Downloading...", progress=0, total=1
project_id, description="Downloading...", progress=0, total=1
)
with atomic_write(dest) as f:
total = (
content_length / chunksize if content_length is not None else None
)
progress = 0
for chunk in response.iter_content(chunksize):
f.write(chunk)
progress += len(chunk)
self._notify_observers(
project_id,
description=f"Downloading...",
description="Downloading...",
progress=progress,
total=content_length,
unit="iB",
)
self._notify_observers(
project_id,
description=f"Downloading...",
description="Downloading...",
progress=progress,
total=progress,
unit="iB",
Expand Down Expand Up @@ -337,7 +334,7 @@ def _get_job_file_local(self, project_id, job_id, *, target_directory: str) -> s
for n_written, total in copyfile_progress(remote_fn, dest):
self._notify_observers(
project_id,
description=f"Copying...",
description="Copying...",
progress=n_written,
total=total,
unit="iB",
Expand All @@ -350,6 +347,8 @@ def _get_job_file_local(self, project_id, job_id, *, target_directory: str) -> s
os.remove(dest)
except FileNotFoundError:
pass

raise

return dest

Expand Down Expand Up @@ -397,7 +396,7 @@ def _start_project_export(self, project_id, *, with_images):

self._notify_observers(
project_id,
description=f"Enqueued export job.",
description="Enqueued export job.",
progress=0,
total=100,
state=State.WAITING,
Expand Down Expand Up @@ -466,28 +465,28 @@ def _download_archive(

def _check_archive(self, project_id, archive_fn) -> str:
self._notify_observers(
project_id, description=f"Checking archive...", progress=0, total=1
project_id, description="Checking archive...", progress=0, total=1
)

try:
with zipfile.ZipFile(archive_fn) as zf:
zf.testzip()
except Exception:
self._notify_observers(
project_id, description=f"Checking archive...", state=State.FAILED
project_id, description="Checking archive...", state=State.FAILED
)
raise

self._notify_observers(
project_id, description=f"Checking archive...", progress=1, total=1
project_id, description="Checking archive...", progress=1, total=1
)

def _cleanup_task_data(self, project_id):
# Find finished export task for project_id

self._notify_observers(
project_id,
description=f"Cleaning up...",
description="Cleaning up...",
progress=0,
total=1,
state=State.RUNNING,
Expand All @@ -513,7 +512,7 @@ def _cleanup_task_data(self, project_id):

self._notify_observers(
project_id,
description=f"Cleaning up...",
description="Cleaning up...",
progress=1,
total=1,
state=State.RUNNING,
Expand Down

0 comments on commit edadd79

Please sign in to comment.