Python based paramiko package acting up on Linux, code works fine on windows
I've tried to post to the mailing list for paramiko and contact the author, but it seems he's having some mailing list problems. Anyways, I have this small example that works just fine on Windows against Python 2.6.2, but fails on Ubuntu against 2.6.2. Here is the code: import subprocess import os import re import paramiko import sqlite3 import datetime import base64 import sys import logging from paramiko.rsakey import RSAKey class OpenSessions: sshconns = [] sqlconn = sqlite3.connect('test.sqlite') def __init__(self): self.sqlconn.row_factory = sqlite3.Row sqlcur = self.sqlconn.cursor() sqlcur.execute(select host, pub_key, username, password, private_key from ssh_hosts) rows = sqlcur.fetchall() for row in rows: sshconn = paramiko.SSHClient() sshconn._system_host_keys.add(row[host], ssh-rsa, RSAKey (data=base64.decodestring(row[pub_key]))) if row[private_key] != : sshconn.connect(hostname=row[host], username=row[username], pkey=RSAKey(data=base64.decodestring(row[private_key]))) elif row[password] != : sshconn.connect(hostname=row[host], username=row[username], password=row[password], look_for_keys=False, timeout=60) self.sshconns.append(sshconn) output = for conn in self.sshconns: print conn.exec_command(uname -a)[1].readline() exit() if __name__== '__main__': sessions = OpenSessions() The code fails with this trace: Traceback (most recent call last): File test.py, line 41, in module sessions = OpenSessions() File test.py, line 36, in __init__ print chan.exec_command(uname -a)[1].readline() File /usr/local/lib/python2.6/dist-packages/paramiko/channel.py, line 212, in exec_command self._wait_for_event() File /usr/local/lib/python2.6/dist-packages/paramiko/channel.py, line 1077, in _wait_for_event raise e paramiko.SSHException: Channel closed. Exception in thread Thread-1 (most likely raised during interpreter shutdown): Traceback (most recent call last): File /usr/lib/python2.6/threading.py, line 525, in __bootstrap_inner File /usr/local/lib/python2.6/dist-packages/paramiko/transport.py, line 1567, in run type 'exceptions.AttributeError': 'NoneType' object has no attribute 'error' This well beyond my abilities to debug. All I know is that it always works on Windows, and always fails in Ubuntu (which of course is where I need use the code). Any suggestions? I know the paramiko mailing list would probably be the better spot for this, but like I said, its got some issues right now. OLIVER -- http://mail.python.org/mailman/listinfo/python-list
Re: Python based paramiko package acting up on Linux, code works fine on windows
On Sep 18, 11:22 am, flxkid theflx...@gmail.com wrote: I've tried to post to the mailing list for paramiko and contact the author, but it seems he's having some mailing list problems. Anyways, I have this small example that works just fine on Windows against Python 2.6.2, but fails on Ubuntu against 2.6.2. Here is the code: import subprocess import os import re import paramiko import sqlite3 import datetime import base64 import sys import logging from paramiko.rsakey import RSAKey class OpenSessions: sshconns = [] sqlconn = sqlite3.connect('test.sqlite') def __init__(self): self.sqlconn.row_factory = sqlite3.Row sqlcur = self.sqlconn.cursor() sqlcur.execute(select host, pub_key, username, password, private_key from ssh_hosts) rows = sqlcur.fetchall() for row in rows: sshconn = paramiko.SSHClient() sshconn._system_host_keys.add(row[host], ssh-rsa, RSAKey (data=base64.decodestring(row[pub_key]))) if row[private_key] != : sshconn.connect(hostname=row[host], username=row[username], pkey=RSAKey(data=base64.decodestring(row[private_key]))) elif row[password] != : sshconn.connect(hostname=row[host], username=row[username], password=row[password], look_for_keys=False, timeout=60) self.sshconns.append(sshconn) output = for conn in self.sshconns: print conn.exec_command(uname -a)[1].readline() exit() if __name__== '__main__': sessions = OpenSessions() The code fails with this trace: Traceback (most recent call last): File test.py, line 41, in module sessions = OpenSessions() File test.py, line 36, in __init__ print chan.exec_command(uname -a)[1].readline() File /usr/local/lib/python2.6/dist-packages/paramiko/channel.py, line 212, in exec_command self._wait_for_event() File /usr/local/lib/python2.6/dist-packages/paramiko/channel.py, line 1077, in _wait_for_event raise e paramiko.SSHException: Channel closed. Exception in thread Thread-1 (most likely raised during interpreter shutdown): Traceback (most recent call last): File /usr/lib/python2.6/threading.py, line 525, in __bootstrap_inner File /usr/local/lib/python2.6/dist-packages/paramiko/transport.py, line 1567, in run type 'exceptions.AttributeError': 'NoneType' object has no attribute 'error' This well beyond my abilities to debug. All I know is that it always works on Windows, and always fails in Ubuntu (which of course is where I need use the code). Any suggestions? I know the paramiko mailing list would probably be the better spot for this, but like I said, its got some issues right now. OLIVER Was a bug in paramiko channel.py in the _wait_for_event function. All fixed up now. OLIVER -- http://mail.python.org/mailman/listinfo/python-list