Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix calls to move() for Python versions < 3.9 #448

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading