

def _parse_backup_stats(self, number, client, forward=False, agent=None):
    'The :func:`burpui.misc.backend.burp2.Burp._parse_backup_stats`\n        function is used to parse the burp logs.\n\n        :param number: Backup number to work on\n        :type number: int\n\n        :param client: Client name to work on\n        :type client: str\n\n        :param forward: Is the client name needed in later process\n        :type forward: bool\n\n        :param agent: What server to ask (only in multi-agent mode)\n        :type agent: str\n\n        :returns: Dict containing the backup log\n        '
    ret = {
        
    }
    backup = {
        'windows': 'unknown',
        'number': int(number),
    }
    if forward:
        backup['name'] = client
    translate = {
        'time_start': 'start',
        'time_end': 'end',
        'time_taken': 'duration',
        'bytes': 'totsize',
        'bytes_received': 'received',
        'bytes_estimated': 'estimated_bytes',
        'files': 'files',
        'files_encrypted': 'files_enc',
        'directories': 'dir',
        'soft_links': 'softlink',
        'hard_links': 'hardlink',
        'meta_data': 'meta',
        'meta_data_encrypted': 'meta_enc',
        'special_files': 'special',
        'efs_files': 'efs',
        'vss_headers': 'vssheader',
        'vss_headers_encrypted': 'vssheader_enc',
        'vss_footers': 'vssfooter',
        'vss_footers_encrypted': 'vssfooter_enc',
        'total': 'total',
        'grand_total': 'total',
    }
    counts = {
        'new': 'count',
        'changed': 'changed',
        'unchanged': 'same',
        'deleted': 'deleted',
        'total': 'scanned',
        'scanned': 'scanned',
    }
    single = ['time_start', 'time_end', 'time_taken', 'bytes_received', 'bytes_estimated', 'bytes']
    query = self.status('c:{0}:b:{1}:l:backup_stats\n'.format(client, number), agent=agent)
    if (not query):
        return ret
    try:
        back = query['clients'][0]['backups'][0]
    except KeyError as e:
        self._logger('warning', 'No backup found')
        return ret
    if ('backup_stats' not in back['logs']):
        self._logger('warning', 'No stats found for backup')
        return ret
    stats = None
    try:
        stats = json.loads(''.join(back['logs']['backup_stats']))
    except:
        stats = back['logs']['backup_stats']
    if (not stats):
        return ret
    if ('counters' not in stats):
        return super(Burp, self)._parse_backup_stats(number, client, forward, stats, agent)
    counters = stats['counters']
    for counter in counters:
        name = counter['name']
        if (name in translate):
            name = translate[name]
        if (counter['name'] in single):
            backup[name] = counter['count']
        else:
            backup[name] = {
                
            }
            for (k, v) in iteritems(counts):
                if (v in counter):
                    backup[name][k] = counter[v]
                else:
                    backup[name][k] = 0
    if (('start' in self) and ('end' in backup)):
        backup['duration'] = (backup['end'] - backup['start'])
    return backup

dataset/ETHPy150Open ziirish/burp-ui/burpui/misc/backend/burp2.py Burp._parse_backup_stats/VarMisuse@548/1066 `backup`->`self`