summaryrefslogtreecommitdiff
path: root/examples/ssh_tunnel.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ssh_tunnel.py')
-rwxr-xr-xexamples/ssh_tunnel.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/examples/ssh_tunnel.py b/examples/ssh_tunnel.py
index 5587f40..03a2e85 100755
--- a/examples/ssh_tunnel.py
+++ b/examples/ssh_tunnel.py
@@ -32,6 +32,10 @@ PEXPECT LICENSE
'''
+from __future__ import print_function
+
+from __future__ import absolute_import
+
import pexpect
import getpass
import time
@@ -59,8 +63,8 @@ def start_tunnel ():
time.sleep (60) # Cygwin is slow to update process status.
ssh_tunnel.expect (pexpect.EOF)
- except Exception, e:
- print str(e)
+ except Exception as e:
+ print(str(e))
def main ():
@@ -69,15 +73,15 @@ def main ():
time.sleep (1)
index = ps.expect (['/usr/bin/ssh', pexpect.EOF, pexpect.TIMEOUT])
if index == 2:
- print 'TIMEOUT in ps command...'
- print str(ps)
+ print('TIMEOUT in ps command...')
+ print(str(ps))
time.sleep (13)
if index == 1:
- print time.asctime(),
- print 'restarting tunnel'
+ print(time.asctime(), end=' ')
+ print('restarting tunnel')
start_tunnel ()
time.sleep (11)
- print 'tunnel OK'
+ print('tunnel OK')
else:
# print 'tunnel OK'
time.sleep (7)