pyupgrade: Reformat with --py36-plus.
This includes mainly fixes of string literals using f-strings or .format(...), as well as unpacking of list comprehensions.
This commit is contained in:
parent
e27ac0ddbe
commit
9ce7c52a10
78 changed files with 356 additions and 389 deletions
|
@ -46,12 +46,12 @@ def mkdir_p(path: str) -> None:
|
|||
|
||||
|
||||
def send_log_zulip(file_name: str, count: int, lines: List[str], extra: str = "") -> None:
|
||||
content = "%s new errors%s:\n```\n%s\n```" % (count, extra, "\n".join(lines))
|
||||
content = "{} new errors{}:\n```\n{}\n```".format(count, extra, "\n".join(lines))
|
||||
zulip_client.send_message(
|
||||
{
|
||||
"type": "stream",
|
||||
"to": "logs",
|
||||
"subject": "%s on %s" % (file_name, platform.node()),
|
||||
"subject": f"{file_name} on {platform.node()}",
|
||||
"content": content,
|
||||
}
|
||||
)
|
||||
|
@ -84,7 +84,7 @@ def process_logs() -> None:
|
|||
file_data = last_data.get(log_file, {})
|
||||
if not os.path.exists(log_file):
|
||||
# If the file doesn't exist, log an error and then move on to the next file
|
||||
print("Log file does not exist or could not stat log file: %s" % (log_file,))
|
||||
print(f"Log file does not exist or could not stat log file: {log_file}")
|
||||
continue
|
||||
length = int(subprocess.check_output(["wc", "-l", log_file]).split()[0])
|
||||
if file_data.get("last") is None:
|
||||
|
@ -95,7 +95,7 @@ def process_logs() -> None:
|
|||
# a log file ends up at the same line length as before
|
||||
# immediately after rotation, this tool won't notice.
|
||||
file_data["last"] = 1
|
||||
output = subprocess.check_output(["tail", "-n+%s" % (file_data["last"],), log_file])
|
||||
output = subprocess.check_output(["tail", "-n+{}".format(file_data["last"]), log_file])
|
||||
new_lines = output.decode("utf-8", errors="replace").split("\n")[:-1]
|
||||
if len(new_lines) > 0:
|
||||
process_lines(new_lines, log_file)
|
||||
|
@ -124,7 +124,7 @@ if __name__ == "__main__":
|
|||
try:
|
||||
log_files = json.loads(open(args.control_path).read())
|
||||
except (json.JSONDecodeError, OSError):
|
||||
print("Could not load control data from %s" % (args.control_path,))
|
||||
print(f"Could not load control data from {args.control_path}")
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
process_logs()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue