exception decorator and mail send for errors and changes to rec state checker
This commit is contained in:
@@ -104,6 +104,9 @@ class RecorderAdapter:
|
||||
def is_recording(self) -> bool:
|
||||
pass
|
||||
|
||||
def get_recording_status(self) -> str:
|
||||
pass
|
||||
|
||||
|
||||
def get_defined_recorder_adapters():
|
||||
models = []
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -2,8 +2,9 @@ import logging
|
||||
|
||||
from backend import LrcException
|
||||
from backend.recorder_adapters import telnetlib, TelnetAdapter, RecorderAdapter
|
||||
from backend.tools.exception_decorator import exception_decorator
|
||||
|
||||
logger = logging.getLogger()
|
||||
logger = logging.getLogger("lrc.recorder_adapters.extron_smp")
|
||||
|
||||
RECORDER_MODEL_NAME = "SMP 351 / 352"
|
||||
VERSION = "0.9.0"
|
||||
@@ -28,11 +29,13 @@ class SMP(TelnetAdapter, RecorderAdapter):
|
||||
self._login()
|
||||
|
||||
def _login(self):
|
||||
print("Connecting to {} ...".format(self.address))
|
||||
logger.info("Connecting to {} ...".format(self.address))
|
||||
try:
|
||||
self.tn = telnetlib.Telnet(self.address)
|
||||
except TimeoutError as e:
|
||||
raise LrcException(str(e))
|
||||
except ConnectionRefusedError as e:
|
||||
raise LrcException(str(e))
|
||||
self.tn.read_until("\r\nPassword:")
|
||||
# password = getpass.getpass()
|
||||
password = self.admin_pw
|
||||
@@ -371,6 +374,7 @@ class SMP(TelnetAdapter, RecorderAdapter):
|
||||
self.tn.write("{}Y2RCDR\n".format(self.esc_char))
|
||||
return TelnetAdapter._get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
@exception_decorator(ConnectionError)
|
||||
def get_recording_status(self):
|
||||
"""
|
||||
Status may be one of:
|
||||
|
||||
Reference in New Issue
Block a user