Skip to content

Commit

Permalink
stderr was being captured by PIPE but not logged (#12)
Browse files Browse the repository at this point in the history
* stderr was being captured by PIPE but not logged

* fix linting errors...
  • Loading branch information
erietz authored Mar 2, 2024
1 parent aeb3e12 commit d39ee67
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ dependencies = [
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:src/pisync tests}"
style = [
"ruff {args:.}",
"ruff check {args:.}",
"black --check --diff {args:.}",
]
fmt = [
"black {args:.}",
"ruff --fix {args:.}",
"ruff check --fix {args:.}",
"style",
]
all = [
Expand All @@ -93,7 +93,7 @@ skip-string-normalization = true
[tool.ruff]
target-version = "py37"
line-length = 120
select = [
lint.select = [
"A",
"ARG",
"B",
Expand All @@ -120,7 +120,7 @@ select = [
"W",
"YTT",
]
ignore = [
lint.ignore = [
# Allow non-abstract empty methods in abstract base classes
"B027",
# Allow boolean positional values in function calls, like `dict.get(... True)`
Expand All @@ -132,18 +132,18 @@ ignore = [
# I do not know how to fix this `subprocess` call: check for execution of untrusted input
"S603"
]
unfixable = [
lint.unfixable = [
# Don't touch unused imports
"F401",
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["pisync"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]

Expand Down
2 changes: 1 addition & 1 deletion src/pisync/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.7"
__version__ = "0.0.8"
12 changes: 10 additions & 2 deletions src/pisync/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ def backup(config: BaseConfig) -> str:
return latest_backup_path
else:
msg = f"Backup failed. Rsync exit code: {exit_code}"
logging.error(msg)
logging.fatal(msg)
# backup failed, we should delete the most recent backup
if config.file_exists(latest_backup_path):
logging.info(f"Deleting failed backup at {latest_backup_path}")
logging.fatal(f"Deleting failed backup at {latest_backup_path}")
config.rmtree(latest_backup_path)
raise BackupFailedError(msg)

Expand Down Expand Up @@ -98,9 +98,17 @@ def run_rsync(rsync_command: List[str]) -> int:
start_time = time.perf_counter()

process = subprocess.Popen(rsync_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

# If the stdout argument was not PIPE, this attribute is None.
if process.stdout is not None:
for line in process.stdout:
logging.info(f"RSYNC: {line.rstrip()}")

# If the stderr argument was not PIPE, this attribute is None.
if process.stderr is not None:
for line in process.stderr:
logging.error(f"RSYNC: {line.rstrip()}")

return_code = process.wait()

end_time = time.perf_counter()
Expand Down

0 comments on commit d39ee67

Please sign in to comment.