diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2017-05-31 18:03:12 -0700 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2017-05-31 18:03:12 -0700 |
commit | 25de2a02048897752df356189017b22a49d37f88 (patch) | |
tree | 60ee505fa6a9c8b11852b1b9a8dd06bcdc89936e | |
parent | f95f0eb1fb82da7ead513dac352ec92712d68e24 (diff) |
More death to line continuations
-rw-r--r-- | demos/forward.py | 2 | ||||
-rwxr-xr-x | demos/rforward.py | 2 | ||||
-rw-r--r-- | paramiko/agent.py | 10 | ||||
-rw-r--r-- | paramiko/auth_handler.py | 6 | ||||
-rw-r--r-- | paramiko/channel.py | 5 | ||||
-rw-r--r-- | paramiko/common.py | 5 | ||||
-rw-r--r-- | paramiko/config.py | 10 | ||||
-rw-r--r-- | paramiko/dsskey.py | 7 | ||||
-rw-r--r-- | paramiko/file.py | 32 | ||||
-rw-r--r-- | paramiko/hostkeys.py | 10 | ||||
-rw-r--r-- | paramiko/kex_gss.py | 4 |
11 files changed, 59 insertions, 34 deletions
diff --git a/demos/forward.py b/demos/forward.py index 96e1700d..c478e217 100644 --- a/demos/forward.py +++ b/demos/forward.py @@ -105,7 +105,7 @@ def verbose(s): print(s) -HELP = """\ +HELP = """ Set up a forward tunnel across an SSH server, using paramiko. A local port (given with -p) is forwarded across an SSH session to an address:port from the SSH server. This is similar to the openssh -L option. diff --git a/demos/rforward.py b/demos/rforward.py index ae70670c..d015cebb 100755 --- a/demos/rforward.py +++ b/demos/rforward.py @@ -85,7 +85,7 @@ def verbose(s): print(s) -HELP = """\ +HELP = """ Set up a reverse forwarding tunnel across an SSH server, using paramiko. A port on the SSH server (given with -p) is forwarded across an SSH session back to the local machine, and out to a remote site reachable from this diff --git a/paramiko/agent.py b/paramiko/agent.py index c950ba5e..a7cab4d8 100644 --- a/paramiko/agent.py +++ b/paramiko/agent.py @@ -115,9 +115,13 @@ class AgentProxyThread(threading.Thread): # The address should be an IP address as a string? or None self.__addr = addr self._agent.connect() - if not isinstance(self._agent, int) and \ - (self._agent._conn is None or - not hasattr(self._agent._conn, 'fileno')): + if ( + not isinstance(self._agent, int) and + ( + self._agent._conn is None or + not hasattr(self._agent._conn, 'fileno') + ) + ): raise AuthenticationException("Unable to connect to SSH agent") self._communicate() except: diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py index 83c5a575..2de71241 100644 --- a/paramiko/auth_handler.py +++ b/paramiko/auth_handler.py @@ -313,8 +313,10 @@ class AuthHandler (object): else: raise SSHException( "Received Package: %s" % MSG_NAMES[ptype]) - elif self.auth_method == 'gssapi-keyex' and\ - self.transport.gss_kex_used: + elif ( + self.auth_method == 'gssapi-keyex' and + self.transport.gss_kex_used + ): kexgss = self.transport.kexgss_ctxt kexgss.set_username(self.username) mic_token = kexgss.ssh_get_mic(self.transport.session_id) diff --git a/paramiko/channel.py b/paramiko/channel.py index 1bd7969d..f2ecc4c0 100644 --- a/paramiko/channel.py +++ b/paramiko/channel.py @@ -920,8 +920,9 @@ class Channel (ClosingContextManager): def _set_remote_channel(self, chanid, window_size, max_packet_size): self.remote_chanid = chanid self.out_window_size = window_size - self.out_max_packet_size = self.transport. \ - _sanitize_packet_size(max_packet_size) + self.out_max_packet_size = self.transport._sanitize_packet_size( + max_packet_size + ) self.active = 1 self._log(DEBUG, 'Max packet out: %d bytes' % self.out_max_packet_size) diff --git a/paramiko/common.py b/paramiko/common.py index a77e39b9..556f046a 100644 --- a/paramiko/common.py +++ b/paramiko/common.py @@ -20,8 +20,9 @@ Common constants and global variables. """ import logging -from paramiko.py3compat import byte_chr, PY2, bytes_types, string_types, b,\ - long +from paramiko.py3compat import ( + byte_chr, PY2, bytes_types, string_types, b, long, +) MSG_DISCONNECT, MSG_IGNORE, MSG_UNIMPLEMENTED, MSG_DEBUG, \ MSG_SERVICE_REQUEST, MSG_SERVICE_ACCEPT = range(1, 7) diff --git a/paramiko/config.py b/paramiko/config.py index 196e32ba..073abb36 100644 --- a/paramiko/config.py +++ b/paramiko/config.py @@ -224,8 +224,9 @@ class SSHConfig (object): if isinstance(config[k], list): for item in range(len(config[k])): if find in config[k][item]: - config[k][item] = config[k][item].\ - replace(find, str(replace)) + config[k][item] = config[k][item].replace( + find, str(replace) + ) else: if find in config[k]: config[k] = config[k].replace(find, str(replace)) @@ -267,8 +268,9 @@ class LazyFqdn(object): address_family = self.config.get('addressfamily', 'any').lower() if address_family != 'any': try: - family = socket.AF_INET if address_family == 'inet' \ - else socket.AF_INET6 + family = socket.AF_INET6 + if address_family == 'inet': + socket.AF_INET results = socket.getaddrinfo( self.host, None, diff --git a/paramiko/dsskey.py b/paramiko/dsskey.py index c8452f23..ac6875bc 100644 --- a/paramiko/dsskey.py +++ b/paramiko/dsskey.py @@ -240,8 +240,11 @@ class DSSKey(PKey): keylist = BER(data).decode() except BERException as e: raise SSHException('Unable to parse key file: ' + str(e)) - if (type(keylist) is not list) or (len(keylist) < 6) or \ - (keylist[0] != 0): + if ( + type(keylist) is not list or + len(keylist) < 6 or + keylist[0] != 0 + ): raise SSHException( 'not a valid DSA private key file (bad ber encoding)') self.p = keylist[1] diff --git a/paramiko/file.py b/paramiko/file.py index 92bf1f14..e31ad9dd 100644 --- a/paramiko/file.py +++ b/paramiko/file.py @@ -251,9 +251,11 @@ class BufferedFile (ClosingContextManager): line = self._rbuffer truncated = False while True: - if self._at_trailing_cr and \ - (self._flags & self.FLAG_UNIVERSAL_NEWLINE) and \ - (len(line) > 0): + if ( + self._at_trailing_cr and + self._flags & self.FLAG_UNIVERSAL_NEWLINE and + len(line) > 0 + ): # edge case: the newline may be '\r\n' and we may have read # only the first '\r' last time. if line[0] == linefeed_byte_value: @@ -274,9 +276,13 @@ class BufferedFile (ClosingContextManager): n = size - len(line) else: n = self._bufsize - if (linefeed_byte in line) or \ - ((self._flags & self.FLAG_UNIVERSAL_NEWLINE) and - (cr_byte in line)): + if ( + linefeed_byte in line or + ( + self._flags & self.FLAG_UNIVERSAL_NEWLINE and + cr_byte in line + ) + ): break try: new_data = self._read(n) @@ -299,9 +305,11 @@ class BufferedFile (ClosingContextManager): self._pos += len(line) return line if self._flags & self.FLAG_BINARY else u(line) xpos = pos + 1 - if (line[pos] == cr_byte_value) and \ - (xpos < len(line)) and \ - (line[xpos] == linefeed_byte_value): + if ( + line[pos] == cr_byte_value and + xpos < len(line) and + line[xpos] == linefeed_byte_value + ): xpos += 1 # if the string was truncated, _rbuffer needs to have the string after # the newline character plus the truncated part of the line we stored @@ -524,8 +532,10 @@ class BufferedFile (ClosingContextManager): return if self.newlines is None: self.newlines = newline - elif self.newlines != newline and \ - isinstance(self.newlines, bytes_types): + elif ( + self.newlines != newline and + isinstance(self.newlines, bytes_types) + ): self.newlines = (self.newlines, newline) elif newline not in self.newlines: self.newlines += (newline,) diff --git a/paramiko/hostkeys.py b/paramiko/hostkeys.py index 001471ac..f5c622ed 100644 --- a/paramiko/hostkeys.py +++ b/paramiko/hostkeys.py @@ -187,10 +187,12 @@ class HostKeys (MutableMapping): entries = [] for e in self._entries: for h in e.hostnames: - if h.startswith('|1|') and not hostname.startswith('|1|') and \ - constant_time_bytes_eq( - self.hash_host(hostname, h), h) \ - or h == hostname: + if ( + h == hostname or + h.startswith('|1|') and + not hostname.startswith('|1|') and + constant_time_bytes_eq(self.hash_host(hostname, h), h) + ): entries.append(e) if len(entries) == 0: return None diff --git a/paramiko/kex_gss.py b/paramiko/kex_gss.py index ccca8e9e..40ceb5cd 100644 --- a/paramiko/kex_gss.py +++ b/paramiko/kex_gss.py @@ -137,8 +137,8 @@ class KexGSSGroup1(object): while 1: x_bytes = os.urandom(128) x_bytes = byte_mask(x_bytes[0], 0x7f) + x_bytes[1:] - if (x_bytes[:8] != self.b7fffffffffffffff) and \ - (x_bytes[:8] != self.b0000000000000000): + first = x_bytes[:8] + if first not in (self.b7fffffffffffffff, self.b0000000000000000): break self.x = util.inflate_long(x_bytes) |