|
@@ -47,9 +47,14 @@ class ObjectTelnet(ObjectConnection):
|
|
|
error = self.read_data([self.olt.get_expected_password()])
|
|
|
if error != -1:
|
|
|
self.tn.write(self.password + self.NEW_LINE_UNIX)
|
|
|
- print("Loged in...\n")
|
|
|
+ print("Logged in...\n")
|
|
|
print self.tn.read_very_lazy()
|
|
|
- error = self.read_data([self.olt.get_expected_initial()])
|
|
|
+ cardinal = self.olt.get_expected_cardinal()
|
|
|
+ if isinstance(cardinal, list):
|
|
|
+ read_data_list = cardinal
|
|
|
+ else:
|
|
|
+ read_data_list = [cardinal]
|
|
|
+ error = self.read_data(read_data_list)
|
|
|
if error != -1:
|
|
|
if self.file_name is not None:
|
|
|
self.connection_file()
|
|
@@ -57,14 +62,14 @@ class ObjectTelnet(ObjectConnection):
|
|
|
self.connection_data()
|
|
|
else:
|
|
|
self.connection_old()
|
|
|
- print("fin-----")
|
|
|
+ print("-----FIN-----")
|
|
|
nc = 0
|
|
|
while self.QUIT:
|
|
|
if nc == 20:
|
|
|
self.QUIT = False
|
|
|
# send quit to terminal until exit confirmation
|
|
|
self.command_quit(self.olt.get_write_exit())
|
|
|
- contador += 1
|
|
|
+ nc += 1
|
|
|
self.tn.close()
|
|
|
self.save_log()
|
|
|
exit(self.RUN_OK)
|
|
@@ -111,7 +116,12 @@ class ObjectTelnet(ObjectConnection):
|
|
|
if self.olt.run_enable_password():
|
|
|
self.read_data([self.olt.get_expected_enable_password()])
|
|
|
self.tn.write(self.password_enable + self.NEW_LINE_UNIX)
|
|
|
- self.read_data([self.olt.get_expected_cardinal()])
|
|
|
+ cardinal = self.olt.get_expected_cardinal()
|
|
|
+ if isinstance(cardinal, list):
|
|
|
+ read_data_list = cardinal
|
|
|
+ else:
|
|
|
+ read_data_list = [cardinal]
|
|
|
+ self.read_data(read_data_list)
|
|
|
return True
|
|
|
return False
|
|
|
|
|
@@ -127,10 +137,18 @@ class ObjectTelnet(ObjectConnection):
|
|
|
read_data = None
|
|
|
with_confirmation = False
|
|
|
if self.olt.get_expected_exit() is not None:
|
|
|
- read_data = [self.olt.get_expected_cardinal(), self.olt.get_expected_exit()]
|
|
|
+ cardinal = self.olt.get_expected_cardinal()
|
|
|
+ if isinstance(cardinal, list):
|
|
|
+ read_data = cardinal + [self.olt.get_expected_exit()]
|
|
|
+ else:
|
|
|
+ read_data = [cardinal, self.olt.get_expected_exit()]
|
|
|
with_confirmation = True
|
|
|
if self.olt.get_expected_exit_with_confirmation() is not None:
|
|
|
- read_data = [self.olt.get_expected_cardinal(), self.olt.get_expected_exit_with_confirmation()]
|
|
|
+ cardinal = self.olt.get_expected_cardinal()
|
|
|
+ if isinstance(cardinal, list):
|
|
|
+ read_data = cardinal + [self.olt.get_expected_exit_with_confirmation()]
|
|
|
+ else:
|
|
|
+ read_data = [cardinal, self.olt.get_expected_exit_with_confirmation()]
|
|
|
with_confirmation = False
|
|
|
if read_data is not None:
|
|
|
position = self.read_data(read_data)
|
|
@@ -155,7 +173,7 @@ class ObjectTelnet(ObjectConnection):
|
|
|
self.command_print(command)
|
|
|
command = command.strip()
|
|
|
if "\\n" in command and (len(command) == 4 or len(command) == 2):
|
|
|
- print "Sendig ENTER \\r\\n"
|
|
|
+ print "Sending ENTER \\r\\n"
|
|
|
command = '\r\n'
|
|
|
else:
|
|
|
command = command.rstrip(self.NEW_LINE_WINDOWS).rstrip(self.NEW_LINE_UNIX)
|
|
@@ -164,8 +182,7 @@ class ObjectTelnet(ObjectConnection):
|
|
|
if self.debug:
|
|
|
print "Send: "
|
|
|
print command
|
|
|
- self.stdin.write(command + self.NEW_LINE_UNIX)
|
|
|
- self.stdin.flush()
|
|
|
+ self.tn.write(command + self.NEW_LINE_UNIX)
|
|
|
self.read_data(expected)
|
|
|
|
|
|
def read_data(self, expected):
|