From a1e257c75c5726235f321d43e5a28eb886499103 Mon Sep 17 00:00:00 2001 From: AlessandroZ Date: Mon, 24 Sep 2018 14:11:28 +0200 Subject: [PATCH 1/5] fix error when listing creds: [-] u'category' --- pupy/pupylib/utils/credentials.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pupy/pupylib/utils/credentials.py b/pupy/pupylib/utils/credentials.py index 2436067a..85c599f5 100644 --- a/pupy/pupylib/utils/credentials.py +++ b/pupy/pupylib/utils/credentials.py @@ -113,6 +113,8 @@ class Credentials(object): return for creds in data: + creds = {k.lower(): v for k, v in creds.items()} + found = False c = { 'category': creds['category'], From 87c437e550fe320668673c4f441589dbdfe506b8 Mon Sep 17 00:00:00 2001 From: AlessandroZ Date: Mon, 24 Sep 2018 14:20:35 +0200 Subject: [PATCH 2/5] make flake8 happy (sorry) --- pupy/pupylib/utils/credentials.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pupy/pupylib/utils/credentials.py b/pupy/pupylib/utils/credentials.py index 85c599f5..6f00f1a6 100644 --- a/pupy/pupylib/utils/credentials.py +++ b/pupy/pupylib/utils/credentials.py @@ -113,9 +113,8 @@ class Credentials(object): return for creds in data: - creds = {k.lower(): v for k, v in creds.items()} + creds = {k.lower(): v for k, v in creds.items()} - found = False c = { 'category': creds['category'], 'cid': creds.get('cid', creds.get('uid')), From a73c08baca24bcf6ac9312445643af241deb0b29 Mon Sep 17 00:00:00 2001 From: AlessandroZ Date: Mon, 24 Sep 2018 16:38:14 +0200 Subject: [PATCH 3/5] flake8 --- pupy/pupylib/utils/credentials.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pupy/pupylib/utils/credentials.py b/pupy/pupylib/utils/credentials.py index 6f00f1a6..fb8f30db 100644 --- a/pupy/pupylib/utils/credentials.py +++ b/pupy/pupylib/utils/credentials.py @@ -7,9 +7,11 @@ from StringIO import StringIO from ..PupyConfig import PupyConfig from ..PupyCredentials import Encryptor + class EncryptionError(Exception): pass + class Credentials(object): def __init__(self, client=None, config=None, password=None): self.config = config or PupyConfig() @@ -56,7 +58,7 @@ class Credentials(object): try: db = self._load_db() except ValueError: - db = {'creds':[]} + db = {'creds': []} if not cid: if not self.client: From 6e6348dd25cc2a18562af51402b44f4ab626e166 Mon Sep 17 00:00:00 2001 From: AlessandroZ Date: Mon, 24 Sep 2018 16:38:34 +0200 Subject: [PATCH 4/5] do not check uri.password when None --- pupy/packages/all/ssh.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pupy/packages/all/ssh.py b/pupy/packages/all/ssh.py index f8455ca4..cfd376e0 100644 --- a/pupy/packages/all/ssh.py +++ b/pupy/packages/all/ssh.py @@ -188,7 +188,7 @@ class SSH(object): yield pair for process in process_iter(): - info = process.as_dict(['username', 'environ']) + info = process.as_dict() if 'environ' not in info or info['environ'] is None: continue @@ -332,7 +332,7 @@ class SSH(object): if chown: commands.append('chown {} {}'.format(repr(chown), repr(remote_path))) - if perm and type(perm) in (str,unicode): + if perm and type(perm) in (str, unicode): perm = int(perm, 8) commands.append('chmod {} {}'.format(oct(perm), repr(remote_path))) @@ -792,7 +792,7 @@ def ssh_interactive(term, w, h, wp, hp, host, port, user, passwords, private_key raise ValueError('No valid credentials found to connect to {}:{} user={}'.format( ssh.host, ssh.port, ssh.user or 'any')) - except gaierror, e: + except gaierror as e: raise ValueError('Unable to connect to {}:{} - {}'.format(host, port, e.strerror)) except NoValidConnectionsError: @@ -886,7 +886,7 @@ def _ssh_cmd(ssh_cmd, thread_name, arg, hosts, port, user, passwords, private_ke continue - except Exception, e: + except Exception as e: data_cb((3, 'Exception: {}: {}'.format(type(e), str(e)))) continue From ce3d92fa7e2857d7195b4dd555329f1abf2b7f3a Mon Sep 17 00:00:00 2001 From: AlessandroZ Date: Mon, 24 Sep 2018 16:39:26 +0200 Subject: [PATCH 5/5] fix [-] 'Process' object has no attribute 'environ' --- pupy/modules/sshell.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pupy/modules/sshell.py b/pupy/modules/sshell.py index 656d3a5e..7884ce76 100644 --- a/pupy/modules/sshell.py +++ b/pupy/modules/sshell.py @@ -80,7 +80,8 @@ class SSHell(PupyModule): host = uri.hostname port = args.port or uri.port or 22 user = args.user or uri.username - passwords = (args.passwords or tuple([uri.password]), + u_pwd = [uri.password] if uri.password else [] + passwords = (args.passwords or tuple(u_pwd), tuple(args.key_passwords)) program = ' '.join(args.program) or None