Read rsync output while it runs

Read the output as it arrives, split on newlines and carriage returns,
instead of all at once with communicate(). This is needed for the
progress bar. Invalid UTF-8 in the output is replaced instead of raising.
This commit is contained in:
Fuxino
2026-10-14 09:42:37 +02:00
parent a3ace84c8b
commit d0fb5b65fb
3 changed files with 56 additions and 11 deletions
+4 -2
View File
@@ -257,6 +257,8 @@ class RecordPopen:
def __init__(self, args: list[str], **kwargs: Any) -> None:
RecordPopen.calls.append(args)
self.stdin = io.BytesIO()
self.stdout = io.BytesIO(b'sent 1 bytes received 2 bytes\ntotal size is 3\n')
def __enter__(self) -> 'RecordPopen':
return self
@@ -264,8 +266,8 @@ class RecordPopen:
def __exit__(self, *args: Any) -> None:
pass
def communicate(self) -> tuple[bytes, None]:
return b'sent 1 bytes received 2 bytes\ntotal size is 3\n', None
def wait(self) -> int:
return RecordPopen.returncode
@pytest.mark.usefixtures('connect')