2020-05-20 13:52:38 +00:00
|
|
|
import json
|
|
|
|
import superscript as su
|
|
|
|
import threading
|
|
|
|
|
|
|
|
__author__ = (
|
|
|
|
"Arthur Lu <learthurgo@gmail.com>",
|
|
|
|
)
|
|
|
|
|
|
|
|
match = False
|
|
|
|
metric = False
|
|
|
|
pit = False
|
|
|
|
|
|
|
|
match_enable = True
|
|
|
|
metric_enable = True
|
|
|
|
pit_enable = True
|
|
|
|
|
|
|
|
config = {}
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
global match
|
|
|
|
global metric
|
|
|
|
global pit
|
|
|
|
|
|
|
|
global match_enable
|
|
|
|
global metric_enable
|
|
|
|
global pit_enable
|
|
|
|
|
2020-05-24 03:49:38 +00:00
|
|
|
global config
|
|
|
|
config = su.load_config("config.json")
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
task = threading.Thread(name = "match", target = match)
|
|
|
|
task.start()
|
|
|
|
task = threading.Thread(name = "match", target = metric)
|
|
|
|
task.start()
|
|
|
|
task = threading.Thread(name = "pit", target = pit)
|
|
|
|
task.start()
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
def match():
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
match = True
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
apikey = config["key"]["database"]
|
|
|
|
competition = config["competition"]
|
|
|
|
tests = config["statistics"]["match"]
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
data = su.load_match(apikey, competition)
|
|
|
|
su.matchloop(apikey, competition, data, tests)
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
match = False
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
if match_enable == True and match == False:
|
|
|
|
|
|
|
|
task = threading.Thread(name = "match", target = match)
|
|
|
|
task.start()
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
def metric():
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
metric = True
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
apikey = config["key"]["database"]
|
|
|
|
tbakey = config["key"]["tba"]
|
|
|
|
competition = config["competition"]
|
|
|
|
metric = config["statistics"]["metric"]
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
timestamp = su.get_previous_time(apikey)
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
su.metricloop(tbakey, apikey, competition, timestamp, metric)
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
metric = False
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
if metric_enable == True and metric == False:
|
|
|
|
|
|
|
|
task = threading.Thread(name = "match", target = metric)
|
|
|
|
task.start()
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
def pit():
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
pit = True
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
apikey = config["key"]["database"]
|
|
|
|
competition = config["competition"]
|
|
|
|
tests = config["statistics"]["pit"]
|
2020-05-20 13:52:38 +00:00
|
|
|
|
2020-05-24 00:43:59 +00:00
|
|
|
data = su.load_pit(apikey, competition)
|
|
|
|
su.pitloop(apikey, competition, data, tests)
|
|
|
|
|
|
|
|
pit = False
|
|
|
|
|
|
|
|
if pit_enable == True and pit == False:
|
|
|
|
|
|
|
|
task = threading.Thread(name = "pit", target = pit)
|
|
|
|
task.start()
|
2020-05-20 13:52:38 +00:00
|
|
|
|
|
|
|
task = threading.Thread(name = "main", target=main)
|
|
|
|
task.start()
|