summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2017-10-11 14:54:49 -0700
committerJeff Forcier <jeff@bitprophet.org>2017-10-11 14:54:49 -0700
commit838748dcb61af0a469230690aa369dd1ae8895ab (patch)
treefacf919a43a41cf5b73cb9e1ed986e91d2772c6e
parent75d7abb97608a5fad14aad1d85c421a7a713f6e9 (diff)
flake8 for previous changeset
-rw-r--r--paramiko/channel.py6
-rw-r--r--paramiko/client.py14
-rw-r--r--paramiko/ecdsakey.py4
-rw-r--r--paramiko/hostkeys.py5
-rw-r--r--paramiko/kex_ecdh_nist.py4
-rw-r--r--paramiko/kex_gex.py4
-rw-r--r--paramiko/kex_group1.py3
-rw-r--r--paramiko/packet.py12
-rw-r--r--paramiko/pkey.py6
-rw-r--r--paramiko/sftp_client.py10
10 files changed, 42 insertions, 26 deletions
diff --git a/paramiko/channel.py b/paramiko/channel.py
index 749749d9..91a8f0df 100644
--- a/paramiko/channel.py
+++ b/paramiko/channel.py
@@ -985,7 +985,8 @@ class Channel (ClosingContextManager):
max_packet_size
)
self.active = 1
- self._log(DEBUG, 'Max packet out: {} bytes'.format(self.out_max_packet_size))
+ self._log(DEBUG,
+ 'Max packet out: {} bytes'.format(self.out_max_packet_size))
def _request_success(self, m):
self._log(DEBUG, 'Sesch channel {} request ok'.format(self.chanid))
@@ -1255,7 +1256,8 @@ class Channel (ClosingContextManager):
if self.in_window_sofar <= self.in_window_threshold:
return 0
if self.ultra_debug:
- self._log(DEBUG, 'addwindow send {}'.format(self.in_window_sofar))
+ self._log(DEBUG,
+ 'addwindow send {}'.format(self.in_window_sofar))
out = self.in_window_sofar
self.in_window_sofar = 0
return out
diff --git a/paramiko/client.py b/paramiko/client.py
index b08c6e64..5f0e9274 100644
--- a/paramiko/client.py
+++ b/paramiko/client.py
@@ -599,7 +599,8 @@ class SSHClient (ClosingContextManager):
try:
self._log(
DEBUG,
- 'Trying SSH key {}'.format(hexlify(pkey.get_fingerprint())))
+ 'Trying SSH key {}'.format(hexlify(pkey.get_fingerprint()))
+ )
allowed_types = set(
self._transport.auth_publickey(username, pkey))
two_factor = (allowed_types & two_factor_types)
@@ -630,11 +631,8 @@ class SSHClient (ClosingContextManager):
for key in self._agent.get_keys():
try:
- self._log(
- DEBUG,
- 'Trying SSH agent key {}'.format(
- hexlify(key.get_fingerprint())
- ))
+ id_ = hexlify(key.get_fingerprint())
+ self._log(DEBUG, 'Trying SSH agent key {}'.format(id_))
# for 2-factor auth a successfully auth'd key password
# will return an allowed 2fac auth method
allowed_types = set(
@@ -753,7 +751,9 @@ class RejectPolicy (MissingHostKeyPolicy):
client._log(DEBUG, 'Rejecting {} host key for {}: {}'.format(
key.get_name(), hostname, hexlify(key.get_fingerprint()),
))
- raise SSHException('Server {!r} not found in known_hosts'.format(hostname))
+ raise SSHException(
+ 'Server {!r} not found in known_hosts'.format(hostname)
+ )
class WarningPolicy (MissingHostKeyPolicy):
diff --git a/paramiko/ecdsakey.py b/paramiko/ecdsakey.py
index 3448bc39..92e01a75 100644
--- a/paramiko/ecdsakey.py
+++ b/paramiko/ecdsakey.py
@@ -144,7 +144,9 @@ class ECDSAKey(PKey):
)
curvename = msg.get_text()
if curvename != self.ecdsa_curve.nist_name:
- raise SSHException("Can't handle curve of type {}".format(curvename))
+ raise SSHException(
+ "Can't handle curve of type {}".format(curvename)
+ )
pointinfo = msg.get_binary()
try:
diff --git a/paramiko/hostkeys.py b/paramiko/hostkeys.py
index 7bd75bb5..ca185273 100644
--- a/paramiko/hostkeys.py
+++ b/paramiko/hostkeys.py
@@ -338,9 +338,8 @@ class HostKeyEntry:
fields = line.split(' ')
if len(fields) < 3:
# Bad number of fields
- log.info("Not enough fields found in known_hosts in line {} ({!r})".format(
- lineno, line
- ))
+ msg = "Not enough fields found in known_hosts in line {} ({!r})"
+ log.info(msg.format(lineno, line))
return None
fields = fields[:3]
diff --git a/paramiko/kex_ecdh_nist.py b/paramiko/kex_ecdh_nist.py
index a5451c69..4e8ff35d 100644
--- a/paramiko/kex_ecdh_nist.py
+++ b/paramiko/kex_ecdh_nist.py
@@ -45,7 +45,9 @@ class KexNistp256():
return self._parse_kexecdh_init(m)
elif not self.transport.server_mode and (ptype == _MSG_KEXECDH_REPLY):
return self._parse_kexecdh_reply(m)
- raise SSHException('KexECDH asked to handle packet type {:d}'.format(ptype))
+ raise SSHException(
+ 'KexECDH asked to handle packet type {:d}'.format(ptype)
+ )
def _generate_key_pair(self):
self.P = ec.generate_private_key(self.curve, default_backend())
diff --git a/paramiko/kex_gex.py b/paramiko/kex_gex.py
index f60f49a4..44030569 100644
--- a/paramiko/kex_gex.py
+++ b/paramiko/kex_gex.py
@@ -91,8 +91,8 @@ class KexGex (object):
return self._parse_kexdh_gex_reply(m)
elif ptype == _MSG_KEXDH_GEX_REQUEST_OLD:
return self._parse_kexdh_gex_request_old(m)
- raise SSHException(
- 'KexGex {} asked to handle packet type {:d}'.format(self.name, ptype))
+ msg = "KexGex {} asked to handle packet type {:d}"
+ raise SSHException(msg.format(self.name, ptype))
# ...internals...
diff --git a/paramiko/kex_group1.py b/paramiko/kex_group1.py
index 64d463cd..1bebd375 100644
--- a/paramiko/kex_group1.py
+++ b/paramiko/kex_group1.py
@@ -73,7 +73,8 @@ class KexGroup1(object):
return self._parse_kexdh_init(m)
elif not self.transport.server_mode and (ptype == _MSG_KEXDH_REPLY):
return self._parse_kexdh_reply(m)
- raise SSHException('KexGroup1 asked to handle packet type {:d}'.format(ptype))
+ msg = "KexGroup1 asked to handle packet type {:d}"
+ raise SSHException(msg.format(ptype))
# ...internals...
diff --git a/paramiko/packet.py b/paramiko/packet.py
index 840a59a7..830a59ea 100644
--- a/paramiko/packet.py
+++ b/paramiko/packet.py
@@ -405,8 +405,9 @@ class Packetizer (object):
)
if sent_too_much and not self.__need_rekey:
# only ask once for rekeying
- self._log(DEBUG, 'Rekeying (hit {} packets, {} bytes sent)'.format(
- self.__sent_packets, self.__sent_bytes,
+ msg = "Rekeying (hit {} packets, {} bytes sent)"
+ self._log(DEBUG, msg.format(
+ self.__sent_packets, self.__sent_bytes,
))
self.__received_bytes_overflow = 0
self.__received_packets_overflow = 0
@@ -458,7 +459,9 @@ class Packetizer (object):
if self.__dump_packets:
self._log(
DEBUG,
- 'Got payload ({} bytes, {} padding)'.format(packet_size, padding),
+ 'Got payload ({} bytes, {} padding)'.format(
+ packet_size, padding
+ )
)
if self.__compress_engine_in is not None:
@@ -486,7 +489,8 @@ class Packetizer (object):
elif (self.__received_packets >= self.REKEY_PACKETS) or \
(self.__received_bytes >= self.REKEY_BYTES):
# only ask once for rekeying
- self._log(DEBUG, 'Rekeying (hit {} packets, {} bytes received)'.format(
+ msg = "Rekeying (hit {} packets, {} bytes received)"
+ self._log(DEBUG, msg.format(
self.__received_packets, self.__received_bytes,
))
self.__received_bytes_overflow = 0
diff --git a/paramiko/pkey.py b/paramiko/pkey.py
index ae01dca2..808215f8 100644
--- a/paramiko/pkey.py
+++ b/paramiko/pkey.py
@@ -310,9 +310,11 @@ class PKey(object):
# unencryped: done
return data
# encrypted keyfile: will need a password
- if headers['proc-type'] != '4,ENCRYPTED':
+ proc_type = headers['proc-type']
+ if proc_type != '4,ENCRYPTED':
raise SSHException(
- 'Unknown private key structure "{}"'.format(headers['proc-type']))
+ 'Unknown private key structure "{}"'.format(proc_type)
+ )
try:
encryption_type, saltstr = headers['dek-info'].split(',')
except:
diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py
index d52cf943..b344dff3 100644
--- a/paramiko/sftp_client.py
+++ b/paramiko/sftp_client.py
@@ -105,7 +105,8 @@ class SFTPClient(BaseSFTP, ClosingContextManager):
raise SSHException('EOF during negotiation')
self._log(
INFO,
- 'Opened sftp connection (server version {})'.format(server_version))
+ 'Opened sftp connection (server version {})'.format(server_version)
+ )
@classmethod
def from_transport(cls, t, window_size=None, max_packet_size=None):
@@ -343,7 +344,8 @@ class SFTPClient(BaseSFTP, ClosingContextManager):
handle = msg.get_binary()
self._log(
DEBUG,
- 'open({!r}, {!r}) -> {}'.format(filename, mode, u(hexlify(handle))))
+ 'open({!r}, {!r}) -> {}'.format(filename, mode, u(hexlify(handle)))
+ )
return SFTPFile(self, handle, mode, bufsize)
# Python continues to vacillate about "open" vs "file"...
@@ -622,8 +624,10 @@ class SFTPClient(BaseSFTP, ClosingContextManager):
self._cwd = None
return
if not stat.S_ISDIR(self.stat(path).st_mode):
+ code = errno.ENOTDIR
raise SFTPError(
- errno.ENOTDIR, "{}: {}".format(os.strerror(errno.ENOTDIR), path))
+ code, "{}: {}".format(os.strerror(code), path)
+ )
self._cwd = b(self.normalize(path))
def getcwd(self):