Exemple #1
0
 def ask(self, data, timeout=5):
     if self.legacy:
         print("Can't ask questions to legacy connections")
         return
     tok = essentials.CreateToken(20, self.__ask_list__)
     self.__ask_list__[tok] = False
     self.send({"function_ask_question": tok, "data": data})
     while self.__ask_list__[tok] == False:
         time.sleep(0.01)
         timeout -= 0.01
         if timeout <= 0:
             raise TimeoutError("No response within time.")
     copyed = copy.deepcopy(self.__ask_list__[tok])
     del self.__ask_list__[tok]
     return copyed['data']
Exemple #2
0
 def ask(self, data, timeout=5):
     if self.client_type == WEB_BASED:
         print(
             "WARNING: ask for Web Based Clients is not currently supported."
         )
         return False
     tok = essentials.CreateToken(20, self.__ask_list__)
     self.__ask_list__[tok] = False
     self.send({"function_ask_question": tok, "data": data})
     while self.__ask_list__[tok] == False:
         time.sleep(0.01)
         timeout -= 0.01
         if timeout <= 0:
             raise TimeoutError("No response within time.")
     copyed = copy.deepcopy(self.__ask_list__[tok])
     del self.__ask_list__[tok]
     return copyed['data']
Exemple #3
0
 def ask(self, data, timeout=5):
     if self.configuration.PYTHONIC != True:
         print("ERROR: Can't ask questions to non-Pythonic connections")
         return
     tok = essentials.CreateToken(20, self.__ask_list__)
     self.__ask_list__[tok] = False
     self.send({"function_ask_question": tok, "data": data})
     while self.__ask_list__[tok] == False and self.running == True:
         time.sleep(0.01)
         timeout -= 0.01
         if timeout <= 0:
             raise TimeoutError("No response within time.")
     if self.__ask_list__[tok] == False and self.running == False:
         raise ConnectionError(
             "We've been disconnected while waiting for a response")
     copyed = copy.deepcopy(self.__ask_list__[tok])
     del self.__ask_list__[tok]
     return copyed['data']