def check(self): if not SYSTEM["monitor"]["SOURCE"]: message = "Black screen monitor is disable, check your config!" self.logger.warning(message) print message time.sleep(60) exit(0) try: profileBLL = ProfileBLL() data = profileBLL.get() if data["status"] == 200: profile_list = data["data"] else: self.logger.error(str(data["status"]) + " " + data["message"]) print "Error code: " + str(data["status"]) print data["message"] exit(1) # ancestor_thread_list = [] for profile in profile_list: while threading.activeCount() > profile['thread']: time.sleep(1) t = threading.Thread(target=self.check_source, args=( profile['protocol'] + '://' + profile['ip'], profile['status'], profile['id'], profile['agent'], profile['thread'], profile['name'], profile['type'], )) t.start() # ancestor_thread_list.append(t) # # Wait for all threads finish # # for ancestor_thread in ancestor_thread_list: # ancestor_thread.join() except Exception as e: self.logger.error(str(e)) print e finally: time.sleep(20)
def check(self): if not SYSTEM["monitor"]["BLACK_SCREEN"]: message = "Black screen monitor is disable, check your config!" self.logger.warning(message) print message time.sleep(60) exit(0) try: profileBLL = ProfileBLL() data = profileBLL.get_video_check_list() if data["status"] == 200: profile_list = data["data"] else: print "Error code: " + str(data["status"]) print data["message"] self.logger.error("Error code: " + str(data["status"]) + " " + data["message"]) exit(1) # ancestor_thread_list = [] for profile in profile_list: while threading.activeCount() > profile['thread']: time.sleep(1) check_video = VideoCheck( id=profile["id"], name=profile["name"], type=profile["type"], protocol=profile["protocol"], source=profile["ip"], last_status=profile["status"], last_video_status=profile["video_status"], agent=profile["agent"]) t = threading.Thread(target=check_video.check_video) t.start() """ ancestor_thread_list.append(t) Wait for all threads finish for ancestor_thread in ancestor_thread_list: ancestor_thread.join() """ time.sleep(60) except Exception as e: self.logger.error(e) print "Exception: " + str(e) time.sleep(10)
def update_data(self, ip): pf = ProfileBLL() ip = get_ip_from_ip_multicast(ip) data = pf.get_by_ip_multicast(ip) profile = None if data["status"] == 200: profile_list = data["data"] if len(profile_list): profile = profile_list[0] else: self.logger.error(str(data["status"]) + " " + data["message"]) time.sleep(5) data = pf.get_by_ip_multicast(ip) if data["status"] == 200: profile_list = data["data"] if len(profile_list): profile = profile_list[0] else: self.logger.error(str(data["status"]) + " " + data["message"]) return profile