Change command error to warning

Also fix some smaller stilistic things
This commit is contained in:
Markus Unterwaditzer 2014-09-13 14:36:44 +02:00
parent 1699324304
commit 14f7da4e04

View file

@ -172,23 +172,27 @@ def _password_from_command(username, host):
'''command''' '''command'''
import subprocess import subprocess
try: if not ctx:
general, _, _ = ctx.obj['config']
_command = general['passwordeval'].split()
except (IndexError, KeyError):
return None return None
command = [expand_path(_command[0])] try:
if len(_command) > 1: general, _, _ = ctx.obj['config']
command += _command[1:] command = general['passwordeval'].split()
except KeyError:
return None
if not command:
return None
command[0] = expand_path(command[0])
try: try:
proc = subprocess.Popen(command + [username, host], proc = subprocess.Popen(command + [username, host],
stdout=subprocess.PIPE) stdout=subprocess.PIPE)
password = proc.stdout.read().decode('utf-8').strip() password = proc.stdout.read().decode('utf-8').strip()
except OSError as e: except OSError as e:
logger.debug('Failed to execute command: {}\n{}'. logger.warning('Failed to execute command: {}\n{}'.
format(" ".join(command), str(e))) format(' '.join(command), str(e)))
return None return None
return password return password