[BUG] NameError: global name 'ssh' is not defined

Andrew Bennetts andrew at canonical.com
Wed Sep 13 13:49:56 BST 2006


Alexander Belchenko wrote:
> On my win32:
[...]
> 
> The problem occurs when I try to access to another branch via sftp:
[...]
>   File "E:\Bazaar\devel\bzr.dev\bzrlib\transport\ssh.py", line 104, in 
> _get_ssh_vendor
>     _ssh_vendor = ssh.ParamikoVendor()
> NameError: global name 'ssh' is not defined

Oops, this would appear to be my fault.  I guess this means that the fallback to
paramiko (when OpenSSH is not available) was broken by my recent refactoring of
this code.

I've attached a bundle that should fix this, and a couple of other pyflakes
nits in those files.  Clearly the tests are lacking though; we should probably
make it so the ParamikoVendor is always tested, regardless of whether OpenSSH is
available.  Or rather, test *every* available SSH implementation (and paramiko
is a hard dependency, so it's always available).

-Andrew.

-------------- next part --------------
# Bazaar revision bundle v0.8
#
# message:
#   Fix NameError reported by Alexander Belchenko.
#   
#   This also fixes some other nits so that pyflakes now gives completely 
#   clean output for sftp.py and ssh.py.
#   
# committer: Andrew Bennetts <andrew.bennetts at canonical.com>
# date: Wed 2006-09-13 22:44:46.076999903 +1000

=== modified file bzrlib/transport/sftp.py
--- bzrlib/transport/sftp.py
+++ bzrlib/transport/sftp.py
@@ -17,26 +17,23 @@
 
 """Implementation of Transport over SFTP, using paramiko."""
 
-import errno
 import os
 import random
 import select
 import socket
 import stat
-import subprocess
 import sys
 import time
 import urllib
 import urlparse
 import weakref
 
-from bzrlib.errors import (FileExists, 
+from bzrlib.errors import (FileExists,
                            NoSuchFile, PathNotChild,
                            TransportError,
-                           LockError, 
+                           LockError,
                            PathError,
                            ParamikoNotPresent,
-                           UnknownSSH,
                            )
 from bzrlib.osutils import pathjoin, fancy_rename, getcwd
 from bzrlib.trace import mutter, warning

=== modified file bzrlib/transport/ssh.py
--- bzrlib/transport/ssh.py
+++ bzrlib/transport/ssh.py
@@ -28,6 +28,7 @@
 from bzrlib.errors import (ConnectionError,
                            ParamikoNotPresent,
                            TransportError,
+                           UnknownSSH,
                            )
 
 from bzrlib.osutils import pathjoin
@@ -101,7 +102,7 @@
     # A check for putty's plink or lsh would go here.
 
     mutter('falling back to paramiko implementation')
-    _ssh_vendor = ssh.ParamikoVendor()
+    _ssh_vendor = ParamikoVendor()
     return _ssh_vendor
 
 

# revision id: andrew.bennetts at canonical.com-20060913124446-28405a99e41eae49
# sha1: 7487b6f1a115c49e5dd14811fde4c4d0875fc478
# inventory sha1: 0f51b7f056c7f3cfca28bd8300df9aaabed3e2ad
# parent ids:
#   pqm at pqm.ubuntu.com-20060909180200-96e41112dff213f3
# base id: pqm at pqm.ubuntu.com-20060909180200-96e41112dff213f3
# properties:
#   branch-nick: bzr-ssh-fixes



More information about the bazaar mailing list