Example #1
0
 def repr_failure(self, excinfo):
     ex = excinfo.value
     if isinstance(ex, BupSubprocFailure):
         msg = ['Exit status: %d' % ex.status,
                'Failures:']
         msg.extend(fsdecode(s) for s in ex.failures)
         return '\n'.join(msg)
Example #2
0
def do_ls(repo, args, out):
    try:
        opt = ls.opts_from_cmdline([fsdecode(arg) for arg in args],
                                   onabort=OptionError)
    except OptionError as e:
        log('error: %s' % e)
        return
    return ls.within_repo(repo, opt, out)
Example #3
0
 def readlink(self, path):
     path = argv_bytes(path)
     if self.verbose > 0:
         log('--readlink(%r)\n' % path)
     res = vfs.resolve(self.repo, path, follow=False)
     name, item = res[-1]
     if not item:
         return -errno.ENOENT
     return fsdecode(vfs.readlink(self.repo, item))
Example #4
0
 def readdir(self, path, offset):
     path = argv_bytes(path)
     assert not offset  # We don't return offsets, so offset should be unused
     res = vfs.resolve(self.repo, path, follow=False)
     dir_name, dir_item = res[-1]
     if not dir_item:
         yield -errno.ENOENT
     yield fuse.Direntry('..')
     # FIXME: make sure want_meta=False is being completely respected
     for ent_name, ent_item in vfs.contents(repo, dir_item, want_meta=False):
         fusename = fsdecode(ent_name.replace(b'/', b'-'))
         yield fuse.Direntry(fusename)
Example #5
0
File: main.py Project: jmberg/bup
def usage(msg=""):
    log('Usage: bup [-?|--help] [-d BUP_DIR] [--debug] [--profile] '
        '<command> [options...]\n\n')
    common = dict(
        ftp = 'Browse backup sets using an ftp-like client',
        fsck = 'Check backup sets for damage and add redundancy information',
        fuse = 'Mount your backup sets as a filesystem',
        help = 'Print detailed help for the given command',
        index = 'Create or display the index of files to back up',
        on = 'Backup a remote machine to the local one',
        restore = 'Extract files from a backup set',
        save = 'Save files into a backup set (note: run "bup index" first)',
        tag = 'Tag commits for easier access',
        web = 'Launch a web server to examine backup sets',
    )

    log('Common commands:\n')
    for cmd,synopsis in sorted(common.items()):
        log('    %-10s %s\n' % (cmd, synopsis))
    log('\n')
    
    log('Other available commands:\n')
    cmds = set()
    for c in sorted(os.listdir(cmdpath)):
        if c.startswith(b'bup-') and c.find(b'.') < 0:
            cname = fsdecode(c[4:])
            if cname not in common:
                cmds.add(c[4:].decode(errors='backslashreplace'))
    # built-in commands take precedence
    for _, name, _ in iter_modules(path=bup.cmd.__path__):
        name = name.replace('_','-')
        if name not in common:
            cmds.add(name)

    log(columnate(sorted(cmds), '    '))
    log('\n')
    
    log("See 'bup help COMMAND' for more information on " +
        "a specific command.\n")
    if msg:
        log("\n%s\n" % msg)
    sys.exit(99)