diff options
author | Scott Maxwell <scott@codecobblers.com> | 2013-10-31 16:05:30 -0700 |
---|---|---|
committer | Scott Maxwell <scott@codecobblers.com> | 2013-10-31 16:18:31 -0700 |
commit | 951e8cfd3a4d892cdaed82ce6b62803dcc001209 (patch) | |
tree | afc8f19045c20aad3a41d7ac58a7e7b3029c415a /demos/demo_simple.py | |
parent | bc683ac3653e2d66fe18c020374ec5b7c723ed53 (diff) |
Fix demos
Diffstat (limited to 'demos/demo_simple.py')
-rwxr-xr-x | demos/demo_simple.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/demos/demo_simple.py b/demos/demo_simple.py index 50f344a7..fb71145d 100755 --- a/demos/demo_simple.py +++ b/demos/demo_simple.py @@ -25,9 +25,13 @@ import os import socket import sys import traceback +from paramiko.py3compat import input import paramiko -import interactive +try: + import interactive +except ImportError: + from . import interactive # setup logging @@ -40,9 +44,9 @@ if len(sys.argv) > 1: if hostname.find('@') >= 0: username, hostname = hostname.split('@') else: - hostname = raw_input('Hostname: ') + hostname = input('Hostname: ') if len(hostname) == 0: - print '*** Hostname required.' + print('*** Hostname required.') sys.exit(1) port = 22 if hostname.find(':') >= 0: @@ -53,7 +57,7 @@ if hostname.find(':') >= 0: # get username if username == '': default_username = getpass.getuser() - username = raw_input('Username [%s]: ' % default_username) + username = input('Username [%s]: ' % default_username) if len(username) == 0: username = default_username password = getpass.getpass('Password for %s@%s: ' % (username, hostname)) @@ -64,18 +68,18 @@ try: client = paramiko.SSHClient() client.load_system_host_keys() client.set_missing_host_key_policy(paramiko.WarningPolicy()) - print '*** Connecting...' + print('*** Connecting...') client.connect(hostname, port, username, password) chan = client.invoke_shell() - print repr(client.get_transport()) - print '*** Here we go!' - print + print(repr(client.get_transport())) + print('*** Here we go!\n') interactive.interactive_shell(chan) chan.close() client.close() -except Exception, e: - print '*** Caught exception: %s: %s' % (e.__class__, e) +except Exception: + e = sys.exc_info()[1] + print('*** Caught exception: %s: %s' % (e.__class__, e)) traceback.print_exc() try: client.close() |