~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/gio_transport.py

Merge bzr.dev, update to use new hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
supported by gio.
25
25
"""
26
26
from cStringIO import StringIO
27
 
import getpass
28
27
import os
29
28
import random
30
 
import socket
31
29
import stat
32
 
import urllib
33
30
import time
34
 
import sys
35
 
import getpass
36
31
import urlparse
37
32
 
38
33
from bzrlib import (
49
44
    deprecated_passed,
50
45
    warn,
51
46
    )
52
 
from bzrlib.trace import mutter, warning
 
47
from bzrlib.trace import mutter
53
48
from bzrlib.transport import (
54
49
    FileStream,
55
50
    ConnectedTransport,
56
51
    _file_streams,
57
 
    Server,
58
52
    )
59
53
 
60
54
from bzrlib.tests.test_server import TestServer
171
165
        #really use bzrlib.auth get_password for this
172
166
        #or possibly better gnome-keyring?
173
167
        auth = config.AuthenticationConfig()
174
 
        (scheme, urluser, urlpassword, host, port, urlpath) = \
175
 
           urlutils.parse_url(self.url)
 
168
        parsed_url = urlutils.URL.from_string(self.url)
176
169
        user = None
177
170
        if (flags & gio.ASK_PASSWORD_NEED_USERNAME and
178
171
                flags & gio.ASK_PASSWORD_NEED_DOMAIN):
179
 
            prompt = scheme.upper() + ' %(host)s DOMAIN\username'
180
 
            user_and_domain = auth.get_user(scheme, host,
181
 
                    port=port, ask=True, prompt=prompt)
 
172
            prompt = (u'%s' % (parsed_url.scheme.upper(),) +
 
173
                      u' %(host)s DOMAIN\\username')
 
174
            user_and_domain = auth.get_user(parsed_url.scheme,
 
175
                parsed_url.host, port=parsed_url.port, ask=True,
 
176
                prompt=prompt)
182
177
            (domain, user) = user_and_domain.split('\\', 1)
183
178
            op.set_username(user)
184
179
            op.set_domain(domain)
185
180
        elif flags & gio.ASK_PASSWORD_NEED_USERNAME:
186
 
            user = auth.get_user(scheme, host,
187
 
                    port=port, ask=True)
 
181
            user = auth.get_user(parsed_url.scheme, parsed_url.host,
 
182
                    port=parsed_url.port, ask=True)
188
183
            op.set_username(user)
189
184
        elif flags & gio.ASK_PASSWORD_NEED_DOMAIN:
190
185
            #Don't know how common this case is, but anyway
191
186
            #a DOMAIN and a username prompt should be the
192
187
            #same so I will missuse the ui_factory get_username
193
188
            #a little bit here.
194
 
            prompt = scheme.upper() + ' %(host)s DOMAIN'
 
189
            prompt = (u'%s' % (parsed_url.scheme.upper(),) +
 
190
                      u' %(host)s DOMAIN')
195
191
            domain = ui.ui_factory.get_username(prompt=prompt)
196
192
            op.set_domain(domain)
197
193
 
198
194
        if flags & gio.ASK_PASSWORD_NEED_PASSWORD:
199
195
            if user is None:
200
196
                user = op.get_username()
201
 
            password = auth.get_password(scheme, host,
202
 
                    user, port=port)
 
197
            password = auth.get_password(parsed_url.scheme, parsed_url.host,
 
198
                    user, port=parsed_url.port)
203
199
            op.set_password(password)
204
200
        op.reply(gio.MOUNT_OPERATION_HANDLED)
205
201
 
213
209
 
214
210
    def _create_connection(self, credentials=None):
215
211
        if credentials is None:
216
 
            user, password = self._user, self._password
 
212
            user, password = self._parsed_url.user, self._parsed_url.password
217
213
        else:
218
214
            user, password = credentials
219
215
 
254
250
        self._set_connection(connection, credentials)
255
251
 
256
252
    def _remote_path(self, relpath):
257
 
        relative = urlutils.unescape(relpath).encode('utf-8')
258
 
        remote_path = self._combine_paths(self._path, relative)
259
 
        return remote_path
 
253
        return self._parsed_url.clone(relpath).path
260
254
 
261
255
    def has(self, relpath):
262
256
        """Does the target location exist?"""