Skip to content

Commit

Permalink
exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aliaksei-chareshneu committed Jun 13, 2024
1 parent 702966c commit 30dd763
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions preprocessor/cellstar_preprocessor/tools/deploy_db/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,23 @@ def _download(uri: str, final_path: Path, kind: InputKind):
ome_zarr.utils.download(uri, str(final_path.resolve()))
return complete_path
else:
try:
# regular download
# filename construct based on last component of uri
complete_path = final_path / filename
if complete_path.exists():
if complete_path.is_dir():
shutil.rmtree(complete_path)
else:
complete_path.unlink()
if not final_path.exists():
final_path.mkdir(parents=True)
urllib.request.urlretrieve(uri, str(complete_path.resolve()))
# check if returns filename
return complete_path
complete_path = final_path / filename
if complete_path.exists():
if complete_path.is_dir():
shutil.rmtree(complete_path)
else:
complete_path.unlink()
if not final_path.exists():
final_path.mkdir(parents=True)
urllib.request.urlretrieve(uri, str(complete_path.resolve()))
# check if returns filename
return complete_path
except Exception as e:
print(f'uri: {uri}, final_path: {final_path}, kind: {kind}')



def _copy_file(uri: str, final_path: Path, kind: InputKind):
Expand Down

0 comments on commit 30dd763

Please sign in to comment.