def time_start(): strt_time = pool_config.getConfig('pool', 'start_time') now = time.strftime('%H:%M:%S', time.localtime(time.time())) start = datetime.strptime(now, '%H:%M:%S') end = datetime.strptime(strt_time, '%H:%M:%S') sec = (end - start).seconds time_start = time.time() + sec return time_start
def pre_pool(): hour = pool_config.getConfig('pool', 'pool_hour') strt_sec = 600 if (int(hour) > 0): strt_sec = int(hour) * 60 * 60 tc = threading.Timer(strt_sec, pool.stop_in_pool, ("stop in pool data.", )) tc.start() sc = sched.scheduler(time_start, time.sleep) sc.enter(5, 1, pool.start_pool_send, ("start send message from pool.", )) sc.run()
def start(): if (len(sys.argv) < 3): capture_nc = pool_config.getConfig("config", 'nc') if (not capture_nc): print "error not have network card info" pool_log.error_log("error not have network card info") sys.exit(1) resent_ip = pool_config.getConfig("config", 'resent_ip') if (not resent_ip): print "error not have resent ip info" pool_log.error_log("error not have resent ip info") sys.exit(1) print "Start sender sever network card: %s resent ip: %s" % ( capture_nc, resent_ip) pool_log.log_info("Start sender sever network card: %s resent ip: %s" % (capture_nc, resent_ip)) count = pool_config.getConfig("config", 'count') port = pool_config.getConfig("config", 'port') if (count): if (port): capture_udp.capture(capture_nc, resent_ip, count, int(port)) else: capture_udp.capture(capture_nc, resent_ip, count) else: capture_udp.capture(capture_nc, resent_ip) else: capture_nc = sys.argv[1] resent_ip = sys.argv[2] print "Start pool sever network card: %s resent ip: %s" % (capture_nc, resent_ip) if (len(sys.argv) == 4): count = sys.argv[3] capture_udp.capture(capture_nc, resent_ip, count) elif (len(sys.argv) == 5): count = sys.argv[3] port = sys.argv[4] capture_udp.capture(capture_nc, resent_ip, count, port) else: capture_udp.capture(capture_nc, resent_ip)