mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-12-26 01:29:10 +00:00
moved core functions in tasks.py to class Tasker
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
236c28c3be
commit
8a212a21df
@ -6,105 +6,116 @@ __author__ = (
|
|||||||
"Arthur Lu <learthurgo@gmail.com>",
|
"Arthur Lu <learthurgo@gmail.com>",
|
||||||
)
|
)
|
||||||
|
|
||||||
match_ = False
|
class Tasker():
|
||||||
metric_ = False
|
|
||||||
pit_ = False
|
|
||||||
|
|
||||||
match_enable = True
|
|
||||||
metric_enable = True
|
|
||||||
pit_enable = True
|
|
||||||
|
|
||||||
config = {}
|
|
||||||
|
|
||||||
def init():
|
|
||||||
|
|
||||||
global match_
|
|
||||||
global metric_
|
|
||||||
global pit_
|
|
||||||
|
|
||||||
global match_enable
|
|
||||||
global metric_enable
|
|
||||||
global pit_enable
|
|
||||||
|
|
||||||
global config
|
|
||||||
config = su.load_config("config.json")
|
|
||||||
|
|
||||||
def match():
|
|
||||||
|
|
||||||
match_ = True
|
|
||||||
|
|
||||||
apikey = config["key"]["database"]
|
|
||||||
competition = config["competition"]
|
|
||||||
tests = config["statistics"]["match"]
|
|
||||||
|
|
||||||
data = su.load_match(apikey, competition)
|
|
||||||
su.matchloop(apikey, competition, data, tests)
|
|
||||||
|
|
||||||
match_ = False
|
match_ = False
|
||||||
|
metric_ = False
|
||||||
|
pit_ = False
|
||||||
|
|
||||||
if match_enable == True and match_ == False:
|
match_enable = True
|
||||||
|
metric_enable = True
|
||||||
|
pit_enable = True
|
||||||
|
|
||||||
|
config = {}
|
||||||
|
|
||||||
|
def __init__():
|
||||||
|
|
||||||
|
config = su.load_config("config.json")
|
||||||
|
|
||||||
|
def match():
|
||||||
|
|
||||||
|
match_ = True
|
||||||
|
|
||||||
|
apikey = config["key"]["database"]
|
||||||
|
competition = config["competition"]
|
||||||
|
tests = config["statistics"]["match"]
|
||||||
|
|
||||||
|
data = su.load_match(apikey, competition)
|
||||||
|
su.matchloop(apikey, competition, data, tests)
|
||||||
|
|
||||||
|
match_ = False
|
||||||
|
|
||||||
|
if match_enable == True and match_ == False:
|
||||||
|
|
||||||
|
task = threading.Thread(name = "match", target = match)
|
||||||
|
task.start()
|
||||||
|
|
||||||
|
def metric():
|
||||||
|
|
||||||
|
metric_ = True
|
||||||
|
|
||||||
|
apikey = config["key"]["database"]
|
||||||
|
tbakey = config["key"]["tba"]
|
||||||
|
competition = config["competition"]
|
||||||
|
metric = config["statistics"]["metric"]
|
||||||
|
|
||||||
|
timestamp = su.get_previous_time(apikey)
|
||||||
|
|
||||||
|
su.metricloop(tbakey, apikey, competition, timestamp, metric)
|
||||||
|
|
||||||
|
metric_ = False
|
||||||
|
|
||||||
|
if metric_enable == True and metric_ == False:
|
||||||
|
|
||||||
|
task = threading.Thread(name = "match", target = metric)
|
||||||
|
task.start()
|
||||||
|
|
||||||
|
def pit():
|
||||||
|
|
||||||
|
pit_ = True
|
||||||
|
|
||||||
|
apikey = config["key"]["database"]
|
||||||
|
competition = config["competition"]
|
||||||
|
tests = config["statistics"]["pit"]
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
def start_match():
|
||||||
task = threading.Thread(name = "match", target = match)
|
task = threading.Thread(name = "match", target = match)
|
||||||
task.start()
|
task.start()
|
||||||
|
|
||||||
def metric():
|
def start_metric():
|
||||||
|
|
||||||
metric_ = True
|
|
||||||
|
|
||||||
apikey = config["key"]["database"]
|
|
||||||
tbakey = config["key"]["tba"]
|
|
||||||
competition = config["competition"]
|
|
||||||
metric = config["statistics"]["metric"]
|
|
||||||
|
|
||||||
timestamp = su.get_previous_time(apikey)
|
|
||||||
|
|
||||||
su.metricloop(tbakey, apikey, competition, timestamp, metric)
|
|
||||||
|
|
||||||
metric_ = False
|
|
||||||
|
|
||||||
if metric_enable == True and metric_ == False:
|
|
||||||
|
|
||||||
task = threading.Thread(name = "match", target = metric)
|
task = threading.Thread(name = "match", target = metric)
|
||||||
task.start()
|
task.start()
|
||||||
|
|
||||||
def pit():
|
def start_pit():
|
||||||
|
|
||||||
pit_ = True
|
|
||||||
|
|
||||||
apikey = config["key"]["database"]
|
|
||||||
competition = config["competition"]
|
|
||||||
tests = config["statistics"]["pit"]
|
|
||||||
|
|
||||||
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 = threading.Thread(name = "pit", target = pit)
|
||||||
task.start()
|
task.start()
|
||||||
|
|
||||||
def start_match():
|
def stop_match():
|
||||||
task = threading.Thread(name = "match", target = match)
|
match_enable = False
|
||||||
task.start()
|
|
||||||
|
|
||||||
def start_metric():
|
def stop_metric():
|
||||||
task = threading.Thread(name = "match", target = metric)
|
metric_enable = False
|
||||||
task.start()
|
|
||||||
|
|
||||||
def start_pit():
|
def stop_pit():
|
||||||
task = threading.Thread(name = "pit", target = pit)
|
pit_enable = False
|
||||||
task.start()
|
|
||||||
|
|
||||||
def stop_match():
|
def get_match():
|
||||||
match_enable = False
|
return match_
|
||||||
|
|
||||||
def stop_metric():
|
def get_metric():
|
||||||
metric_enable = False
|
return metric_
|
||||||
|
|
||||||
def stop_pit():
|
def get_pit():
|
||||||
pit_enable = False
|
return pit_
|
||||||
|
|
||||||
|
def get_match_enable():
|
||||||
|
return match_enable
|
||||||
|
|
||||||
|
def get_metric_enable():
|
||||||
|
return metric_enable
|
||||||
|
|
||||||
|
def get_pit_enable():
|
||||||
|
return pit_enable
|
||||||
"""
|
"""
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user