Skip to content

Commit

Permalink
Remove progress info from snapraid output
Browse files Browse the repository at this point in the history
  • Loading branch information
Chronial committed Sep 25, 2021
1 parent 4cb7e69 commit 8acd931
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ feature you are missing, you can have a look
### Unreleased
* Add --ignore-deletethreshold (by exterrestris, #25)
* Add support for scrub --plan, replacing --percentage
* Remove snapraid progress output. Was accidentially introduced with python3
support.

### v0.5 (26 Feb 2021)
* Remove (broken) python2 support
Expand Down
13 changes: 4 additions & 9 deletions snapraid-runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ def tee_log(infile, out_lines, log_level):
"""
def tee_thread():
for line in iter(infile.readline, ""):
line = line.strip()
# Do not log the progress display
if "\r" in line:
line = line.split("\r")[-1]
logging.log(log_level, line.strip())
logging.log(log_level, line.rstrip())
out_lines.append(line)
infile.close()
t = threading.Thread(target=tee_thread)
Expand All @@ -44,19 +40,18 @@ def snapraid_command(command, args={}, *, allow_statuscodes=[]):
Run snapraid command
Raises subprocess.CalledProcessError if errorlevel != 0
"""
arguments = ["--conf", config["snapraid"]["config"]]
arguments = ["--conf", config["snapraid"]["config"],
"--quiet"]
for (k, v) in args.items():
arguments.extend(["--" + k, str(v)])
p = subprocess.Popen(
[config["snapraid"]["executable"], command] + arguments,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
# Snapraid always outputs utf-8 on windows. On linux, utf-8
# also seems a sensible assumption.
encoding="utf-8",
errors="replace"
)
errors="replace")
out = []
threads = [
tee_log(p.stdout, out, logging.OUTPUT),
Expand Down

0 comments on commit 8acd931

Please sign in to comment.