def json_engine(self, req): # pylint: disable=R0201,W0613 """ Return torrent engine data. """ try: return stats.engine_data(config.engine) except (error.LoggableError, xmlrpc.ERRORS), torrent_exc: raise exc.HTTPInternalServerError(str(torrent_exc))
def module_test(): """ Quick test using… python -m pyrocore.daemon.webapp """ import pprint from pyrocore import connect try: engine = connect() print("%s - %s" % (engine.engine_id, engine.open())) pprint.pprint(stats.engine_data(engine)) print("%s - %s" % (engine.engine_id, engine.open())) except (error.LoggableError, xmlrpc.ERRORS), torrent_exc: print("ERROR: %s" % torrent_exc)
def _flux_engine_data(engine): """ Return rTorrent data set for pushing to InfluxDB. """ data = stats.engine_data(engine) # Make it flat data["up_rate"] = data["upload"][0] data["up_limit"] = data["upload"][1] data["down_rate"] = data["download"][0] data["down_limit"] = data["download"][1] data["version"] = data["versions"][0] views = data["views"] del data["upload"] del data["download"] del data["versions"] del data["views"] return data, views