Beispiel #1
0
        def index():
            logs_fancy = str()
            for log in self.logs:
                logs_fancy += "<p>" + log + "</p>\n"

            return page.format(client=self.name,
                               state=ClientStateToString(self.state),
                               style=style,
                               logs=logs_fancy)
Beispiel #2
0
 def run(self):
     import time
     threading.Thread(target=self.run_web, daemon=True).start()
     try:
         cnt = 0
         old_state = self.state
         while True:
             time.sleep(1)
             cnt += 1
             if self.state != old_state:
                 print("CLIENT {}".format(ClientStateToString(self.state)), flush=True)
             if cnt > 5:
                 print("CLIENT active", flush=True)
                 cnt = 0
     except KeyboardInterrupt:
         print("ok exiting..")
Beispiel #3
0
 def run(self):
     """ Main run loop. """
     #threading.Thread(target=self.run_web, daemon=True).start()
     try:
         cnt = 0
         old_state = self.state
         while True:
             time.sleep(1)
             cnt += 1
             if self.state != old_state:
                 print("{}:CLIENT in {} state".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S'), ClientStateToString(self.state)), flush=True)
             if cnt > 5:
                 print("{}:CLIENT active".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')), flush=True)
                 cnt = 0
             if not self._attached:
                 print("Detatched from combiner.", flush=True)
                 # TODO: Implement a check/condition to ulitmately close down if too many reattachment attepts have failed. s  
                 self._attach()
                 self._subscribe_to_combiner(self.config)
             if self.error_state:
                 return
     except KeyboardInterrupt:
         print("Ok, exiting..")