From dea5f3a37456c02b222052a62e80efc50670d3ff Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 10 Oct 2021 06:15:22 +0000 Subject: [PATCH] implemented event delay with dummy listener, event delay listener in data.py unimplemented --- src/cli/data.py | 6 +++++- src/cli/superscript.py | 23 ++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/cli/data.py b/src/cli/data.py index e5bfb5b..926b589 100644 --- a/src/cli/data.py +++ b/src/cli/data.py @@ -185,4 +185,8 @@ def push_pit(apikey, competition, pit): for variable in pit: - push_team_pit_data(apikey, competition, variable, pit[variable]) \ No newline at end of file + push_team_pit_data(apikey, competition, variable, pit[variable]) + +def check_new_database_matches(client, competition): + + return True \ No newline at end of file diff --git a/src/cli/superscript.py b/src/cli/superscript.py index c10b09a..f8859a5 100644 --- a/src/cli/superscript.py +++ b/src/cli/superscript.py @@ -158,7 +158,7 @@ import warnings import websockets from interface import splash, log, ERR, INF, stdout, stderr -from data import get_previous_time, set_current_time, load_match, push_match, load_pit, push_pit +from data import get_previous_time, set_current_time, load_match, push_match, load_pit, push_pit, check_new_database_matches from processing import matchloop, metricloop, pitloop config_path = "config.json" @@ -207,7 +207,7 @@ sample_json = """{ "attitude":true } }, - "even-delay":false, + "event-delay":false, "loop-delay":60 }""" @@ -383,11 +383,20 @@ def main(send, verbose = False, profile = False): set_current_time(client, current_time) send(stdout, INF, "finished all tests in " + str(time.time() - loop_start) + " seconds, looping") - loop_delay = float(config["loop-delay"]) - remaining_time = loop_delay - (time.time() - loop_start) - if remaining_time > 0: - send(stdout, INF, "loop delayed by " + str(remaining_time) + " seconds") - time.sleep(remaining_time) + event_delay = config["event-delay"] + if event_delay: + send(stdout, INF, "loop delayed until database returns new matches") + new_match = False + while not new_match: + time.sleep(1) + new_match = check_new_database_matches(client, competition) + send(stdout, INF, "database returned new matches") + else: + loop_delay = float(config["loop-delay"]) + remaining_time = loop_delay - (time.time() - loop_start) + if remaining_time > 0: + send(stdout, INF, "loop delayed by " + str(remaining_time) + " seconds") + time.sleep(remaining_time) except KeyboardInterrupt: send(stdout, INF, "detected KeyboardInterrupt, killing threads")