exception decorator and mail send for errors and changes to rec state checker
This commit is contained in:
@@ -6,11 +6,14 @@ from pprint import pprint
|
||||
|
||||
import requests
|
||||
from requests.auth import HTTPBasicAuth
|
||||
from requests.exceptions import ConnectionError
|
||||
|
||||
from backend import LrcException
|
||||
from backend.recorder_adapters import RecorderAdapter
|
||||
|
||||
# HOST = "localhost"
|
||||
from backend.tools.exception_decorator import exception_decorator
|
||||
|
||||
BASE_URL = "http://172.23.8.102" # Audimax SMP 351
|
||||
|
||||
USER = "admin"
|
||||
@@ -34,12 +37,14 @@ class EpiphanV1(RecorderAdapter):
|
||||
def _get_version(self):
|
||||
pass
|
||||
|
||||
def get_status(self) -> dict:
|
||||
@exception_decorator(ConnectionError)
|
||||
def get_recording_status(self) -> dict:
|
||||
res = self.session.get(self.url + "/admin/ajax/recorder_status.cgi")
|
||||
if res.ok:
|
||||
return res.json()
|
||||
raise LrcException(res.text, res.status_code)
|
||||
|
||||
@exception_decorator(ConnectionError)
|
||||
def get_sysinfo(self) -> dict:
|
||||
res = self.session.get(self.url + "/ajax/sysinfo.cgi")
|
||||
if res.ok:
|
||||
@@ -47,7 +52,7 @@ class EpiphanV1(RecorderAdapter):
|
||||
raise LrcException(res.text, res.status_code)
|
||||
|
||||
def is_recording(self) -> bool:
|
||||
state = self.get_status().get('state', None)
|
||||
state = self.get_recording_status().get('state', None)
|
||||
return state == "up"
|
||||
|
||||
def get_recording_time(self):
|
||||
@@ -55,7 +60,7 @@ class EpiphanV1(RecorderAdapter):
|
||||
Returns recording time in seconds. Also returns 0 if not recording.
|
||||
:return:
|
||||
"""
|
||||
return self.get_status().get('seconds', None)
|
||||
return self.get_recording_status().get('seconds', None)
|
||||
|
||||
def start_recording(self):
|
||||
res = self.session.get(self.url + "/admin/ajax/start_recorder.cgi")
|
||||
|
||||
Reference in New Issue
Block a user