2 MODE_CHECK = "MODE_CHECK" # query all peers
3 MODE_ANYTHING = "MODE_ANYTHING" # one recoverable version
4 MODE_WRITE = "MODE_WRITE" # replace all shares, probably.. not for initial
6 MODE_READ = "MODE_READ"
7 MODE_REPAIR = "MODE_REPAIR" # query all peers, get the privkey
9 class NotWriteableError(Exception):
12 class BadShareError(Exception):
13 """This represents an error discovered in a particular share, during
14 retrieve, from which we can recover by using some other share. This does
15 *not* include local coding errors.
18 class NeedMoreDataError(BadShareError):
19 def __init__(self, needed_bytes, encprivkey_offset, encprivkey_length):
20 Exception.__init__(self)
21 self.needed_bytes = needed_bytes # up through EOF
22 self.encprivkey_offset = encprivkey_offset
23 self.encprivkey_length = encprivkey_length
25 return "<NeedMoreDataError (%d bytes)>" % self.needed_bytes
27 class UncoordinatedWriteError(Exception):
29 return ("<%s -- You, oh user, tried to change a file or directory "
30 "at the same time as another process was trying to change it. "
31 " To avoid data loss, don't do this. Please see "
32 "docs/write_coordination.rst for details.>" %
33 (self.__class__.__name__,))
35 class UnrecoverableFileError(Exception):
38 class NotEnoughServersError(Exception):
39 """There were not enough functioning servers available to place shares
40 upon. This might result from all servers being full or having an error, a
41 local bug which causes all server requests to fail in the same way, or
42 from there being zero servers. The first error received (if any) is
43 stored in my .first_error attribute."""
44 def __init__(self, why, first_error=None):
45 Exception.__init__(self, why, first_error)
46 self.first_error = first_error
48 class CorruptShareError(BadShareError):
49 def __init__(self, server, shnum, reason):
50 self.args = (server, shnum, reason)
55 return "<CorruptShareError server=%s shnum[%d]: %s" % \
56 (self.server.get_name(), self.shnum, self.reason)
58 class UnknownVersionError(BadShareError):
59 """The share we received was of a version we don't recognize."""