def ip_stat(self, ip, dfrom, dto, det): """Get info about ip from billing""" from billing import Dbi result = dict() try: dbi = Dbi(ip) _stat = dbi._get_stat(dfrom, dto, det) #print _stat except Exception as e: result['status'] = False result['data'] = (('error:', e.message), ) return result #TODO: data.tpl должен принимать в качестве параметров список а не словарь # Необходимо переделать все функции!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stat = list() stat.append(_stat['header']) stat.extend(_stat['body']) result['status'] = True result['result'] = True if len(stat) > 0 else False result['data'] = stat return result
def ip_info(self, ip): """Get info about ip from billing""" from billing import Dbi result = dict() try: dbi = Dbi(ip) except Exception as e: result['status'] = False result['data'] = (('error:', e.message), ) return result if dbi: result['status'] = True result['result'] = dbi.active result['data'] = [(dbi.field_descr(k).decode('utf-8'), v) for (k, v) in dbi._ipinfo.items()] else: result['status'] = False result['data'] = (('error:', "ip '{}' not exist in Billing DB".format(ip)), ) return result