def get_counters(self, name=None, agent=None):  # pragma: no cover (hard to test, requires a running backup)
        """See :func:`burpui.misc.backend.interface.BUIbackend.get_counters`"""
        res = {}
        if agent:
            if not name or name not in self.running[agent]:
                return res
        else:
            if 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:
            # self._logger('debug', 'line: {0}'.format(line))
            reg = re.search(r'^{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'):
                    # self._logger('debug', '{0}: {1}'.format(self.counters[c], v))
                    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:
            # You know... division by 0
            res['percent'] = 0
        return res
dataset/ETHPy150Open ziirish/burp-ui/burpui/misc/backend/burp1.py/Burp.get_counters/original