Commit e31dd3b2 authored by Alan's avatar Alan
Browse files

Simplify syntax using subprocess.check_ouput now that it is available

parent 3bc3844e
......@@ -49,21 +49,16 @@ def _notify(title, body):
"""
cmd = "/usr/local/sbin/tails-notify-user"
try:
# XXX: replace with check_output when Tails will be based on Wheezy
# (which includes Python 2.7)
notify_user = subprocess.Popen([cmd, title, body],
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE)
notify_user_output = notify_user.stdout.read()
notify_user.wait()
if notify_user.returncode != 0:
syslog.syslog(syslog.LOG_WARNING,
"Warning: unable to notify the user. %s returned "
"with exit code %s" % (cmd, notify_user.returncode))
syslog.syslog(syslog.LOG_WARNING,
"%s output follows: %s." % (cmd, notify_user_output))
syslog.syslog(syslog.LOG_WARNING,
"The notification was: %s %s" % (title, body))
notify_user = subprocess.check_output([cmd, title, body],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
syslog.syslog(syslog.LOG_WARNING,
"Warning: unable to notify the user. %s returned "
"with exit code %s" % (cmd, e.returncode))
syslog.syslog(syslog.LOG_WARNING,
"%s output follows: %s." % (cmd, notify_user))
syslog.syslog(syslog.LOG_WARNING,
"The notification was: %s %s" % (title, body))
except OSError as e:
syslog.syslog(syslog.LOG_WARNING,
"Warning: unable to notify the user. %s" % e)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment