当前位置: 首页>>代码示例>>Python>>正文


Python Tardis.Util类代码示例

本文整理汇总了Python中Tardis.Util的典型用法代码示例。如果您正苦于以下问题:Python Util类的具体用法?Python Util怎么用?Python Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: moveKeys

def moveKeys(db, crypt):
    try:
        if args.keys is None:
            logger.error("Must specify key file for key manipulation")
            return 1
        clientId = db.getConfigValue('ClientID')
        salt, vkey = db.getSrpValues()
        #(db, _) = getDB(crypt)
        if args.extract:
            (f, c) = db.getKeys()
            if not (f and c):
                raise Exception("Unable to retrieve keys from server.  Aborting.")
            Util.saveKeys(args.keys, clientId, f, c)
            if args.deleteKeys:
                db.setKeys(salt, vkey, None, None)
        elif args.insert:
            (f, c) = Util.loadKeys(args.keys, clientId)
            logger.info("Keys: F: %s C: %s", f, c)
            if not (f and c):
                raise Exception("Unable to retrieve keys from key database.  Aborting.")
            db.setKeys(salt, vkey, f, c)
            if args.deleteKeys:
                Util.saveKeys(args.keys, clientId, None, None)
        return 0
    except TardisDB.AuthenticationException as e:
        logger.error("Authentication failed.  Bad password")
        return 1
    except Exception as e:
        logger.error(e)
        if args.exceptions:
            logger.exception(e)
        return 1
开发者ID:koldinger,项目名称:Tardis,代码行数:32,代码来源:Sonic.py

示例2: main

def main():
    global logger
    progressbar.streams.wrap_stderr()
    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger('')
    args = processArgs()
    password = Util.getPassword(args.password, args.passwordfile, args.passwordprog, allowNone=False)

    crypto = TardisCrypto.TardisCrypto(password, args.client)

    path = os.path.join(args.database, args.client, args.dbname)
    db = TardisDB.TardisDB(path, backup=False)

    Util.authenticate(db, args.client, password)
    (f, c) = db.getKeys()
    crypto.setKeys(f, c)

    cacheDir = CacheDir.CacheDir(os.path.join(args.database, args.client))

    if args.names or args.all:
        encryptFilenames(db, crypto)
    if args.dirs or args.all:
        generateDirHashes(db, crypto, cacheDir)
    if args.sigs or args.all:
        generateSignatures(db, crypto, cacheDir)
    if args.files or args.all:
        encryptFiles(db, crypto, cacheDir)
    if args.meta or args.all:
        generateMetadata(db, cacheDir)
开发者ID:koldinger,项目名称:Tardis,代码行数:29,代码来源:encryptDB.py

示例3: setPassword

def setPassword(crypt, password):
    try:
        (db, _, _) = getDB(None, None)
        crypt.genKeys()
        (f, c) = crypt.getKeys()
        (salt, vkey) = srp.create_salted_verification_key(args.client, password)
        if args.keys:
            db.beginTransaction()
            db.setSrpValues(salt, vkey)
            Util.saveKeys(args.keys, db.getConfigValue('ClientID'), f, c)
            db.commit()
        else:
            db.setKeys(salt, vkey, f, c)
        return 0
    except TardisDB.NotAuthenticated:
        logger.error('Client %s already has a password', args.client)
        if args.exceptions:
            logger.exception(e)
        return 1
    except TardisDB.AuthenticationFailed as e:
        logger.error("Authentication failed.  Bad password")
        if args.exceptions:
            logger.exception(e)
        return 1
    except Exception as e:
        logger.error(str(e))
        if args.exceptions:
            logger.exception(e)
        return 1
开发者ID:koldinger,项目名称:Tardis,代码行数:29,代码来源:Sonic.py

示例4: changePassword

def changePassword(crypt, crypt2):
    try:
        (db, _) = getDB(crypt)
        # Load the keys, and insert them into the crypt object, to decyrpt them
        if args.keys:
            (f, c) = Util.loadKeys(args.keys, db.getConfigValue("ClientID"))
        else:
            (f, c) = db.getKeys()
        crypt.setKeys(f, c)

        # Grab the keys from one crypt object.
        # Need to do this because getKeys/setKeys assumes they're encrypted, and we need the raw
        # versions
        crypt2._filenameKey = crypt._filenameKey
        crypt2._contentKey = crypt._contentKey
        # Now get the encrypted versions
        (f, c) = crypt2.getKeys()
        if args.keys:
            db.beginTransaction()
            db.setToken(crypt2.createToken())
            Util.saveKeys(args.keys, db.getConfigValue("ClientID"), f, c)
            db.commit()
        else:
            db.setKeys(crypt2.createToken(), f, c)
        db.close()
        return 0
    except Exception as e:
        logger.error(e)
        return 1
