Compare commits

..

No commits in common. "81d430b56b0ec8ff2ce6b03c6023adbde0c6697c" and "a540f4336f6778115cd52b5e9df20bb052dbfd16" have entirely different histories.

View File

@ -15,7 +15,6 @@ import select
import pathlib
import threading
import subprocess
import _thread # for interrupt_main
import typing
@ -318,7 +317,10 @@ def main(argv: typing.List[str]):
for line in fh:
try:
data = json.loads(line)
if data['type'] == 'log_message':
if ((data['type'] == 'log_message' or
data['type'] == 'progress_message')
and 'message' in data):
# Count warnings and errors, but ignore some.
changed_msg = "file changed while we backed it up"
if data['levelname'] == 'WARNING':
@ -332,11 +334,6 @@ def main(argv: typing.List[str]):
prefix = ""
line = (prefix + data['message'] + '\n').encode()
elif (data['type'] == 'progress_message'
and 'message' in data):
line = (data['message'] + '\n').encode()
elif data['type'] == 'archive_progress':
now = time.time()
if now - last_progress > 10:
@ -356,20 +353,13 @@ def main(argv: typing.List[str]):
# ignore unknown progress line
continue
except Exception as e:
# on error, print raw line with exception
line = f"[exception: {str(e)} ]".encode() + line
# on error, print raw line
pass
sys.stdout.buffer.write(line)
sys.stdout.flush()
captured_output.append(line)
fh.close()
def _reader_thread(fh):
try:
return reader_thread(fh)
except BrokenPipeError:
pass
except Exception:
_thread.interrupt_main()
reader = threading.Thread(target=_reader_thread, args=(borg.stdout,))
reader = threading.Thread(target=reader_thread, args=(borg.stdout,))
reader.daemon = True
reader.start()