Merge branch 'develop' of Nixellion/DashMachine into develop
This commit is contained in:
commit
0f72583f31
@ -135,5 +135,5 @@ def get_data_source(data_source):
|
||||
module = importlib.import_module(
|
||||
f"dashmachine.platform.{data_source['platform']}", "."
|
||||
)
|
||||
platform = module.Platform(data_source, data_source_args)
|
||||
platform = module.Platform(data_source, **data_source_args)
|
||||
return platform.process()
|
||||
|
@ -2,9 +2,9 @@ from requests import get
|
||||
|
||||
|
||||
class Platform:
|
||||
def __init__(self, data_source, data_source_args):
|
||||
def __init__(self, *args, **kwargs):
|
||||
# parse the user's options from the config entries
|
||||
for key, value in data_source_args.items():
|
||||
for key, value in kwargs.items():
|
||||
self.__dict__[key] = value
|
||||
|
||||
def process(self):
|
||||
|
@ -5,9 +5,9 @@ from flask import render_template_string
|
||||
|
||||
|
||||
class Platform:
|
||||
def __init__(self, data_source, data_source_args):
|
||||
def __init__(self, *args, **kwargs):
|
||||
# parse the user's options from the config entries
|
||||
for key, value in data_source_args.items():
|
||||
for key, value in kwargs.items():
|
||||
self.__dict__[key] = value
|
||||
|
||||
# set defaults for omitted options
|
||||
|
34
dashmachine/platform/transmission.py
Normal file
34
dashmachine/platform/transmission.py
Normal file
@ -0,0 +1,34 @@
|
||||
import json
|
||||
from flask import render_template_string
|
||||
import transmissionrpc
|
||||
|
||||
|
||||
# from pprint import PrettyPrinter
|
||||
# pp = PrettyPrinter()
|
||||
|
||||
class Platform:
|
||||
def __init__(self, *args, **kwargs):
|
||||
# parse the user's options from the config entries
|
||||
for key, value in kwargs.items():
|
||||
self.__dict__[key] = value
|
||||
|
||||
if not hasattr(self, "port"):
|
||||
self.port = 9091
|
||||
if not hasattr(self, "host"):
|
||||
self.host = 'localhost'
|
||||
|
||||
self.tc = transmissionrpc.Client(self.host, port=self.port, user=self.user, password=self.password)
|
||||
|
||||
def process(self):
|
||||
|
||||
torrents = len(self.tc.get_torrents())
|
||||
data = {}
|
||||
for key, field in self.tc.session_stats().__dict__['_fields'].items():
|
||||
data[key] = field.value
|
||||
# pp.pprint (data)
|
||||
|
||||
value_template = render_template_string(self.value_template, **data)
|
||||
return value_template
|
||||
|
||||
# Testing
|
||||
# test = Platform(host='192.168.1.19', user='', password='').process()
|
@ -32,3 +32,4 @@ SQLAlchemy==1.3.13
|
||||
urllib3==1.25.8
|
||||
Werkzeug==0.16.1
|
||||
WTForms==2.2.1
|
||||
transmissionrpc
|
Loading…
x
Reference in New Issue
Block a user