/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/ftp.py

  • Committer: Vincent Ladeuil
  • Date: 2007-10-17 15:36:20 UTC
  • mto: (2961.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 2962.
  • Revision ID: v.ladeuil+lp@free.fr-20071017153620-7q8uml5d78jli2fl
ake ftp aware of authentication config.

 bzrlib/transport/ftp.py:
FtpTransport._create_connection): Try the authentication config
efore prompting the user.

 bzrlib/tests/test_ftp_transport.py:
TestFTPServerUI.test_prompt_for_password): New test.

 bzrlib/tests/test_config.py:
TestConfigPath.test_authentication_config_filename): Add test,
ot tested on windows, but should work.

 bzrlib/tests/HTTPTestUtil.py:
AuthServer.authorized): Fix typo.

 bzrlib/config.py:
AuthenticationConfig.__init__): Track the filename getter, we
eed it for _save().
AuthenticationConfig._save): Needed for tests.
AuthenticationConfig._set_option): Basic setter, needed for
ests.
AuthenticationConfig.get_credentials): Rework 'port' acquisition.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
from warnings import warn
41
41
 
42
42
from bzrlib import (
 
43
    config,
43
44
    errors,
44
45
    osutils,
45
46
    urlutils,
131
132
            connection.connect(host=self._host, port=self._port)
132
133
            if self._user and self._user != 'anonymous' and \
133
134
                    password is None: # '' is a valid password
134
 
                get_password = bzrlib.ui.ui_factory.get_password
135
 
                password = get_password(prompt='FTP %(user)s@%(host)s password',
136
 
                                        user=self._user, host=self._host)
 
135
                auth = config.AuthenticationConfig()
 
136
                config_credentials = auth.get_credentials('ftp', self._host,
 
137
                                                          user=self._user)
 
138
                if config_credentials is not None:
 
139
                    password = config_credentials['password']
 
140
                else:
 
141
                    get_password = bzrlib.ui.ui_factory.get_password
 
142
                    password = get_password(
 
143
                        prompt='FTP %(user)s@%(host)s password',
 
144
                        user=self._user, host=self._host)
137
145
            connection.login(user=self._user, passwd=password)
138
146
            connection.set_pasv(not self.is_active)
139
147
        except ftplib.error_perm, e: