Browse Source

Use f-strings in log_mail function

Note: For f-string support python 3.6 is required, see [0]

[0]https://www.python.org/dev/peps/pep-0498/
mario forzanini 2 years ago
parent
commit
2f9f3e0486
1 changed files with 4 additions and 5 deletions
  1. 4 5
      lcmlog-server

+ 4 - 5
lcmlog-server

@@ -228,12 +228,11 @@ def log_hash(name):
 # True add the 'Reply-to: ' header to the email
 def log_mail(kind, user_name, date, tags, log):
 	if REPLY_TO:
-                subprocess.run("printf " + shlex.quote(log) + " | mail -s \"Log" + kind + " " + date + " " + tags +
-                               "\" -r " + user + FROM_DOMAIN + " -a \"Reply-to:" + TO_ADDRESS + " \" -- "
-		               + TO_ADDRESS, shell=True)
+                subprocess.run('printf "%s\n" ' + f'{shlex.quote(log)} | mail -s "Log{kind} {date} {tags}" ' +
+                               f'-r {user}@{FROM_DOMAIN} -a "Reply-to: {TO_ADDRESS}" -- {TO_ADDRESS}', shell=True)
 	else:
-		subprocess.run("printf \"%s\n\" " + shlex.quote(log) + " | mail -s \"Log" | kind + " " + date + " " + tags +
-		               "\" -r " + user + FROM_DOMAIN + " -- " + TO_ADDRESS, shell=True)
+                subprocess.run('printf "%s\n" ' + f'{shlex.quote(log)} | mail -s "Log{kind} {date} {tags}" ' +
+                               f'-r {user}@{FROM_DOMAIN} -- {TO_ADDRESS}', shell=True)
 	return