added recorder command backend
This commit is contained in:
43
recorder_adapters/extron_smp.py
Normal file
43
recorder_adapters/extron_smp.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import getpass
|
||||
import sys
|
||||
from abc import ABC, abstractmethod
|
||||
from backend.recorder_adapters import telnetlib, TelnetAdapter
|
||||
|
||||
# HOST = "localhost"
|
||||
# HOST = "129.13.51.102" # Audimax SMP 351
|
||||
# HOST = "129.13.51.106" # Tulla SMP 351
|
||||
HOST = "172.22.246.207" # Test SMP MZ
|
||||
|
||||
USER = "admin"
|
||||
PW = "123mzsmp"
|
||||
|
||||
|
||||
class SMP(TelnetAdapter):
|
||||
def __init__(self, address, admin_password):
|
||||
super().__init__(address)
|
||||
self.admin_pw = admin_password
|
||||
|
||||
def login(self):
|
||||
self.tn = telnetlib.Telnet(HOST)
|
||||
self.tn.read_until("\r\nPassword:")
|
||||
# password = getpass.getpass()
|
||||
password = self.admin_pw
|
||||
self.tn.write(password + "\n\r")
|
||||
|
||||
if not self.tn.assert_string_in_output("Login Administrator")[0]:
|
||||
print("WRONG (admin) password!! Exiting!")
|
||||
self.tn = None
|
||||
raise Exception("Could not login as administrator with given pw!")
|
||||
print("OK, we have admin rights!")
|
||||
|
||||
def get_version(self):
|
||||
self.tn.write("1Q\n")
|
||||
|
||||
# print_tn(read_line(tn))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
|
||||
smp = SMP(HOST, PW)
|
||||
print(smp)
|
||||
smp.login()
|
||||
print(smp.get_version())
|
||||
Reference in New Issue
Block a user