for b in chunkyreader(f, os.fstat(f.fileno()).st_size - 20):
sum.update(b)
if sum.digest() != wantsum:
- raise ValueError('expected %r, got %r' % (wantsum.encode('hex'),
+ raise ValueError('Expected %r, got %r' % (wantsum.encode('hex'),
sum.hexdigest()))
-
+
def git_verify(base):
if opt.quick:
break
else:
rv = 1
- raise Exception('no such command %r' % cmd)
+ raise Exception('No such command "%r"' % cmd)
except Exception, e:
rv = 1
log('Error: %s!' % e)
if not hasattr(fuse, '__version__'):
- raise RuntimeError, "your fuse module is too old for fuse.__version__"
+ raise RuntimeError, 'Your python "fuse" module is too old for fuse.__version__'
fuse.fuse_python_api = (0, 2)
continue
match = re.match(value_rx, parameter)
if not match:
- raise fatal("couldn't parse %s as %s mapping" % (parameter, type))
+ raise fatal("Cannot parse %s as %s mapping" % (parameter, type))
old_id, new_id = match.groups()
if type in ('uid', 'gid'):
old_id = int(old_id)
ns = conn.read(4)
if not ns:
w.abort()
- raise Exception('object read: expected length header, got EOF')
+ raise Exception('Object read: expected length header, got EOF')
n = struct.unpack('!I', ns)[0]
#debug2('expecting %d bytes' % n)
if not n:
if cmd:
cmd(conn, rest)
else:
- raise Exception('unknown server command: %r' % line)
+ raise Exception('Unknown server command: "%r"' % line)
debug1('bup server: Done.')
'%s(?:%s%s)?%s' % (protocol, host, port, path), remote, re.I)
if url_match:
if not url_match.group(1) in ('ssh', 'bup', 'file'):
- raise ClientError, 'unexpected protocol: %s' % url_match.group(1)
+ raise ClientError, 'Unexpected protocol: %s' % url_match.group(1)
return url_match.group(1,3,4,5)
else:
rs = remote.split(':', 1)
self.pin = self.p.stdin
self.conn = Conn(self.pout, self.pin)
except OSError, e:
- raise ClientError, 'connect: %s' % e, sys.exc_info()[2]
+ raise ClientError, 'Connect: %s' % e, sys.exc_info()[2]
elif self.protocol == 'bup':
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((self.host, atoi(self.port) or 1982))
self.p.wait()
rv = self.p.wait()
if rv:
- raise ClientError('server tunnel returned exit code %d' % rv)
+ raise ClientError('Server tunnel returned exit code %d' % rv)
self.conn = None
self.sock = self.p = self.pin = self.pout = None
if self.p:
rv = self.p.poll()
if rv != None:
- raise ClientError('server exited unexpectedly with code %r'
+ raise ClientError('Server exited unexpectedly with code %r'
% rv)
try:
return self.conn.check_ok()
def check_busy(self):
if self._busy:
- raise ClientError('already busy with command %r' % self._busy)
-
+ raise ClientError('Already busy with command %r' % self._busy)
+
def ensure_busy(self):
if not self._busy:
- raise ClientError('expected to be busy, but not busy?!')
-
+ raise ClientError('Expected to be busy, but not busy')
+
def _not_busy(self):
self._busy = None
return id
def abort(self):
- raise ClientError("don't know how to abort remote pack writing")
+ raise ClientError("Don't know how to abort remote pack writing")
def _raw_write(self, datalist, sha):
assert(self.file)
if version == 2:
return PackIdxV2(filename, f)
else:
- raise GitError('%s: expected idx file version 2, got %d'
+ raise GitError('%s: Expected idx file version 2, got %d'
% (filename, version))
elif len(header) == 8 and header[0:4] < '\377tOc':
return PackIdxV1(filename, f)
else:
- raise GitError('%s: unrecognized idx file header' % filename)
+ raise GitError('%s: Unrecognized idx file header' % filename)
elif filename.endswith('.midx'):
return midx.PackMidx(filename)
else:
d = repo() # appends a / to the path
parent = os.path.dirname(os.path.dirname(d))
if parent and not os.path.exists(parent):
- raise GitError('parent directory "%s" does not exist' % parent)
+ raise GitError('Parent directory "%s" does not exist' % parent)
if os.path.exists(d) and not os.path.isdir(os.path.join(d, '.')):
raise GitError('"%s" exists but is not a directory' % d)
p = subprocess.Popen(['git', '--bare', 'init'], stdout=sys.stderr,
_ver = tuple(m.group(1).split('.'))
needed = ('1','5', '3', '1')
if _ver < needed:
- raise GitError('git version %s or higher is required; you have %s'
+ raise GitError('Git version %s or higher is required; you have %s'
% ('.'.join(needed), '.'.join(_ver)))
return _ver
raise KeyError('blob %r is missing' % id)
spl = hdr.split(' ')
if len(spl) != 3 or len(spl[0]) != 40:
- raise GitError('expected blob, got %r' % spl)
+ raise GitError('Expected blob, got %r' % spl)
(hex, type, size) = spl
it = _AbortableIter(chunkyreader(self.p.stdout, int(spl[2])),
for blob in self.join(treeline[5:]):
yield blob
else:
- raise GitError('invalid object type %r: expected blob/tree/commit'
+ raise GitError('Invalid object type %r: Expected blob/tree/commit'
% type)
def join(self, id):
p = subprocess.Popen(argv, stdout=subprocess.PIPE, preexec_fn=preexec_fn)
out, err = p.communicate()
if p.returncode != 0:
- raise Exception('subprocess %r failed with status %d'
+ raise Exception('Subprocess %r failed with status %d'
% (' '.join(argv), p.returncode))
return out
return NotOk(rl[6:])
else:
onempty(rl)
- raise Exception('server exited unexpectedly; see errors above')
+ raise Exception('Server exited unexpectedly; see errors above')
def drain_and_check_ok(self):
"""Remove all data for the current command from input stream."""
def check_ok(self):
"""Verify that server action completed successfully."""
def onempty(rl):
- raise Exception('expected "ok", got %r' % rl)
+ raise Exception('Expected "ok", got %r' % rl)
return self._check_ok(onempty)
while tail != 'BUPMUX':
b = os.read(infd, (len(tail) < 6) and (6-len(tail)) or 1)
if not b:
- raise IOError('demux: unexpected EOF during initialization')
+ raise IOError('Demux: Unexpected EOF during initialization')
tail += b
sys.stderr.write(tail[:-6]) # pre-mux log messages
tail = tail[-6:]
match = re.match(r'^((?:[-+]?[0-9]+)?)(s|ms|us|ns)$', epoch_str)
if not match:
if re.match(r'^([-+]?[0-9]+)$', epoch_str):
- raise ValueError('must include units, i.e. 100ns, 100ms, ...')
+ raise ValueError('Must include units, i.e. 100ns, 100ms, ...')
raise ValueError()
(n, units) = match.group(1, 2)
if not n:
"""
g = re.match(r'([-+\d.e]+)\s*(\w*)', str(s))
if not g:
- raise ValueError("can't parse %r as a number" % s)
+ raise ValueError("Cannot parse %r as a number" % s)
(val, unit) = g.groups()
num = float(val)
unit = unit.lower()
elif unit in ['', 'b']:
mult = 1
else:
- raise ValueError("invalid unit %r in number %r" % (unit, s))
+ raise ValueError("Invalid unit %r in number %r" % (unit, s))
return int(num*mult)
try:
date = atof(str)
except ValueError, e:
- raise fatal('invalid date format (should be a float): %r' % e)
+ raise fatal('Invalid date format (should be a float): %r' % e)
else:
return date
try:
f = open(realpath(parameter))
except IOError, e:
- raise fatal("couldn't read %s" % parameter)
+ raise fatal("Cannot read %s!" % parameter)
for exclude_path in f.readlines():
# FIXME: perhaps this should be rstrip('\n')
exclude_path = realpath(exclude_path.strip())
try:
f = open(realpath(parameter))
except IOError, e:
- raise fatal("couldn't read %s" % parameter)
+ raise fatal("Cannot read %s!" % parameter)
for pattern in f.readlines():
spattern = pattern.rstrip('\n')
if not spattern:
Example:
'/home/foo' -> [('', '/'), ('home', '/home'), ('foo', '/home/foo')]"""
if not path.startswith('/'):
- raise Exception, 'path must start with "/": %s' % path
+ raise Exception, 'Path must start with "/": %s' % path
# Since we assume path startswith('/'), we can skip the first element.
result = [('', '/')]
norm_path = os.path.abspath(path)
""" Commit all of the relevant data to disk. Do as much work
as possible without actually making the changes visible."""
if self._save_prepared:
- raise Error('save of %r already in progress' % self._filename)
+ raise Error('Save of %r already in progress' % self._filename)
if self._node_paths:
(dir, name) = os.path.split(self._filename)
(ffd, self._tmpname) = tempfile.mkstemp('.tmp', name, dir)
def commit_save(self):
if not self._save_prepared:
- raise Error('cannot commit save of %r; no save prepared'
+ raise Error('Cannot commit save of %r; no save prepared'
% self._filename)
if self._tmpname:
os.rename(self._tmpname, self._filename)
def _add(self, ename, entry):
if self.lastfile and self.lastfile <= ename:
- raise Error('%r must come before %r'
+ raise Error('%r must come before %r'
% (''.join(ename), ''.join(self.lastfile)))
self.lastfile = ename
self.level = _golevel(self.level, self.f, ename, entry,
def _create_via_common_rec(self, path, create_symlinks=True):
if not self.mode:
- raise ApplyError('no metadata - cannot create path ' + path)
+ raise ApplyError('No metadata - cannot create path ' + path)
# If the path already exists and is a dir, try rmdir.
# If the path already exists and is anything else, try unlink.
def _apply_common_rec(self, path, restore_numeric_ids=False):
if not self.mode:
- raise ApplyError('no metadata - cannot apply to ' + path)
+ raise ApplyError('No metadata - cannot apply to ' + path)
# FIXME: S_ISDOOR, S_IFMPB, S_IFCMP, S_IFNWK, ... see stat(2).
# EACCES errors at this stage are fatal for the current path.
try:
readpipe(['bash', '-c', 'exit 42'])
except Exception, ex:
- WVPASSEQ(str(ex), "subprocess 'bash -c exit 42' failed with status 42")
+ WVPASSEQ(str(ex), "Subprocess 'bash -c exit 42' failed with status 42")
@wvtest
try:
batchpipe(['bash', '-c'], ['exit 42'])
except Exception, ex:
- WVPASSEQ(str(ex), "subprocess 'bash -c exit 42' failed with status 42")
+ WVPASSEQ(str(ex), "Subprocess 'bash -c exit 42' failed with status 42")
args = [str(x) for x in range(6)]
# Force batchpipe to break the args into batches of 3. This
# approach assumes all args are the same length.
return self._lresolve(rest)
elif first == '..':
if not self.parent:
- raise NoSuchFile("no parent dir for %r" % self.name)
+ raise NoSuchFile("No parent dir for %r" % self.name)
return self.parent._lresolve(rest)
elif rest:
return self.sub(first)._lresolve(rest)
"""
global _symrefs
if _symrefs > 100:
- raise TooManySymlinks('too many levels of symlinks: %r'
+ raise TooManySymlinks('Too many levels of symlinks: %r'
% self.fullname())
_symrefs += 1
try:
return self.parent.lresolve(self.readlink(),
stay_inside_fs=True)
except NoSuchFile:
- raise NoSuchFile("%s: broken symlink to %r"
+ raise NoSuchFile("%s: Broken symlink to %r"
% (self.fullname(), self.readlink()))
finally:
_symrefs -= 1
def write_vuint(port, x):
if x < 0:
- raise Exception("vuints must not be negative")
+ raise Exception("vuint's must not be negative")
elif x == 0:
port.write('\0')
else:
def read_vuint(port):
c = port.read(1)
if c == '':
- raise EOFError('encountered EOF while reading vuint');
+ raise EOFError('Encountered EOF while reading vuint');
result = 0
offset = 0
while c:
def read_vint(port):
c = port.read(1)
if c == '':
- raise EOFError('encountered EOF while reading vint');
+ raise EOFError('Encountered EOF while reading vint');
negative = False
result = 0
offset = 0
def pack(types, *args):
if len(types) != len(args):
- raise Exception('number of arguments does not match format string')
+ raise Exception('Number of arguments does not match format string')
port = StringIO()
for (type, value) in zip(types, args):
if type == 'V':
elif type == 's':
write_bvec(port, value)
else:
- raise Exception('unknown xpack format string item "' + type + '"')
+ raise Exception('Unknown xpack format string item "' + type + '"')
return port.getvalue()
elif type == 's':
result.append(read_bvec(port))
else:
- raise Exception('unknown xunpack format string item "' + type + '"')
+ raise Exception('Unknown xunpack format string item "' + type + '"')
return result