get config only if exist.
This commit is contained in:
parent
28191883a2
commit
af59f5e316
@ -15,7 +15,9 @@ from pymediainfo import MediaInfo
|
||||
|
||||
|
||||
def read_yaml():
|
||||
config = GuiSettings.objects.filter(id=1).values()[0]
|
||||
setting = GuiSettings.objects.filter(id=1).values()
|
||||
if setting:
|
||||
config = setting[0]
|
||||
|
||||
if config and os.path.isfile(config['playout_config']):
|
||||
with open(config['playout_config'], 'r') as config_file:
|
||||
@ -149,9 +151,11 @@ class PlayoutService:
|
||||
|
||||
class SystemStats:
|
||||
def __init__(self):
|
||||
self.config = GuiSettings.objects.filter(id=1).values()[0]
|
||||
settings = GuiSettings.objects.filter(id=1).values()
|
||||
self.config = settings[0] if settings else []
|
||||
|
||||
def all(self):
|
||||
if self.config:
|
||||
return {
|
||||
**self.system(),
|
||||
**self.cpu(), **self.ram(), **self.swap(),
|
||||
@ -189,6 +193,7 @@ class SystemStats:
|
||||
}
|
||||
|
||||
def disk(self):
|
||||
if 'media_disk' in self.config and self.config['media_disk']:
|
||||
root = psutil.disk_usage(self.config['media_disk'])
|
||||
return {
|
||||
'disk_total': [root.total, sizeof_fmt(root.total)],
|
||||
@ -208,6 +213,10 @@ class SystemStats:
|
||||
def net_speed(self):
|
||||
net = psutil.net_if_stats()
|
||||
|
||||
if not 'net_interface' in self.config or \
|
||||
not self.config['net_interface']:
|
||||
return
|
||||
|
||||
if self.config['net_interface'] not in net:
|
||||
return {
|
||||
'net_speed_send': 'no network interface set!',
|
||||
|
Loading…
x
Reference in New Issue
Block a user