]> arthur.barton.de Git - bup.git/commitdiff
Streamline output: Exception messages
authorAlexander Barton <alex@barton.de>
Wed, 31 Dec 2014 17:34:39 +0000 (18:34 +0100)
committerAlexander Barton <alex@barton.de>
Wed, 31 Dec 2014 17:49:50 +0000 (18:49 +0100)
All messages should start with a capital letter and DON'T contain any
punctuation!

Signed-off-by: Alexander Barton <alex@barton.de>
14 files changed:
cmd/fsck-cmd.py
cmd/ftp-cmd.py
cmd/fuse-cmd.py
cmd/restore-cmd.py
cmd/server-cmd.py
lib/bup/client.py
lib/bup/git.py
lib/bup/helpers.py
lib/bup/hlinkdb.py
lib/bup/index.py
lib/bup/metadata.py
lib/bup/t/thelpers.py
lib/bup/vfs.py
lib/bup/vint.py

index 28b37bcef237379e1655f308a33fa1b691b5378a..cf982aa3e49fd63f07f2fc3e1116a3ee22979866 100755 (executable)
@@ -63,9 +63,9 @@ def quick_verify(base):
     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:
index 620e24741f5e61d94d348454b5ac881723abb1ed..29b9dc0b723a8d683eda2e0edbfb4a5b5105556b 100755 (executable)
@@ -202,7 +202,7 @@ for line in lines:
             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)
index a19b69a40aefdaddb745f1a81009048c6a433d99..8e103b5ecf4604ca8c0e6795742960c3bf37c1bd 100755 (executable)
@@ -111,7 +111,7 @@ class BupFs(fuse.Fuse):
 
 
 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)
 
 
index a9806999932a8f8759a3332d558be5faf03cfe7b..3b888157e6590f4c0c9f5d70889e2ac1ec8f48b9 100755 (executable)
@@ -81,7 +81,7 @@ def parse_owner_mappings(type, options, fatal):
             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)
index 1e0e79c65ef09fa7f8efe3f5ca2eb4ab21fc961c..a7f00ba8cd0857bcc4c04f08e2e685c56135f894 100755 (executable)
@@ -79,7 +79,7 @@ def receive_objects_v2(conn, junk):
         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:
@@ -205,6 +205,6 @@ for _line in lr:
         if cmd:
             cmd(conn, rest)
         else:
-            raise Exception('unknown server command: %r' % line)
+            raise Exception('Unknown server command: "%r"' % line)
 
 debug1('bup server: Done.')
index 4174912d5ef1e2f87427ea86a6b00f80a9ed7ba6..3feea453933da34dd5c862055340a92347340c80 100644 (file)
@@ -41,7 +41,7 @@ def parse_remote(remote):
             '%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)
@@ -76,7 +76,7 @@ class Client:
                     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))
@@ -118,7 +118,7 @@ class Client:
             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
 
@@ -126,7 +126,7 @@ class Client:
         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()
@@ -135,12 +135,12 @@ class Client:
 
     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
 
@@ -314,7 +314,7 @@ class PackWriter_Remote(git.PackWriter):
         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)
index c35803dc6551fcf990472ad8f2fc06f65dcfce7e..cde7aa2c105ca28889500a83b83b0dcf6ad68fa2 100644 (file)
@@ -528,12 +528,12 @@ def open_idx(filename):
             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:
@@ -913,7 +913,7 @@ def init_repo(path=None):
     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,
@@ -970,7 +970,7 @@ def ver():
         _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
 
@@ -1073,7 +1073,7 @@ class CatPipe:
             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])),
@@ -1119,7 +1119,7 @@ class CatPipe:
             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):
index a5ad83101953d0b086d43b0bb3db7663ebccb685..f517a1c0d3f46fedfea38e849f041aa27606a244 100644 (file)
@@ -207,7 +207,7 @@ def readpipe(argv, preexec_fn=None):
     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
 
@@ -453,7 +453,7 @@ class BaseConn:
                 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."""
@@ -464,7 +464,7 @@ class BaseConn:
     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)
 
 
@@ -527,7 +527,7 @@ class DemuxConn(BaseConn):
         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:]
@@ -734,7 +734,7 @@ throw a ValueError that may contain additional information."""
     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:
@@ -753,7 +753,7 @@ def parse_num(s):
     """
     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()
@@ -768,7 +768,7 @@ def parse_num(s):
     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)
 
 
@@ -850,7 +850,7 @@ def parse_date_or_fatal(str, fatal):
     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
 
@@ -867,7 +867,7 @@ def parse_excludes(options, fatal):
             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())
@@ -892,7 +892,7 @@ def parse_rx_excludes(options, fatal):
             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:
@@ -928,7 +928,7 @@ def path_components(path):
     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)
index 3a53b4059952af61828198ed5e783cf1da818ad8..29bacc00a810a7c1974b2b1569cfba76d8ef0902 100644 (file)
@@ -35,7 +35,7 @@ class HLinkDB:
         """ 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)
@@ -58,7 +58,7 @@ class HLinkDB:
 
     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)
index a7967bdf5df1c0f156dc050f3f8e1980e016fe9e..ccc8d42b0c8f20262cb696b56a73e7d4f88be114 100644 (file)
@@ -490,7 +490,7 @@ class Writer:
 
     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,
index 44ced3a7b7aa96d992a71c4623d7e475aaf48ac8..1749dd90dc7ae01124b1f8016bc7d49339ff3ee0 100644 (file)
@@ -296,7 +296,7 @@ class Metadata:
 
     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.
@@ -362,7 +362,7 @@ class Metadata:
 
     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.
index 68004b72f03e69633fa765d776144a90c3e90b42..9f1d70a950991488d788e51f6587af4ad5578be9 100644 (file)
@@ -120,7 +120,7 @@ def test_readpipe():
     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
@@ -134,7 +134,7 @@ def test_batchpipe():
     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.
index 3bedae7de09ad1b6daabd4ee91c455760100cee5..5ba0804e6c0041b491b75c21c3161db5e1daf28a 100644 (file)
@@ -238,7 +238,7 @@ class Node(object):
             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)
@@ -369,7 +369,7 @@ class Symlink(File):
         """
         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:
@@ -377,7 +377,7 @@ class Symlink(File):
                 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
index bca93bd0b5eb9f18c4db0a270e6154ef525481b1..57be65b45462bb3b1bc02faa3acdd8cb416a7103 100644 (file)
@@ -11,7 +11,7 @@ from cStringIO import StringIO
 
 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:
@@ -27,7 +27,7 @@ def write_vuint(port, x):
 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:
@@ -64,7 +64,7 @@ def write_vint(port, x):
 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
@@ -112,7 +112,7 @@ def skip_bvec(port):
 
 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':
@@ -122,7 +122,7 @@ def pack(types, *args):
         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()
 
 
@@ -137,5 +137,5 @@ def unpack(types, data):
         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