[paramiko] paramiko API changes in 1.6

Robey Pointer robey at lag.net
Mon Mar 12 11:06:58 PDT 2007


Since I got another bug report off-list about this, I decided this is  
probably worth highlighting:

In 1.6, a lot of the Channel methods changed from returning a True/ 
False success indicator to returning nothing, and raising an  
SSHException on failure.  The reason is that I chose poorly the first  
time around, and returning a True/False success value isn't great  
design.  The channel operations should succeed most of the time, and  
when they don't, that's exceptional -- so it should raise an  
exception! :)

If you had code (using paramiko 1.4 or 1.5.x) like this:

     if not chan.exec_command(...):
         raise Exception(...)

You can just change it to:

     chan.exec_command(...)

and an SSHException will be raised if the call fails.  The same is  
true for the other methods on Channel.

robey




More information about the paramiko mailing list