开发者ID:daleathan,项目名称:Tardis,代码行数:29,代码来源:Sonic.py

示例5: main

def main():
    global logger
    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger('')
    args = processArgs()
    password = Util.getPassword(args.password, args.passwordfile, args.passwordprog)

    (_, _, crypto) = Util.setupDataConnection(args.database, args.client, password, args.keys, args.dbname, args.dbdir)

    data = args.names
    if not data:
        tty = os.isatty(0)
        if not tty:
            data = list(map(str.strip, sys.stdin.readlines()))
        else:
            data = reader(args.quiet)

    for i in data:
        if i:
            if not args.quiet:
                print(i, " \t => \t", end=' ')
            try:
                if (args.encrypt):
                    print(crypto.encryptPath(i))
                else:
                    print(crypto.decryptPath(i))
            except Exception as e:
                print("Caught exception: " + str(e))
开发者ID:koldinger,项目名称:Tardis,代码行数:28,代码来源:decryptName.py

示例6: moveKeys

def moveKeys(db, crypt):
    try:
        if args.keys is None:
            logger.error("Must specify key file for key manipulation")
            return 1
        clientId = db.getConfigValue("ClientID")
        token = crypt.createToken()
        (db, _) = getDB(crypt)
        if args.extract:
            (f, c) = db.getKeys()
            if not (f and c):
                raise Exception("Unable to retrieve keys from server.  Aborting.")
            Util.saveKeys(args.keys, clientId, f, c)
            if args.deleteKeys:
                db.setKeys(token, None, None)
        elif args.insert:
            (f, c) = Util.loadKeys(args.keys, clientId)
            logger.info("Keys: F: %s C: %s", f, c)
            if not (f and c):
                raise Exception("Unable to retrieve keys from key database.  Aborting.")
            db.setKeys(token, f, c)
            if args.deleteKeys:
                Util.saveKeys(args.keys, clientId, None, None)
        return 0
    except Exception as e:
        logger.error(e)
        logger.exception(e)
        return 1
开发者ID:daleathan,项目名称:Tardis,代码行数:28,代码来源:Sonic.py

示例7: _bsetInfo

def _bsetInfo(db, info):
    print "Backupset       : %s (%d)" % ((info["name"]), info["backupset"])
    print "Completed       : %s" % ("True" if info["completed"] else "False")
    t = time.strftime("%d %b, %Y %I:%M:%S %p", time.localtime(float(info["starttime"])))
    print "StartTime       : %s" % (t)
    if info["endtime"] is not None:
        t = time.strftime("%d %b, %Y %I:%M:%S %p", time.localtime(float(info["endtime"])))
        duration = str(datetime.timedelta(seconds=(int(float(info["endtime"]) - float(info["starttime"])))))
        print "EndTime         : %s" % (t)
        print "Duration        : %s" % (duration)
    print "SW Versions     : C:%s S:%s" % (info["clientversion"], info["serverversion"])
    print "Client IP       : %s" % (info["clientip"])
    details = db.getBackupSetDetails(info["backupset"])
    (files, dirs, size, newInfo, endInfo) = details
    print "Files           : %d" % (files)
    print "Directories     : %d" % (dirs)
    print "Total Size      : %s" % (Util.fmtSize(size))

    print "New Files       : %d" % (newInfo[0])
    print "New File Size   : %s" % (Util.fmtSize(newInfo[1]))
    print "New File Space  : %s" % (Util.fmtSize(newInfo[2]))

    print "Purgeable Files : %d" % (endInfo[0])
    print "Purgeable Size  : %s" % (Util.fmtSize(endInfo[1]))
    print "Purgeable Space : %s" % (Util.fmtSize(endInfo[2]))
开发者ID:daleathan,项目名称:Tardis,代码行数:25,代码来源:Sonic.py

示例8: getDB

