diff options
author | Robey Pointer <robey@lag.net> | 2004-04-06 08:16:02 +0000 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2004-04-06 08:16:02 +0000 |
commit | 945a41dd3d2cf7f3d37012c588d8eb07bcc296b2 (patch) | |
tree | 112de2889851b2515994cbaab42bf3f868d0939e /tests | |
parent | ed72847ad1e392af6bb8920176c30548c68ddb23 (diff) |
[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-42]
support py22, more or less
add roger binns' patches for supporting python 2.2. i hedged a bit on the
logging stuff and just added some trickery to let logging be stubbed out for
python 2.2. this changed a lot of import statements but i managed to avoid
hacking at any of the existing logging.
socket timeouts are required for the threads to notice when they've been
deactivated. worked around it by using the 'select' module on py22.
also fixed the sftp unit tests to cope with a password-protected private key.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_sftp.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/tests/test_sftp.py b/tests/test_sftp.py index 798853f6..5085d7a1 100755 --- a/tests/test_sftp.py +++ b/tests/test_sftp.py @@ -31,9 +31,10 @@ import sys, os HOST = os.environ.get('TEST_HOST', 'localhost') USER = os.environ.get('TEST_USER', os.environ.get('USER', 'nobody')) PKEY = os.environ.get('TEST_PKEY', os.path.join(os.environ.get('HOME', '/'), '.ssh/id_rsa')) +PKEY_PASSWD = os.environ.get('TEST_PKEY_PASSWD', None) FOLDER = os.environ.get('TEST_FOLDER', 'temp-testing') -import paramiko, logging, unittest +import paramiko, unittest ARTICLE = ''' Insulin sensitivity and liver insulin receptor structure in ducks from two @@ -64,16 +65,21 @@ decreased compared with chicken. # setup logging -l = logging.getLogger('paramiko') -l.setLevel(logging.DEBUG) -if len(l.handlers) == 0: - f = open('test.log', 'w') - lh = logging.StreamHandler(f) - lh.setFormatter(logging.Formatter('%(levelname)-.3s [%(asctime)s] %(name)s: %(message)s', '%Y%m%d:%H%M%S')) - l.addHandler(lh) +paramiko.util.log_to_file('test.log') + t = paramiko.Transport(HOST) -key = paramiko.RSAKey() -key.read_private_key_file(PKEY) +try: + key = paramiko.RSAKey.from_private_key_file(PKEY, PKEY_PASSWD) +except paramiko.PasswordRequiredException: + sys.stderr.write('\n\nparamiko.RSAKey.from_private_key_file REQUIRES PASSWORD.\n') + sys.stderr.write('You have two options:\n') + sys.stderr.write('* Change environment variable TEST_PKEY to point to a different\n') + sys.stderr.write(' (non-password-protected) private key file.\n') + sys.stderr.write('* Set environment variable TEST_PKEY_PASSWD to the password needed\n') + sys.stderr.write(' to unlock this private key.\n') + sys.stderr.write('\n') + sys.exit(1) + try: t.connect(username=USER, pkey=key) except paramiko.SSHException: |