added code to initialize db with models and recodres

This commit is contained in:
Tobias Kurze
2019-11-20 12:41:05 +01:00
parent bc1347fe99
commit 60ff5bdeaf
20 changed files with 1658 additions and 136 deletions

View File

@@ -1,4 +1,12 @@
# Copyright (c) 2019. Tobias Kurze
"""
This is the recorder adapter implementation for Epiphan Recorders. The following Epiphan recorder models are supported:
- LectureRecorder X2
- LectureRecorder
- VGADVI Recorder
- DVI Broadcaster DL
- DVIRecorderDL
"""
import shutil
import time
from datetime import datetime
@@ -14,39 +22,44 @@ from backend.recorder_adapters import RecorderAdapter
# HOST = "localhost"
from backend.tools.exception_decorator import exception_decorator
RECORDER_MODEL_NAME = "Epiphan Recorder Adapter (for: )"
BASE_URL = "http://172.23.8.102" # Audimax SMP 351
USER = "admin"
PW = "lrgrashof+-"
class EpiphanV1(RecorderAdapter):
def __init__(self, url: str, admin_user: str, admin_pw: str):
if not url.startswith('http'):
url = 'http://' + url
self.url = url
self.user = admin_user
self.password = admin_pw
class Epiphan(RecorderAdapter):
def __init__(self, address: str, user: str, password: str, firmware_version: str = "", **kwargs):
if not address.startswith('http'):
address = 'http://' + address
super().__init__(address, user, password)
self.firmware_version = firmware_version
self.session = requests.Session()
self.session.auth = HTTPBasicAuth(self.user, self.password)
@classmethod
def get_recorder_params(cls) -> dict:
return {'_requires_user': True,
'_requires_password': True}
def _get_name(self):
pass
return RECORDER_MODEL_NAME
def _get_version(self):
pass
@exception_decorator(ConnectionError)
def get_recording_status(self) -> dict:
res = self.session.get(self.url + "/admin/ajax/recorder_status.cgi")
res = self.session.get(self.address + "/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")
res = self.session.get(self.address + "/ajax/sysinfo.cgi")
if res.ok:
return res.json()
raise LrcException(res.text, res.status_code)
@@ -63,13 +76,13 @@ class EpiphanV1(RecorderAdapter):
return self.get_recording_status().get('seconds', None)
def start_recording(self):
res = self.session.get(self.url + "/admin/ajax/start_recorder.cgi")
res = self.session.get(self.address + "/admin/ajax/start_recorder.cgi")
if not res.ok:
raise LrcException(res.text, res.status_code)
time.sleep(2) # just a little bit of waiting time -> it takes a bit for the Epiphan to update its state
def stop_recording(self):
res = self.session.get(self.url + "/admin/ajax/stop_recorder.cgi")
res = self.session.get(self.address + "/admin/ajax/stop_recorder.cgi")
if not res.ok:
raise LrcException(res.text, res.status_code)
time.sleep(4) # just a little bit of waiting time -> it takes a bit for the Epiphan to update its state
@@ -114,7 +127,7 @@ class EpiphanV1(RecorderAdapter):
raise LrcException(str(err))
def get_screenshot(self):
ret = self.session.get(self.url + "/admin/grab_frame.cgi?size=256x192&device=DAV93133.vga&_t=1573471990578",
ret = self.session.get(self.address + "/admin/grab_frame.cgi?size=256x192&device=DAV93133.vga&_t=1573471990578",
stream=True)
print(ret)
@@ -125,7 +138,7 @@ class EpiphanV1(RecorderAdapter):
if __name__ == '__main__':
e = EpiphanV1(BASE_URL, USER, PW)
e = Epiphan(BASE_URL, USER, PW)
try:
# print(e.is_recording())
"""