mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Change command error to warning
Also fix some smaller stilistic things
This commit is contained in:
parent
1699324304
commit
14f7da4e04
1 changed files with 13 additions and 9 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue