Fix compatibility with Python 2.6. Fixes #3.

This commit is contained in:
Andris Raugulis 2016-08-30 15:09:59 +03:00
parent e8bd764cdb
commit ef8d727356
1 changed files with 6 additions and 6 deletions

View File

@ -31,7 +31,7 @@ SSH_BANNER = 'SSH-2.0-OpenSSH_7.3'
def usage(): def usage():
p = os.path.basename(sys.argv[0]) p = os.path.basename(sys.argv[0])
out.head('# {0} v1.0.20160812, moo@arthepsy.eu'.format(p)) out.head('# {0} v1.0.20160812, moo@arthepsy.eu'.format(p))
out.info('\nusage: {} [-nv] host[:port]\n'.format(p)) out.info('\nusage: {0} [-nv] host[:port]\n'.format(p))
out.info(' -v verbose') out.info(' -v verbose')
out.info(' -n disable colors' + os.linesep) out.info(' -n disable colors' + os.linesep)
sys.exit(1) sys.exit(1)
@ -169,7 +169,7 @@ class SSH(object):
self.__sock = socket.create_connection((host, port), cto) self.__sock = socket.create_connection((host, port), cto)
self.__sock.settimeout(rto) self.__sock.settimeout(rto)
except Exception as e: except Exception as e:
out.fail('[fail] {}'.format(e)) out.fail('[fail] {0}'.format(e))
sys.exit(1) sys.exit(1)
def __enter__(self): def __enter__(self):
@ -526,14 +526,14 @@ def output_compatibility(kex, client=False):
comp_text = [] comp_text = []
for sshd_name, v in ssh_timeframe.items(): for sshd_name, v in ssh_timeframe.items():
if v[cp] is None: if v[cp] is None:
comp_text.append('{} {}+'.format(sshd_name, v[0])) comp_text.append('{0} {1}+'.format(sshd_name, v[0]))
elif v[0] == v[1]: elif v[0] == v[1]:
comp_text.append('{} {}'.format(sshd_name, v[0])) comp_text.append('{0} {1}'.format(sshd_name, v[0]))
else: else:
if v[1] < v[0]: if v[1] < v[0]:
comp_text.append('{} {}+ (some functionality from {})'.format(sshd_name, v[0], v[1])) comp_text.append('{0} {1}+ (some functionality from {2})'.format(sshd_name, v[0], v[1]))
else: else:
comp_text.append('{} {}-{}'.format(sshd_name, v[0], v[1])) comp_text.append('{0} {1}-{2}'.format(sshd_name, v[0], v[1]))
if len(comp_text) > 0: if len(comp_text) > 0:
out.good('[info] compatibility: ' + ', '.join(comp_text)) out.good('[info] compatibility: ' + ', '.join(comp_text))