Sfoglia il codice sorgente

Fix fiberhome connection close

gabriel 6 anni fa
parent
commit
c1db3715a7
3 ha cambiato i file con 19 aggiunte e 9 eliminazioni
  1. 5 1
      FiberHome.py
  2. 3 0
      OLTBase.py
  3. 11 8
      ObjectTelnet.py

+ 5 - 1
FiberHome.py

@@ -12,10 +12,14 @@ class FiberHome(OLTBase):
         return "Password:"
 
     def get_write_exit(self):
-        return "quit"
+        return "exit"
 
     def run_enable(self):
         return True
 
     def get_character_error(self):
         return "%"
+
+    def get_expected_exit_with_confirmation(self):
+        return "Bye!"
+

+ 3 - 0
OLTBase.py

@@ -36,6 +36,9 @@ class OLTBase:
     def get_expected_exit(self):
         return None
 
+    def get_expected_exit_with_confirmation(self):
+        return None
+
     def get_write_exit_confirmation(self):
         return None
 

+ 11 - 8
ObjectTelnet.py

@@ -112,18 +112,21 @@ class ObjectTelnet(ObjectConnection):
         """
         if command.lower() == self.olt.get_write_exit().lower():
             self.tn.write(self.olt.get_write_exit() + self.NEW_LINE_UNIX)
+            read_data = None
+            with_confirmation = False
             if self.olt.get_expected_exit() is not None:
-                # data = self.tn.read_all()
-                position = self.read_data([self.olt.get_expected_cardinal(), self.olt.get_expected_exit()])
+                read_data = [self.olt.get_expected_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()]
+                with_confirmation = False
+            if read_data is not None:
+                position = self.read_data(read_data)
                 if position == 2:
                     # quit terminal
-                    self.tn.write(self.olt.get_write_exit_confirmation() + self.NEW_LINE_UNIX)
+                    if with_confirmation:
+                        self.tn.write(self.olt.get_write_exit_confirmation() + self.NEW_LINE_UNIX)
                     self.QUIT = False
-                # (i, obj, data) = self.tn.expect([self.olt.get_expected_cardinal(), self.olt.get_expected_exit()], 10)
-                # if self.olt.get_expected_exit() in data:
-                    # # quit terminal
-                    # self.tn.write(self.olt.get_write_exit_confirmation() + self.NEW_LINE_UNIX)
-                    # self.QUIT = False
             return True
         return False