summaryrefslogtreecommitdiffhomepage
path: root/demos/forward.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2014-09-06 16:07:24 -0700
committerJeff Forcier <jeff@bitprophet.org>2014-09-06 16:07:24 -0700
commit08239ff4b29c0b53c5443f21ae482e51340223f6 (patch)
tree73f0b7e4d25a80c965186d03abde9c006b1feec0 /demos/forward.py
parent5335d9dc0a6266217d288e7aaf2091739980d841 (diff)
parent6a6ac4d78421667b810f5e3a017fb669853133f9 (diff)
Merge branch 'master' into 234-int
Diffstat (limited to 'demos/forward.py')
-rw-r--r--demos/forward.py16
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)