~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/gio_transport.py

(vila) Fix bzrlib.tests.test_gpg.TestVerify.test_verify_revoked_signature
 with recent versions of gpg. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
It provides the gio+XXX:// protocols where XXX is any of the protocols
24
24
supported by gio.
25
25
"""
 
26
 
 
27
from __future__ import absolute_import
 
28
 
26
29
from cStringIO import StringIO
27
 
import getpass
28
30
import os
29
31
import random
30
 
import socket
31
32
import stat
32
 
import urllib
33
33
import time
34
 
import sys
35
 
import getpass
36
34
import urlparse
37
35
 
38
36
from bzrlib import (
49
47
    deprecated_passed,
50
48
    warn,
51
49
    )
52
 
from bzrlib.trace import mutter, warning
 
50
from bzrlib.trace import mutter
53
51
from bzrlib.transport import (
54
52
    FileStream,
55
53
    ConnectedTransport,
56
54
    _file_streams,
57
 
    Server,
58
55
    )
59
56
 
60
57
from bzrlib.tests.test_server import TestServer
171
168
        #really use bzrlib.auth get_password for this
172
169
        #or possibly better gnome-keyring?
173
170
        auth = config.AuthenticationConfig()
174
 
        (scheme, urluser, urlpassword, host, port, urlpath) = \
175
 
           urlutils.parse_url(self.url)
 
171
        parsed_url = urlutils.URL.from_string(self.url)
176
172
        user = None
177
173
        if (flags & gio.ASK_PASSWORD_NEED_USERNAME and
178
174
                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)
 
175
            prompt = (u'%s' % (parsed_url.scheme.upper(),) +
 
176
                      u' %(host)s DOMAIN\\username')
 
177
            user_and_domain = auth.get_user(parsed_url.scheme,
 
178
                parsed_url.host, port=parsed_url.port, ask=True,
 
179
                prompt=prompt)
182
180
            (domain, user) = user_and_domain.split('\\', 1)
183
181
            op.set_username(user)
184
182
            op.set_domain(domain)
185
183
        elif flags & gio.ASK_PASSWORD_NEED_USERNAME:
186
 
            user = auth.get_user(scheme, host,
187
 
                    port=port, ask=True)
 
184
            user = auth.get_user(parsed_url.scheme, parsed_url.host,
 
185
                    port=parsed_url.port, ask=True)
188
186
            op.set_username(user)
189
187
        elif flags & gio.ASK_PASSWORD_NEED_DOMAIN:
190
188
            #Don't know how common this case is, but anyway
191
189
            #a DOMAIN and a username prompt should be the
192
190
            #same so I will missuse the ui_factory get_username
193
191
            #a little bit here.
194
 
            prompt = scheme.upper() + ' %(host)s DOMAIN'
 
192
            prompt = (u'%s' % (parsed_url.scheme.upper(),) +
 
193
                      u' %(host)s DOMAIN')
195
194
            domain = ui.ui_factory.get_username(prompt=prompt)
196
195
            op.set_domain(domain)
197
196
 
198
197
        if flags & gio.ASK_PASSWORD_NEED_PASSWORD:
199
198
            if user is None:
200
199
                user = op.get_username()
201
 
            password = auth.get_password(scheme, host,
202
 
                    user, port=port)
 
200
            password = auth.get_password(parsed_url.scheme, parsed_url.host,
 
201
                    user, port=parsed_url.port)
203
202
            op.set_password(password)
204
203
        op.reply(gio.MOUNT_OPERATION_HANDLED)
205
204
 
213
212
 
214
213
    def _create_connection(self, credentials=None):
215
214
        if credentials is None:
216
 
            user, password = self._user, self._password
 
215
            user, password = self._parsed_url.user, self._parsed_url.password
217
216
        else:
218
217
            user, password = credentials
219
218
 
254
253
        self._set_connection(connection, credentials)
255
254
 
256
255
    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
 
256
        return self._parsed_url.clone(relpath).path
260
257
 
261
258
    def has(self, relpath):
262
259
        """Does the target location exist?"""
274
271
            else:
275
272
                self._translate_gio_error(e, relpath)
276
273
 
277
 
    def get(self, relpath, decode=DEPRECATED_PARAMETER, retries=0):
 
274
    def get(self, relpath, retries=0):
278
275
        """Get the file at the given relative path.
279
276
 
280
277
        :param relpath: The relative path to the file
284
281
        We're meant to return a file-like object which bzr will
285
282
        then read from. For now we do this via the magic of StringIO
286
283
        """
287
 
        if deprecated_passed(decode):
288
 
            warn(deprecated_in((2,3,0)) %
289
 
                 '"decode" parameter to GioTransport.get()',
290
 
                 DeprecationWarning, stacklevel=2)
291
284
        try:
292
285
            if 'gio' in debug.debug_flags:
293
286
                mutter("GIO get: %s" % relpath)