Exemplo n.º 1
0
 def children_info(self):
     result = OrderedDict({
         '`total_size': human_size(self.total_size),
         '`part_path': self.part_path,
     })
     for child_name, child_item in self._dict_children.items():
         result[child_item.full_path] = child_item.children_info
     return result
Exemplo n.º 2
0
    def actions(self, item):
        if item.type == 'dir' and hasattr(item, 'dir'):
            freespace = util.freespace(item.dir)
            totalspace = util.totalspace(item.dir)
            try:
                percentage = freespace * 100.0 / totalspace
            except ZeroDivisionError, e:
                percentage = 0.0
                print e

            if (totalspace == 0): # no space perhaps a bad path
                diskfree = _( 'Bad Path' )
            else:
                diskfree = _( '%(freespace)s free of %(totalspace)s total (%(percentage)i%% free)' ) % ({
                    'freespace': util.human_size(freespace),
                    'totalspace': util.human_size(totalspace),
                    'percentage': percentage})
            return  [ ( self.dud, diskfree) ]
Exemplo n.º 3
0
def stats_squashfs(squashfs):
    """
    Produce squashfs statistics.
    """
    try:
        size_file = os.path.join(squashfs, 'filesystem.size')
        size = human_size(int(''.join(open(size_file, "r").read().split())))
    except FileNotFoundError:
        size = 0

    logging.info('livefs     [%4s MB]' % size)
Exemplo n.º 4
0
def stats_dirs(iso):
    """
    Overall statistics of the ISO file itself.
    """
    logging.info('---')
    dirs = ['.', 'boot', 'dists', 'doc', 'EFI', 'install',
            'isolinux', 'pics', 'preseed', 'pool']

    for folder in dirs:
        path = os.path.join(iso, folder)
        logging.info('%-10s [%4s MB]' % (folder, human_size(get_folder_size(path))))
Exemplo n.º 5
0
    def actions(self, item):
        if item.type == 'dir' and hasattr(item, 'dir'):
            freespace = util.freespace(item.dir)
            totalspace = util.totalspace(item.dir)
            try:
                percentage = freespace * 100.0 / totalspace
            except ZeroDivisionError, e:
                percentage = 0.0
                print e

            if (totalspace == 0):  # no space perhaps a bad path
                diskfree = _('Bad Path')
            else:
                diskfree = _(
                    '%(freespace)s free of %(totalspace)s total (%(percentage)i%% free)'
                ) % ({
                    'freespace': util.human_size(freespace),
                    'totalspace': util.human_size(totalspace),
                    'percentage': percentage
                })
            return [(self.dud, diskfree)]
Exemplo n.º 6
0
def manifest(target):
    """
    Produces a manifest of the target dir.
    """
    files = []
    for file in glob.glob(target, recursive=True):
        if os.path.isfile(file):
            name = os.path.basename(file).split('_')[0]
            version = os.path.basename(file).split('_')[1]
            size = human_size(os.path.getsize(file))
            files.append((name, version, size))

    for file in sorted(files):
        logging.info('%s,%s,%s' % (file[0], file[1], file[2]))
Exemplo n.º 7
0
 def _get_size(self, size):
     return '{} <> {}%'.format(human_size(size), round(size * 100 / self._walk_folder.total_size, 2))