diff options
author | mathieui <mathieui@mathieui.net> | 2015-09-24 19:52:57 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2015-09-24 19:52:57 +0200 |
commit | fce4daf4a158cede422b3b918511666c19665b60 (patch) | |
tree | 2a86b87f1aa587d73e26a9bd4ed4c865bc1fd0af /src | |
parent | 99d5e25f9bb9a6cbe51973d8409691ad8e5482a1 (diff) | |
download | poezio-fce4daf4a158cede422b3b918511666c19665b60.tar.gz poezio-fce4daf4a158cede422b3b918511666c19665b60.tar.bz2 poezio-fce4daf4a158cede422b3b918511666c19665b60.tar.xz poezio-fce4daf4a158cede422b3b918511666c19665b60.zip |
Exit if the eval_password command returns a non-zero status code
Diffstat (limited to 'src')
-rw-r--r-- | src/connection.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/connection.py b/src/connection.py index 23c07d59..b3bf00e3 100644 --- a/src/connection.py +++ b/src/connection.py @@ -15,6 +15,7 @@ log = logging.getLogger(__name__) import getpass import subprocess +import sys import slixmpp from slixmpp.plugins.xep_0184 import XEP_0184 @@ -49,10 +50,15 @@ class Connection(slixmpp.ClientXMPP): if not password and not eval_password and not (keyfile and certfile): password = getpass.getpass() elif not password and not (keyfile and certfile): - print("No password or certificates provided, using the eval_password command.") + sys.stderr.write("No password or certificates provided, using the eval_password command.\n") process = subprocess.Popen(['sh', '-c', eval_password], stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) - process.wait() + code = process.wait() + if code != 0: + sys.stderr.write('The eval_password command (%s) returned a ' + 'nonzero status code: %s.\n' % (eval_password, code)) + sys.stderr.write('Poezio will now exit\n') + sys.exit(code) password = process.stdout.readline().decode('utf-8').strip('\n') else: # anonymous auth self.anon = True |