~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2005-09-17 04:51:54 UTC
  • mto: (1393.2.1)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: john@arbash-meinel.com-20050917045153-bfa0bd371b0b877e
Most tests pass, some problems with unavailable socket recv

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
"""
6
6
 
7
7
from bzrlib.trace import mutter
8
 
from bzrlib.errors import BzrError
 
8
from bzrlib.errors import (BzrError, 
 
9
    TransportError, TransportNotPossible, NonRelativePath,
 
10
    NoSuchFile, FileExists, PermissionDenied,
 
11
    ConnectionReset)
9
12
 
10
13
_protocol_handlers = {
11
14
}
21
24
        mutter('registering transport: %s => %s' % (prefix, klass.__name__))
22
25
        _protocol_handlers[prefix] = klass
23
26
 
24
 
class TransportError(BzrError):
25
 
    """All errors thrown by Transport implementations should derive
26
 
    from this class.
27
 
    """
28
 
    def __init__(self, msg=None, orig_error=None):
29
 
        if msg is None and orig_error is not None:
30
 
            msg = str(orig_error)
31
 
        BzrError.__init__(self, msg)
32
 
        self.msg = msg
33
 
        self.orig_error = orig_error
34
 
 
35
 
class AsyncError(TransportError):
36
 
    pass
37
 
 
38
 
# A set of semi-meaningful errors which can be thrown
39
 
class TransportNotPossible(TransportError):
40
 
    """This is for transports where a specific function is explicitly not
41
 
    possible. Such as pushing files to an HTTP server.
42
 
    """
43
 
    pass
44
 
 
45
 
class NonRelativePath(TransportError):
46
 
    """An absolute path was supplied, that could not be decoded into
47
 
    a relative path.
48
 
    """
49
 
    pass
50
 
 
51
 
class NoSuchFile(TransportError, IOError):
52
 
    """A get() was issued for a file that doesn't exist."""
53
 
    def __init__(self, msg=None, orig_error=None):
54
 
        import errno
55
 
        TransportError.__init__(self, msg=msg, orig_error=orig_error)
56
 
        IOError.__init__(self, errno.ENOENT, self.msg)
57
 
 
58
 
class FileExists(TransportError, OSError):
59
 
    """An operation was attempted, which would overwrite an entry,
60
 
    but overwritting is not supported.
61
 
 
62
 
    mkdir() can throw this, but put() just overwites existing files.
63
 
    """
64
 
    def __init__(self, msg=None, orig_error=None):
65
 
        import errno
66
 
        TransportError.__init__(self, msg=msg, orig_error=orig_error)
67
 
        OSError.__init__(self, errno.EEXIST, self.msg)
68
 
 
69
 
class PermissionDenied(TransportError):
70
 
    """An operation cannot succeed because of a lack of permissions."""
71
 
    pass
72
 
 
73
 
class ConnectionReset(TransportError):
74
 
    """The connection has been closed."""
75
 
    pass
76
 
 
77
27
class Transport(object):
78
28
    """This class encapsulates methods for retrieving or putting a file
79
29
    from/to a storage location.