/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/sftp.py

  • Committer: Wouter van Heyst
  • Date: 2006-06-06 12:06:20 UTC
  • mfrom: (1740 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: larstiq@larstiq.dyndns.org-20060606120620-50066b0951e4ef7c
merge bzr.dev 1740

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
from bzrlib.transport import (
45
45
    register_urlparse_netloc_protocol,
46
46
    Server,
 
47
    split_url,
47
48
    Transport,
48
49
    )
49
50
import bzrlib.ui
662
663
        return urlparse.urlunparse(('sftp', netloc, path, '', '', ''))
663
664
 
664
665
    def _split_url(self, url):
665
 
        if isinstance(url, unicode):
666
 
            # TODO: Disallow unicode urls
667
 
            #raise InvalidURL(url, 'urls must not be unicode.')
668
 
            url = url.encode('ascii')
669
 
        (scheme, netloc, path, params,
670
 
         query, fragment) = urlparse.urlparse(url, allow_fragments=False)
 
666
        (scheme, username, password, host, port, path) = split_url(url)
671
667
        assert scheme == 'sftp'
672
 
        username = password = host = port = None
673
 
        if '@' in netloc:
674
 
            username, host = netloc.split('@', 1)
675
 
            if ':' in username:
676
 
                username, password = username.split(':', 1)
677
 
                password = urllib.unquote(password)
678
 
            username = urllib.unquote(username)
679
 
        else:
680
 
            host = netloc
681
 
 
682
 
        if ':' in host:
683
 
            host, port = host.rsplit(':', 1)
684
 
            try:
685
 
                port = int(port)
686
 
            except ValueError:
687
 
                # TODO: Should this be ConnectionError?
688
 
                raise TransportError('%s: invalid port number' % port)
689
 
        host = urllib.unquote(host)
690
 
 
691
 
        path = urlutils.unescape(path)
692
668
 
693
669
        # the initial slash should be removed from the path, and treated
694
670
        # as a homedir relative path (the path begins with a double slash
1021
997
                return '1'
1022
998
            def get_hexdump(self):
1023
999
                return False
 
1000
            def close(self):
 
1001
                pass
1024
1002
 
1025
1003
        server = paramiko.SFTPServer(FakeChannel(), 'sftp', StubServer(self), StubSFTPServer,
1026
1004
                                     root=self._root, home=self._server_homedir)