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


Python Util.fmtSize方法代码示例

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


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

示例1: _bsetInfo

# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import fmtSize [as 别名]
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,代码行数:27,代码来源:Sonic.py

示例2: _bsetInfo

# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import fmtSize [as 别名]
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,代码行数:27,代码来源:Sonic.py

示例3: listBSets

# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import fmtSize [as 别名]
def listBSets(db):
    try:
        last = db.lastBackupSet()
        for i in db.listBackupSets():
            t = time.strftime("%d %b, %Y %I:%M:%S %p", time.localtime(float(i["starttime"])))
            if i["endtime"] is not None:
                duration = str(datetime.timedelta(seconds=(int(float(i["endtime"]) - float(i["starttime"])))))
            else:
                duration = ""
            completed = "Comp" if i["completed"] else "Incomp"
            full = "Full" if i["full"] else "Delta"
            isCurrent = current if i["backupset"] == last["backupset"] else ""
            size = Util.fmtSize(i["bytesreceived"], formats=["", "KB", "MB", "GB", "TB"])

            print "%-30s %-4d %-6s %3d  %-5s  %s  %-7s %6s %5s %8s  %s" % (
                i["name"],
                i["backupset"],
                completed,
                i["priority"],
                full,
                t,
                duration,
                i["filesfull"],
                i["filesdelta"],
                size,
                isCurrent,
            )
    except Exception as e:
        logger.error(e)
        logger.exception(e)
        return 1
开发者ID:daleathan,项目名称:Tardis,代码行数:33,代码来源:Sonic.py

示例4: listFiles

# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import fmtSize [as 别名]
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,代码行数:61,代码来源:Sonic.py

示例5: removeOrphans

# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import fmtSize [as 别名]
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,代码行数:12,代码来源:Sonic.py

示例6: listBSets

# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import fmtSize [as 别名]
def listBSets(db, crypt, cache):
    global _regenerator
    try:
        if args.longinfo:
            _regenerator = Regenerator.Regenerator(cache, db, crypt)

        last = db.lastBackupSet()
        print("%-30s %-4s %-6s %3s  %-5s  %-24s  %-7s %6s %5s %8s  %s" % ("Name", "Id", "Comp", "Pri", "Full", "Start", "Runtime", "Files", "Delta", "Size", ""))
        sets = list(db.listBackupSets())

        if args.minpriority:
            sets = list(filter(lambda x: x['priority'] >= args.minpriority, sets))
        sets = sets[-(args.number):]

        for bset in sets:
            t = time.strftime("%d %b, %Y %I:%M:%S %p", time.localtime(float(bset['starttime'])))
            if bset['endtime'] is not None:
                duration = str(datetime.timedelta(seconds = (int(float(bset['endtime']) - float(bset['starttime'])))))
            else:
                duration = ''
            completed = 'Comp' if bset['completed'] else 'Incomp'
            full      = 'Full' if bset['full'] else 'Delta'
            isCurrent = current if bset['backupset'] == last['backupset'] else ''
            size = Util.fmtSize(bset['bytesreceived'], formats=['', 'KB', 'MB', 'GB', 'TB'])

            print("%-30s %-4d %-6s %3d  %-5s  %-24s  %-7s %6s %5s %8s  %s" % (bset['name'], bset['backupset'], completed, bset['priority'], full, t, duration, bset['filesfull'], bset['filesdelta'], size, isCurrent))
            if args.longinfo:
                commandLine = getCommandLine(db, bset['commandline'])
                if commandLine:
                    print("    Command Line: %s" % (commandLine.decode('utf-8')))
                    print()
    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,代码行数:41,代码来源:Sonic.py

示例7: printit

# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import fmtSize [as 别名]
def printit(info, name, color, gone):
    global column
    annotation = ''
    if args.annotate and info is not None:
        if info['dir']:
            annotation = '/'
        elif info['link']:
            annotation = '@'
        elif info['mode'] & (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH):
            annotation = '*'
    name = name + annotation
    if gone:
        name = '(' + name + ')'

    if column == 0:
        doprint('  ')

    if args.cksums:
        if info and info['checksum']:
            cksum = info['checksum']
        else:
            cksum = ''
    if args.chnlen:
        if info and info['chainlength'] is not None:
            chnlen = "%-3d" % int(info['chainlength'])
        else:
            chnlen = ''
    if args.inode:
        if info and info['inode'] is not None:
            inode = "%8d" % int(info['inode'])
        else:
            inode = ''
    if args.size:
        if info and info['size'] is not None:
            if args.human:
                fsize = "%8s" % Util.fmtSize(info['size'], formats=['','KB','MB','GB', 'TB', 'PB'])
            else:
                fsize = "%8d" % int(info['size'])
        else:
            fsize = ''

    if args.long:
        if gone:
            doprint('  %s' % (name), color, eol=True)
        else:
            mode = Util.filemode(info['mode'])
            group = Util.getGroupName(info['gid'])
            owner = Util.getUserId(info['uid'])
            mtime = Util.formatTime(info['mtime'])
            nlinks = info['nlinks']
            if info['size'] is not None:
                if args.human:
                    size = Util.fmtSize(info['size'], formats=['','KB','MB','GB', 'TB', 'PB'])
                else:
                    size = "%8d" % info['size']
            else:
                size = ''
            doprint('  %9s %3d %-8s %-8s %8s %12s ' % (mode, nlinks, owner, group, size, mtime), color=colors['name'])
            if args.size:
                doprint(' %8s ' % (fsize))
            if args.inode:
                doprint(' %8s ' % (inode))
            if args.cksums:
                doprint(' %32s ' % (cksum))
            if args.chnlen:
                doprint(' %-3s ' % (chnlen))
            doprint('%s' % (name), color, eol=True)
    elif args.cksums or args.chnlen or args.inode or args.size:
        doprint(columnfmt % name, color)
        if args.size:
            doprint(' ' + fsize, color=colors['name'])
        if args.inode:
            doprint(' ' + inode, color=colors['name'])
        if args.cksums:
            doprint(' ' + cksum, color=colors['name'])
        if args.chnlen:
            doprint(' ' + chnlen, color=colors['name'])
        doprint(' ', eol=True)
    else:
        column += 1
        if column == columns:
            eol = True
            column = 0
        else:
            eol = False
        doprint(columnfmt % name, color, eol=eol)
开发者ID:koldinger,项目名称:Tardis,代码行数:88,代码来源:List.py


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