diff options
author | Sebastian Deiss <s.deiss@science-computing.de> | 2014-02-11 13:01:49 +0100 |
---|---|---|
committer | Sebastian Deiss <s.deiss@science-computing.de> | 2014-02-11 13:01:49 +0100 |
commit | e7f41de2f2dac5d03404f35edc5514f12e42c49f (patch) | |
tree | eae66247e741b2acdcc5ec10712af231992296a0 /demos/forward.py | |
parent | a08ac06083a40eb1455e5fa14cd644f7a2350f16 (diff) |
Merge branch scottkmaxwell:py3-support-without-py25 into
SebastianDeiss:gssapi-py3-support
Diffstat (limited to 'demos/forward.py')
-rw-r--r-- | demos/forward.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/demos/forward.py b/demos/forward.py index 5048c775..96e1700d 100644 --- a/demos/forward.py +++ b/demos/forward.py @@ -30,7 +30,11 @@ import getpass import os import socket import select -import SocketServer +try: + import SocketServer +except ImportError: + import socketserver as SocketServer + import sys from optparse import OptionParser @@ -54,7 +58,7 @@ class Handler (SocketServer.BaseRequestHandler): chan = self.ssh_transport.open_channel('direct-tcpip', (self.chain_host, self.chain_port), self.request.getpeername()) - except Exception, e: + except Exception as e: verbose('Incoming request to %s:%d failed: %s' % (self.chain_host, self.chain_port, repr(e))) @@ -98,7 +102,7 @@ def forward_tunnel(local_port, remote_host, remote_port, transport): def verbose(s): if g_verbose: - print s + print(s) HELP = """\ @@ -165,8 +169,8 @@ def main(): try: client.connect(server[0], server[1], username=options.user, key_filename=options.keyfile, look_for_keys=options.look_for_keys, password=password) - except Exception, e: - print '*** Failed to connect to %s:%d: %r' % (server[0], server[1], e) + except Exception as e: + print('*** Failed to connect to %s:%d: %r' % (server[0], server[1], e)) sys.exit(1) verbose('Now forwarding port %d to %s:%d ...' % (options.port, remote[0], remote[1])) @@ -174,7 +178,7 @@ def main(): try: forward_tunnel(options.port, remote[0], remote[1], client.get_transport()) except KeyboardInterrupt: - print 'C-c: Port forwarding stopped.' + print('C-c: Port forwarding stopped.') sys.exit(0) |