From 14f7da4e04ea09bc1c026f217edb79ee6fe811b6 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sat, 13 Sep 2014 14:36:44 +0200 Subject: [PATCH] Change command error to warning Also fix some smaller stilistic things --- vdirsyncer/utils/__init__.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/vdirsyncer/utils/__init__.py b/vdirsyncer/utils/__init__.py index 2fdedcf..52d0513 100644 --- a/vdirsyncer/utils/__init__.py +++ b/vdirsyncer/utils/__init__.py @@ -172,23 +172,27 @@ def _password_from_command(username, host): '''command''' import subprocess - try: - general, _, _ = ctx.obj['config'] - _command = general['passwordeval'].split() - except (IndexError, KeyError): + if not ctx: return None - command = [expand_path(_command[0])] - if len(_command) > 1: - command += _command[1:] + try: + general, _, _ = ctx.obj['config'] + command = general['passwordeval'].split() + except KeyError: + return None + + if not command: + return None + + command[0] = expand_path(command[0]) try: proc = subprocess.Popen(command + [username, host], stdout=subprocess.PIPE) password = proc.stdout.read().decode('utf-8').strip() except OSError as e: - logger.debug('Failed to execute command: {}\n{}'. - format(" ".join(command), str(e))) + logger.warning('Failed to execute command: {}\n{}'. + format(' '.join(command), str(e))) return None return password