def getDB(crypt, password, new=False, allowRemote=True, allowUpgrade=False):
    loc = urllib.parse.urlparse(args.database)
    # This is basically the same code as in Util.setupDataConnection().  Should consider moving to it.
    if (loc.scheme == 'http') or (loc.scheme == 'https'):
        if not allowRemote:
            raise Exception("This command cannot be executed remotely.  You must execute it on the server directly.")
        # If no port specified, insert the port
        if loc.port is None:
            netloc = loc.netloc + ":" + Defaults.getDefault('TARDIS_REMOTE_PORT')
            dbLoc = urllib.parse.urlunparse((loc.scheme, netloc, loc.path, loc.params, loc.query, loc.fragment))
        else:
            dbLoc = args.database
        tardisdb = RemoteDB.RemoteDB(dbLoc, args.client)
        cache = tardisdb
    else:
        basedir = os.path.join(args.database, args.client)
        if not args.dbdir:
            dbdir = os.path.join(args.database, args.client)
        else:
            dbdir = os.path.join(args.dbdir, args.client)
        dbfile = os.path.join(dbdir, args.dbname)
        if new and os.path.exists(dbfile):
            raise Exception("Database for client %s already exists." % (args.client))

        cache = CacheDir.CacheDir(basedir, 2, 2, create=new)
        schema = args.schema if new else None
        tardisdb = TardisDB.TardisDB(dbfile, backup=False, initialize=schema, allow_upgrade=allowUpgrade)

    if tardisdb.needsAuthentication():
        if password is None:
            password = Util.getPassword(args.password, args.passwordfile, args.passwordprog, prompt="Password for %s: " % (args.client), allowNone=False, confirm=False)
            crypt = TardisCrypto.TardisCrypto(password, args.client)
        Util.authenticate(tardisdb, args.client, password)

    return (tardisdb, cache, crypt)
开发者ID:koldinger,项目名称:Tardis,代码行数:35,代码来源:Sonic.py

示例9: _bsetInfo

def _bsetInfo(db, info):
    print("Backupset       : %s (%d)" % ((info['name']), info['backupset']))
    print("Completed       : %s" % ('True' if info['completed'] else 'False'))
    t = time.strftime("%d %b, %Y %I:%M:%S %p", time.localtime(float(info['starttime'])))
    print("StartTime       : %s" % (t))
    if info['endtime'] is not None:
        t = time.strftime("%d %b, %Y %I:%M:%S %p", time.localtime(float(info['endtime'])))
        duration = str(datetime.timedelta(seconds = (int(float(info['endtime']) - float(info['starttime'])))))
        print("EndTime         : %s" % (t))
        print("Duration        : %s" % (duration))
    print("SW Versions     : C:%s S:%s" % (info['clientversion'], info['serverversion']))
    print("Client IP       : %s" % (info['clientip']))
    details = db.getBackupSetDetails(info['backupset'])
    (files, dirs, size, newInfo, endInfo) = details
    print("Files           : %d" % (files))
    print("Directories     : %d" % (dirs))
    print("Total Size      : %s" % (Util.fmtSize(size)))

    print("New Files       : %d" % (newInfo[0]))
    print("New File Size   : %s" % (Util.fmtSize(newInfo[1])))
    print("New File Space  : %s" % (Util.fmtSize(newInfo[2])))

    print("Purgeable Files : %d" % (endInfo[0]))
    print("Purgeable Size  : %s" % (Util.fmtSize(endInfo[1])))
    print("Purgeable Space : %s" % (Util.fmtSize(endInfo[2])))
开发者ID:koldinger,项目名称:Tardis,代码行数:25,代码来源:Sonic.py

示例10: main

def main():
    global logger
    args = processArgs()
    kwargs = processMountOpts(args.mountopts)
    logger = Util.setupLogging(args.verbose)

    try:
        argsDict = vars(args)
        def getarg(name):
            """ Extract a value from either the kwargs, or the regular args """
            return kwargs.get(name) or argsDict.get(name)

        # Extract the password file and program, if they exist.  Names differ, so getarg doesn't work.
        pwfile = kwargs.get('pwfile') or argsDict.get('passwordfile')
        pwprog = kwargs.get('pwprog') or argsDict.get('passwordprog')

        password = Util.getPassword(getarg('password'), pwfile, pwprog, prompt="Password for %s: " % (getarg('client')))
        args.password = None
        (tardis, cache, crypt) = Util.setupDataConnection(getarg('database'), getarg('client'), password, getarg('keys'), getarg('dbname'), getarg('dbdir'))
    except TardisDB.AuthenticationException as e:
        logger.error("Authentication failed.  Bad password")
        #if args.exceptions:
            #logger.exception(e)
        sys.exit(1)
    except Exception as e:
        logger.error("DB Connection failed: %s", e)
        sys.exit(1)

    delTardisKeys(kwargs)

    fs = TardisFS(tardis, cache, crypt, args)
    FUSE(fs, args.mountpoint[0], debug=args.debug, nothreads=True, foreground=args.foreground, **kwargs)
