added logging conf and now checking recording status with simple script ; notifications are missing
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import logging
|
||||
|
||||
from backend import LrcException
|
||||
from backend.recorder_adapters import telnetlib, TelnetAdapter, RecorderAdapter
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
RECORDER_MODEL_NAME = "SMP 351 / 352"
|
||||
VERSION = "0.9.0"
|
||||
REQUIRES_USER = False
|
||||
@@ -16,26 +21,34 @@ PW = "123mzsmp"
|
||||
|
||||
|
||||
class SMP(TelnetAdapter, RecorderAdapter):
|
||||
def __init__(self, address, password, **kwargs):
|
||||
def __init__(self, address, password, auto_login=True, **kwargs):
|
||||
super().__init__(address)
|
||||
self.admin_pw = password
|
||||
if auto_login:
|
||||
self._login()
|
||||
|
||||
def _login(self):
|
||||
self.tn = telnetlib.Telnet(HOST)
|
||||
print("Connecting to {} ...".format(self.address))
|
||||
try:
|
||||
self.tn = telnetlib.Telnet(self.address)
|
||||
except TimeoutError as e:
|
||||
raise LrcException(str(e))
|
||||
self.tn.read_until("\r\nPassword:")
|
||||
# password = getpass.getpass()
|
||||
password = self.admin_pw
|
||||
self.tn.write(password + "\n\r")
|
||||
|
||||
out = self.tn.assert_string_in_output("Login Administrator")
|
||||
print(out)
|
||||
if not out[0]:
|
||||
print(out[1])
|
||||
if "Password:" in out[1]:
|
||||
# TODO: loop until logged in...
|
||||
print("re-enter pw")
|
||||
self.tn.write("123mzsmp\n\r")
|
||||
self.tn.write(self.admin_pw+"\n\r")
|
||||
print(self.tn.assert_string_in_output("Login Administrator"))
|
||||
print("WRONG (admin) password!! Exiting!")
|
||||
print(self.admin_pw)
|
||||
self.tn = None
|
||||
raise Exception("Could not login as administrator with given pw!")
|
||||
print("OK, we have admin rights!")
|
||||
@@ -369,6 +382,9 @@ class SMP(TelnetAdapter, RecorderAdapter):
|
||||
self.tn.write("{}YRCDR\n".format(self.esc_char))
|
||||
return TelnetAdapter._get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def is_recording(self):
|
||||
return self.get_recording_status() == 1
|
||||
|
||||
def extent_recording_time(self, extension_time: int):
|
||||
"""
|
||||
Extends a scheduled recording by extension_time minutes
|
||||
@@ -764,7 +780,7 @@ class SMP(TelnetAdapter, RecorderAdapter):
|
||||
|
||||
|
||||
def main():
|
||||
smp = SMP(HOST, PW)
|
||||
smp = SMP(HOST, PW, False)
|
||||
print(smp)
|
||||
smp._login()
|
||||
print(smp.get_version(verbose_info=False))
|
||||
|
||||
Reference in New Issue
Block a user