Skip to content

Commit

Permalink
Fix flake8 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Chronial committed Aug 16, 2019
1 parent 051976f commit 3964935
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions snapraid-runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ def send_email(success):
log = email_log.getvalue()
maxsize = config['email'].get('maxsize', 500) * 1024
if maxsize and len(log) > maxsize:
cut_lines = log.count("\n", maxsize//2, -maxsize//2)
cut_lines = log.count("\n", maxsize // 2, -maxsize // 2)
log = (
"NOTE: Log was too big for email and was shortened\n\n" +
log[:maxsize//2] +
log[:maxsize // 2] +
"[...]\n\n\n --- LOG WAS TOO BIG - {} LINES REMOVED --\n\n\n[...]".format(
cut_lines) +
log[-maxsize//2:])
log[-maxsize // 2:])
body += log

msg = MIMEText(body, "plain", "utf-8")
Expand Down Expand Up @@ -129,7 +129,7 @@ def finish(is_success):
if ("error", "success")[is_success] in config["email"]["sendon"]:
try:
send_email(is_success)
except:
except Exception:
logging.exception("Failed to send email")
if is_success:
logging.info("Run finished successfully")
Expand Down Expand Up @@ -219,14 +219,14 @@ def main():

try:
load_config(args)
except:
except Exception:
print("unexpected exception while loading config")
print(traceback.format_exc())
sys.exit(2)

try:
setup_logger()
except:
except Exception:
print("unexpected exception while setting up logging")
print(traceback.format_exc())
sys.exit(2)
Expand Down Expand Up @@ -265,14 +265,14 @@ def run():
diff_results = Counter(line.split(" ")[0] for line in diff_out)
diff_results = dict((x, diff_results[x]) for x in
["add", "remove", "move", "update"])
logging.info(("Diff results: {add} added, {remove} removed, "
+ "{move} moved, {update} modified").format(**diff_results))
logging.info(("Diff results: {add} added, {remove} removed, " +
"{move} moved, {update} modified").format(**diff_results))

if (config["snapraid"]["deletethreshold"] >= 0 and
diff_results["remove"] > config["snapraid"]["deletethreshold"]):
logging.error(
"Deleted files exceed delete threshold of {}, aborting".format(
config["snapraid"]["deletethreshold"]))
config["snapraid"]["deletethreshold"]))
finish(False)

if (diff_results["remove"] + diff_results["add"] + diff_results["move"] +
Expand Down

0 comments on commit 3964935

Please sign in to comment.