开发者ID:koldinger,项目名称:Tardis,代码行数:32,代码来源:TardisFS.py

示例11: listFiles

def listFiles(db, crypt):
    #print args
    info = getBackupSet(db, args.backup, args.date, defaultCurrent=True)
    #print info, info['backupset']
    lastDir = '/'
    lastDirInode = (-1, -1)
    bset = info['backupset']
    files = db.getNewFiles(info['backupset'], args.previous)
    for fInfo in files:
        name = _decryptFilename(fInfo['name'], crypt)
        
        if not args.dirs and fInfo['dir']:
            continue
        dirInode = (fInfo['parent'], fInfo['parentdev'])
        if dirInode == lastDirInode:
            path = lastDir
        else:
            path = _path(db, crypt, bset, dirInode)
            lastDirInode = dirInode
            lastDir = path
            if not args.fullname:
                print("%s:" % (path))
        if args.status:
            status = '[New]   ' if fInfo['chainlength'] == 0 else '[Delta] '
        else:
            status = ''
        if args.fullname:
            name = os.path.join(path, name)

        if args.long:
            mode  = Util.filemode(fInfo['mode'])
            group = Util.getGroupName(fInfo['gid'])
            owner = Util.getUserId(fInfo['uid'])
            mtime = Util.formatTime(fInfo['mtime'])
            if fInfo['size'] is not None:
                if args.human:
                    size = "%8s" % Util.fmtSize(fInfo['size'], formats=['','KB','MB','GB', 'TB', 'PB'])
                else:
                    size = "%8d" % int(fInfo['size'])
            else:
                size = ''           
            print('  %s%9s %-8s %-8s %8s %12s' % (status, mode, owner, group, size, mtime), end=' ')
            if args.cksums:
                print(' %32s ' % (fInfo['checksum'] or ''), end=' ')
            if args.chnlen:
                print(' %4s ' % (fInfo['chainlength']), end=' ')
            if args.inode:
                print(' %-16s ' % ("(%s, %s)" % (fInfo['device'], fInfo['inode'])), end=' ')

            print(name)
        else:
            print("    %s" % status, end=' ')
            if args.cksums:
                print(' %32s ' % (fInfo['checksum'] or ''), end=' ')
            if args.chnlen:
                print(' %4s ' % (fInfo['chainlength']), end=' ')
            if args.inode:
                print(' %-16s ' % ("(%s, %s)" % (fInfo['device'], fInfo['inode'])), end=' ')
            print(name)
开发者ID:koldinger,项目名称:Tardis,代码行数:59,代码来源:Sonic.py

示例12: main

def main():
    global logger
    try:
        parseArgs()
        logger = Util.setupLogging(args.verbose)

        if len(args.backup) > 2:
            logger.error(args.backup)
            logger.error("Too many backups (%d) specified.  Only one or two allowed", len(args.backup))
            sys.exit(1)

        password = Util.getPassword(
            args.password, args.passwordfile, args.passwordprog, prompt="Password for %s: " % (args.client)
        )
        args.password = None
        (tardis, cache, crypt) = Util.setupDataConnection(
            args.database, args.client, password, args.keys, args.dbname, args.dbdir
        )
        password = None

        bsets = []
        for i in args.backup:
            bset = getBackupSet(tardis, i)
            if bset:
                logger.debug("Got backupset %s", str(bset))
                logger.debug("backupset: %s", bset["backupset"])
                bsets.append(bset)
            else:
                sys.exit(1)

        if len(bsets) == 1:
            bsets.append(None)

        r = Regenerator.Regenerator(cache, tardis, crypt)
        then = time.asctime(time.localtime(float(bsets[0]["starttime"]))) + "  (" + bsets[0]["name"] + ")"
        if bsets[1]:
            now = time.asctime(time.localtime(float(bsets[1]["starttime"]))) + "  (" + bsets[1]["name"] + ")"
        else:
            now = time.asctime() + "  (filesystem)"

        for f in args.files:
            if bsets[1] is None and os.path.isdir(f):
                diffDir(os.path.abspath(f), r, bsets, tardis, crypt, args.reduce, now, then, recurse=args.recurse)
            else:
                (i0, _) = getFileInfo(os.path.abspath(f), bsets[0]["backupset"], tardis, crypt, args.reduce)
                if i0 and i0["dir"]:
                    (i1, _) = getFileInfo(os.path.abspath(f), bsets[1]["backupset"], tardis, crypt, args.reduce)
                    if i1 and i1["dir"]:
                        diffDir(
                            os.path.abspath(f), r, bsets, tardis, crypt, args.reduce, now, then, recurse=args.recurse
                        )
                        continue
                diffFile(f, r, bsets, tardis, crypt, args.reduce, args.recurse, now, then)
    except KeyboardInterrupt:
        pass
    except Exception as e:
        logger.error("Caught exception: %s", str(e))
        logger.exception(e)
