Fix flake8 warnings
This commit is contained in:
1 parent
051976f560
commit
3964935580
1 file changed
+8
-8
+8
-8
@@ -93,13 +93,13 @@ def send_email(success):
|
|||||||
log = email_log.getvalue()
|
log = email_log.getvalue()
|
||||||
maxsize = config['email'].get('maxsize', 500) * 1024
|
maxsize = config['email'].get('maxsize', 500) * 1024
|
||||||
if maxsize and len(log) > maxsize:
|
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 = (
|
log = (
|
||||||
"NOTE: Log was too big for email and was shortened\n\n" +
|
"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(
|
"[...]\n\n\n --- LOG WAS TOO BIG - {} LINES REMOVED --\n\n\n[...]".format(
|
||||||
cut_lines) +
|
cut_lines) +
|
||||||
log[-maxsize//2:])
|
log[-maxsize // 2:])
|
||||||
body += log
|
body += log
|
||||||
|
|
||||||
msg = MIMEText(body, "plain", "utf-8")
|
msg = MIMEText(body, "plain", "utf-8")
|
||||||
@@ -129,7 +129,7 @@ def finish(is_success):
|
|||||||
if ("error", "success")[is_success] in config["email"]["sendon"]:
|
if ("error", "success")[is_success] in config["email"]["sendon"]:
|
||||||
try:
|
try:
|
||||||
send_email(is_success)
|
send_email(is_success)
|
||||||
except:
|
except Exception:
|
||||||
logging.exception("Failed to send email")
|
logging.exception("Failed to send email")
|
||||||
if is_success:
|
if is_success:
|
||||||
logging.info("Run finished successfully")
|
logging.info("Run finished successfully")
|
||||||
@@ -219,14 +219,14 @@ def main():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
load_config(args)
|
load_config(args)
|
||||||
except:
|
except Exception:
|
||||||
print("unexpected exception while loading config")
|
print("unexpected exception while loading config")
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
setup_logger()
|
setup_logger()
|
||||||
except:
|
except Exception:
|
||||||
print("unexpected exception while setting up logging")
|
print("unexpected exception while setting up logging")
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
@@ -265,8 +265,8 @@ def run():
|
|||||||
diff_results = Counter(line.split(" ")[0] for line in diff_out)
|
diff_results = Counter(line.split(" ")[0] for line in diff_out)
|
||||||
diff_results = dict((x, diff_results[x]) for x in
|
diff_results = dict((x, diff_results[x]) for x in
|
||||||
["add", "remove", "move", "update"])
|
["add", "remove", "move", "update"])
|
||||||
logging.info(("Diff results: {add} added, {remove} removed, "
|
logging.info(("Diff results: {add} added, {remove} removed, " +
|
||||||
+ "{move} moved, {update} modified").format(**diff_results))
|
"{move} moved, {update} modified").format(**diff_results))
|
||||||
|
|
||||||
if (config["snapraid"]["deletethreshold"] >= 0 and
|
if (config["snapraid"]["deletethreshold"] >= 0 and
|
||||||
diff_results["remove"] > config["snapraid"]["deletethreshold"]):
|
diff_results["remove"] > config["snapraid"]["deletethreshold"]):
|
||||||
|
|||||||
Reference in new issue
Block a user