44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
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())
|