开发者ID:koldinger,项目名称:Tardis,代码行数:58,代码来源:Diff.py

示例13: removeOrphans

def removeOrphans(db, cache):
    if hasattr(cache, "removeOrphans"):
        r = cache.removeOrphans()
        logger.debug("Remove Orphans: %s %s", type(r), r)
        count = r["count"]
        size = r["size"]
        rounds = r["rounds"]
    else:
        count, size, rounds = Util.removeOrphans(db, cache)
    print "Removed %d orphans, for %s, in %d rounds" % (count, Util.fmtSize(size), rounds)
开发者ID:daleathan,项目名称:Tardis,代码行数:10,代码来源:Sonic.py

示例14: processArgs

def processArgs():
    isatty = os.isatty(sys.stdout.fileno())

    parser = argparse.ArgumentParser(description='List Tardis File Versions', fromfile_prefix_chars='@', formatter_class=Util.HelpFormatter, add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)

    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument('--long', '-l',     dest='long',        default=False, action='store_true',         help='Use long listing format.')
    parser.add_argument('--hidden', '-a',   dest='hidden',      default=False, action='store_true',         help='Show hidden files.')
    parser.add_argument('--reverse', '-r',  dest='reverse',     default=False, action='store_true',         help='Reverse the sort order')
    parser.add_argument('--annotate', '-f', dest='annotate',    default=False, action='store_true',         help='Annotate files based on type.')
    parser.add_argument('--size', '-s',     dest='size',        default=False, action='store_true',         help='Show file sizes')
    parser.add_argument('--human', '-H',    dest='human',       default=False, action='store_true',         help='Format sizes for easy reading')
    parser.add_argument('--dirinfo', '-d',  dest='dirinfo',     default=False, action='store_true',         help='List directories, but not their contents')
    parser.add_argument('--checksums', '-c',dest='cksums',      default=False, action='store_true',         help='Print checksums.')
    parser.add_argument('--chainlen', '-L', dest='chnlen',      default=False, action='store_true',         help='Print chainlengths.')
    parser.add_argument('--inode', '-i',    dest='inode',       default=False, action='store_true',         help='Print inode numbers')
    parser.add_argument('--versions', '-V', dest='versions',    default='change', choices=['none', 'change', 'all', 'last'],   help='Display all, changed, last, or no versions of files.  Default: %(default)s')
    parser.add_argument('--deletions',      dest='deletions',   default=True,  action=Util.StoreBoolean,    help='Show deletions. Default: %(default)s')
    parser.add_argument('--broken',         dest='broken',      default=True,  action=Util.StoreBoolean,    help='Show broken files (missing data). Default: %(default)s')
    parser.add_argument('--oneline', '-O',  dest='oneline',     default=False, action=Util.StoreBoolean,    help='Display versions on one line with the name.  Default: %(default)s')
    parser.add_argument('--times', '-T',    dest='checktimes',  default=False, action=Util.StoreBoolean,    help='Use file time changes when determining diffs. Default: %(default)s')
    parser.add_argument('--metadata', '-M', dest='checkmeta',   default=False, action=Util.StoreBoolean,    help='Use any metadata changes when determining diffs.  Default: %(default)s')
    parser.add_argument('--headers',        dest='headers',     default=True,  action=Util.StoreBoolean,    help='Show headers. Default: %(default)s')
    parser.add_argument('--colors',         dest='colors',      default=isatty, action=Util.StoreBoolean,   help='Use colors. Default: %(default)s')
    parser.add_argument('--columns',        dest='columns',     type=int, default=None ,                    help='Number of columns to display')

    parser.add_argument('--recurse', '-R',  dest='recurse',     default=False, action='store_true',         help='List Directories Recurively')
    parser.add_argument('--maxdepth',       dest='maxdepth',    default=sys.maxsize, type=int,               help='Maximum depth to recurse directories')

    parser.add_argument('--glob',           dest='glob',        default=False, action=Util.StoreBoolean,    help='Glob filenames')

    parser.add_argument('--reduce',         dest='reduce',      default=0, type=int, const=sys.maxsize, nargs='?',
                        help='Reduce paths by N directories.  No value for smart reduction')
    parser.add_argument('--realpath',       dest='realpath',    default=True, action=Util.StoreBoolean,     help='Use the full path, expanding symlinks to their actual path components')

    rangegrp = parser.add_mutually_exclusive_group()
    rangegrp.add_argument('--range',        dest='range',   default=None,                                   help="Use a range of backupsets.  Format: 'Start:End' Start and End can be names or backupset numbers.  Either value can be left off to indicate the first or last set respectively")
    rangegrp.add_argument('--dates',        dest='daterange', default=None,                                 help="Use a range of dates for the backupsets.  Format: 'Start:End'.  Start and End are names which can be intepreted liberally.  Either can be left off to indicate the first or last set respectively")

    parser.add_argument('--exceptions',     default=False, action=Util.StoreBoolean, dest='exceptions', help="Log full exception data");

    parser.add_argument('--verbose', '-v',  action='count', default=0, dest='verbose',                  help='Increase the verbosity')
    parser.add_argument('--version',        action='version', version='%(prog)s ' + Tardis.__versionstring__,    help='Show the version')
    parser.add_argument('--help', '-h',     action='help')

    parser.add_argument('directories', nargs='*', default='.',                                              help='List of directories/files to list')

    Util.addGenCompletions(parser)

    return parser.parse_args(remaining)
