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), if args.cksums: print ' %32s ' % (fInfo['checksum'] or ''), if args.chnlen: print ' %4s ' % (fInfo['chainlength']), if args.inode: print ' %-16s ' % ("(%s, %s)" % (fInfo['device'], fInfo['inode'])), print name else: print " %s" % status, if args.cksums: print ' %32s ' % (fInfo['checksum'] or ''), if args.chnlen: print ' %4s ' % (fInfo['chainlength']), if args.inode: print ' %-16s ' % ("(%s, %s)" % (fInfo['device'], fInfo['inode'])), print name
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)
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)
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)