Skip to content

Commit

Permalink
Fix calls to move() for Python versions < 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
tysmith committed Jun 5, 2024
1 parent b3aed93 commit c33bdc5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion grizzly/common/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,5 @@ def tail(in_file: Path, size_limit: int) -> None:
out_fp.write(b"[LOG TAILED]\n")
copyfileobj(in_fp, out_fp, 0x10000) # 64KB chunks
in_file.unlink()
move(out_file, in_file)
# Python 3.9+: move() accepts a path-like object for both src and dst
move(out_file, str(in_file.resolve()))
3 changes: 2 additions & 1 deletion grizzly/common/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def _submit_report(
log_path = dest / f"{self.report_prefix}_logs"
if log_path.is_dir():
LOG.warning("Report log path exists '%s'", log_path)
move(report.path, log_path)
# Python 3.9+: move() accepts a path-like object for both src and dst
move(str(report.path.resolve()), str(log_path.resolve()))
# avoid filling the disk
free_space = disk_usage(str(log_path.resolve())).free
if free_space < self.min_space:
Expand Down
3 changes: 2 additions & 1 deletion grizzly/common/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def add_from_file(
if copy:
copyfile(src_file, dst_file)
else:
move(src_file, dst_file)
# Python 3.9+: move() accepts a path-like object for both src and dst
move(str(src_file.resolve()), str(dst_file.resolve()))

# entry_point is always 'required'
if required or url_path == self.entry_point:
Expand Down
4 changes: 2 additions & 2 deletions grizzly/target/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def add(self, asset: str, path: Path, copy: bool = True) -> Path:
else:
copytree(path, dst)
else:
# TODO: move() only accepts str in Python 3.8
move(str(path), str(self.path))
# Python 3.9+: move() accepts a path-like object for both src and dst
move(str(path.resolve()), str(self.path.resolve()))
self.assets[asset] = path.name
LOG.debug("%s asset %r to '%s'", "copied" if copy else "moved", asset, dst)
return dst
Expand Down

0 comments on commit c33bdc5

Please sign in to comment.