Using SFTP pull on Win32

John Arbash Meinel john at arbash-meinel.com
Fri Nov 11 19:09:53 GMT 2005


Robey Pointer wrote:
> 
> On 11 Nov 2005, at 7:05, John A Meinel wrote:
> 
>> Alexey Shamrin wrote:
>>
>>> On 11/11/05, Matt Lavin <matt.lavin at gmail.com> wrote:
>>>
>>>> In the end, I changed a line in bzrlib/transport/sftp.py from
>>>>
>>>>         password = getpass.getpass('SSH %s@%s password: ' %
>>>> (self._username, self._host))
>>>>
>>>>  to
>>>>
>>>>       password = getpass.getpass('SSH %s@%s password: ' %
>>>> (str(self._username), str(self._host)))
>>>>
>>>
>>> I agree, without the fix "bzr pull" fails (see the end of the message
>>> for traceback).
>>>
>>> I think the better way to fix the bug is to encode the arguments  using
>>> sys.stdout.encoding, because getpass always write to stoud. Here is
>>> the patch:
>>>
>>
>> I agree that this is the way to fix the problem. With one minor fix. I
>> would use "self._username.encode(enc, errors='replace')".
>> Because this is just displaying the username, and it is possible that
>> those characters are illegal in the current encoding.
>> Otherwise you get a UnicodeEncodeError if there is an illegal  character.
> 
> 
> This is one of the things I don't like about the SFTP transport: it 
> shouldn't be trying to directly interact with the user.  Especially  not
> by just calling getpass on whatever the current terminal is.   Imagine a
> GUI using bzrlib.
> 
> It seems like other transports might need to ask for a password 
> sometimes (HTTP auth maybe?).  It would be cool if a transport could 
> raise some kind of exception when it needs a password, and maybe get 
> re-created with a password after the user interface has asked for  one. 
> I'm not sure if that's particularly easy to implement though. :)
> 
> Anyway I mostly just wanted to whine that I'm unsatisfied with the  way
> the SFTP transport is directly asking the user for a password.   It
> shouldn't be implementing UI.

Actually, we have a place to put UI stuff. "bzrlib.ui" Right now the
only thing it has in there is a progress indicator, but we certainly
could abstract some more stuff to getting a password, etc.

I think that is a decent way to do it. Then the "SilentUI" would just
fail, the TextUI would call getpass(), and the future GuiUI could have
it create a dialog box.

John
=:->

> 
> robey
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051111/40b8def1/attachment.pgp 


More information about the bazaar mailing list