Using SFTP pull on Win32
Robey Pointer
robey at lag.net
Fri Nov 11 18:24:26 GMT 2005
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.
robey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051111/cda069a6/attachment.pgp
More information about the bazaar
mailing list