Skip to content

Commit

Permalink
do not wait for rsync to finish before logging stdout to file (#11)
Browse files Browse the repository at this point in the history
* do not wait for rsync to finish before logging stdout to file

* bump version to 0.0.7
  • Loading branch information
erietz authored Mar 2, 2024
1 parent 5f2394d commit aeb3e12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
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.6"
__version__ = "0.0.7"
13 changes: 8 additions & 5 deletions src/pisync/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,15 @@ def enforce_system_requirements() -> None:

def run_rsync(rsync_command: List[str]) -> int:
logging.info(f"Running {rsync_command}")

start_time = time.perf_counter()
process = subprocess.run(rsync_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in process.stdout.decode().split("\n"):
logging.info(f"RSYNC: {line}")

process = subprocess.Popen(rsync_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if process.stdout is not None:
for line in process.stdout:
logging.info(f"RSYNC: {line.rstrip()}")
return_code = process.wait()

end_time = time.perf_counter()
logging.info(f"Time elapsed {end_time - start_time} seconds")

return process.returncode
return return_code

0 comments on commit aeb3e12

Please sign in to comment.