def quit_service(signum, sigframe): exit(143) signal(SIGTERM, quit_service) dbi = None dbs = None dbp = None if dbhost and office: dbi = DBIngest(index="sensors", office=office, host=dbhost) dbs = DBQuery(index="sensors", office=office, host=dbhost) dbp = DBQuery(index="provisions", office=office, host=dbhost) dbp.wait() def get_passcodes(ip, port): if office and dbhost: def _bucketize(query): r = dbp.bucketize(query, ["passcode"], size=1000) if "passcode" in r: return [k for k in r["passcode"] if r["passcode"][k]] return [] try: codes = _bucketize("passcode:* and ip={} and port={}".format( ip, port)) if codes: return codes
":sout=#gather:rtp{sdp=" + rtsp + ",port=" + str(rtp_port1) + "}", ":network-caching:1500", ":sout-all", ":sout-keep" ]) time.sleep(10) def quit_service(signum, sigframe): exit(143) signal(SIGTERM, quit_service) filters = [pattern for i in range(ncameras)] if dbhost and office: db = DBQuery(index="provisions", office=office, host=dbhost) db.wait() for r1 in db.search( "algorithm='{}' and office:[{},{}] and simfile:* and simsn:*". format(algorithm, office[0], office[1]), size=ncameras): m = re.search('[0-9]+$', r1["_source"]["simsn"]) if not m: continue i = int(m.group(0)) if i < ncameras: filters[i] = r1["_source"]["simfile"] files = list(os.listdir(simulated_root)) with ThreadPoolExecutor(ncameras) as e: k = random.randint(0, ncameras) for i in range(ncameras): files1 = [f for f in files if re.search(filters[i], f)] file = files1[(i + k) % len(files1)]