

def get_counters(self, name=None, agent=None):
    'See :func:`burpui.misc.backend.interface.BUIbackend.get_counters`'
    res = {
        
    }
    if agent:
        if ((not name) or (name not in self.running[agent])):
            return res
    elif ((not name) or (name not in self.running)):
        return res
    filemap = self.status('c:{0}\n'.format(name))
    if (not filemap):
        return res
    for line in filemap:
        reg = re.search('^{0}\\s+(\\d)\\s+(\\S)\\s+(.+)$'.format(name), line)
        if (reg and (reg.group(2) == 'r') and (int(reg.group(1)) == 2)):
            count = 0
            for val in reg.group(3).split('\t'):
                if (val and (count > 0) and (count < 15)):
                    try:
                        vals = map(int, val.split('/'))
                        if ((vals[0] > 0) or (vals[1] > 0) or vals[2] or (vals[3] > 0)):
                            res[self.counters[count]] = vals
                    except (ValueError, IndexError):
                        count += 1
                        continue
                elif val:
                    if (self.counters[count] == 'path'):
                        res[self.counters[count]] = val
                    else:
                        try:
                            res[self.counters[count]] = int(val)
                        except ValueError:
                            count += 1
                            continue
                count += 1
    if ('bytes' not in res):
        res['bytes'] = 0
    if (res.viewkeys() & {'start', 'estimated_bytes', 'bytes_in'}):
        try:
            diff = (time.time() - int(res['start']))
            byteswant = int(res['estimated_bytes'])
            bytesgot = int(res['bytes_in'])
            bytespersec = (bytesgot / diff)
            bytesleft = (byteswant - bytesgot)
            res['speed'] = bytespersec
            if (bytespersec > 0):
                timeleft = int((bytesleft / bytespersec))
                res['timeleft'] = timeleft
            else:
                res['timeleft'] = (- 1)
        except:
            res['timeleft'] = (- 1)
    try:
        res['percent'] = round(((float(res['bytes']) / float(res['estimated_bytes'])) * 100))
    except Exception:
        res['percent'] = 0
    return res

dataset/ETHPy150Open ziirish/burp-ui/burpui/misc/backend/burp1.py Burp.get_counters/original