Skip to content

Commit

Permalink
fix python3.7 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
lidong committed Jun 4, 2024
1 parent f2dd8be commit 280e4a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 12 additions & 3 deletions zipapps/download_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ def sort_key(s):
if target == "q":
return
target_path = Path(target)
target_path.unlink(missing_ok=True)
try:
target_path.unlink()
except FileNotFoundError:
pass
print(f"[{get_time()}] Start downloading...")
print(download_url)
print(target_path.absolute(), flush=True)
Expand Down Expand Up @@ -224,14 +227,20 @@ def reporthook(blocknum, blocksize, totalsize):
except http.client.RemoteDisconnected:
continue
except KeyboardInterrupt:
temp_path.unlink(missing_ok=True)
try:
temp_path.unlink()
except FileNotFoundError:
pass
print()
print(f"\n[{get_time()}] Download canceled.", flush=True)
return
except Exception:
print()
traceback.print_exc()
temp_path.unlink(missing_ok=True)
try:
temp_path.unlink()
except FileNotFoundError:
pass
break
print("Press enter to exit.", flush=True)
input()
Expand Down
5 changes: 4 additions & 1 deletion zipapps/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,10 @@ def _rm_with_patterns(
if path.is_dir():
shutil.rmtree(path, ignore_errors=True)
else:
path.unlink(missing_ok=True)
try:
path.unlink()
except FileNotFoundError:
pass

@classmethod
def _pip_install(cls, target_dir: Path, pip_args: list):
Expand Down

0 comments on commit 280e4a7

Please sign in to comment.