开发者ID:koldinger,项目名称:Tardis,代码行数:54,代码来源:List.py

示例15: collectDirContents2

def collectDirContents2(tardis, dirList, crypt):
    """
    Do the same thing as collectDirContents, just a lot faster, relying on the structure of the DB.
    Create a set of directory "ranges", a range being a set of entries in the dirlist that a: all have
    the same inode, and b: span a contiguous range of backupsets in the backupsets list (ie, if there are 3
    backupsets in the range in backupsets, there also must be the same three entries in the dirlist).  Then
    query any directory entries that exist in here, and span each one over the approriate portions of the
    range.  Repeat for each range.
    """

    contents = {}
    for (x, y) in dirList:
        contents[x['backupset']] = {}
    names = set()
    ranges = []
    dirRange = []
    prev = {}
    dirHash = dict([(x['backupset'], y) for (x,y) in dirList])
    # Detect the ranges
    for bset in backupSets:
        d = dirHash.setdefault(bset['backupset'])
        # If we don't have an entry here, the range ends.
        # OR if the inode is different from the previous
        if prev and ((not d) or (prev['inode'] != d['inode']) or (prev['device'] != d['device'])):
            if len(dirRange):
                ranges.append(dirRange)
                dirRange = []
        if d:
            dirRange.append(bset)
        prev = d
    if len(dirRange):
        ranges.append(dirRange)

    # Now, for each range, populate
    for r in ranges:
        first = r[0]['backupset']
        last  = r[-1]['backupset']
        dinfo = dirHash[first]
        #print "Reading for (%d, %d) : %d => %d" %(dinfo['inode'], dinfo['device'], first, last)
        x = tardis.readDirectoryForRange((dinfo['inode'], dinfo['device']), first, last)
        for y in x:
            logger.debug("Processing %s", y['name'])
            name = Util.asString(crypt.decryptFilename(y['name'])) if crypt else Util.asString(y['name'])
            names.add(name)
            for bset in r:
                if y['firstset'] <= bset['backupset'] <= y['lastset']:
                    contents[bset['backupset']][name] = y

    # and return what we've discovered
    return (contents, names)
开发者ID:koldinger,项目名称:Tardis,代码行数:50,代码来源:List.py


注:本文中的Tardis.Util类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。