Compare commits
No commits in common. "5e899fca6204a5bba4d070b77aeea18d85e52f41" and "18f49c1a0ce79d76b37c5a05486f7dfbed90a33b" have entirely different histories.
5e899fca62
...
18f49c1a0c
@ -11,9 +11,6 @@ from pdf import format_m_s
|
|||||||
from rich import print
|
from rich import print
|
||||||
import search_tui
|
import search_tui
|
||||||
|
|
||||||
from rich.traceback import install
|
|
||||||
install(show_locals=True)
|
|
||||||
|
|
||||||
# Main entrypoint for now. Cli with two options; init will make the files needed and run will start the program from the specified directory
|
# Main entrypoint for now. Cli with two options; init will make the files needed and run will start the program from the specified directory
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='Otime very alpha version 😁')
|
parser = argparse.ArgumentParser(description='Otime very alpha version 😁')
|
||||||
@ -39,8 +36,6 @@ def main():
|
|||||||
parser_init.add_argument('--dir', required=False, dest='dir', action='store', default='./', help='specify a directory')
|
parser_init.add_argument('--dir', required=False, dest='dir', action='store', default='./', help='specify a directory')
|
||||||
parser_init.add_argument('--xml', required=False, dest='xml_path', action='store', default=None, help='Where the xml result file should be saved')
|
parser_init.add_argument('--xml', required=False, dest='xml_path', action='store', default=None, help='Where the xml result file should be saved')
|
||||||
|
|
||||||
parser_init = subparsers.add_parser('mtr', help='run mtr commands')
|
|
||||||
parser_init.add_argument('--port', required=False, dest='port', action='store', help='specify a serial port')
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@ -59,9 +54,6 @@ def main():
|
|||||||
search_tui.main(args.dir)
|
search_tui.main(args.dir)
|
||||||
case 'gen':
|
case 'gen':
|
||||||
gen(args.dir, args.xml_path)
|
gen(args.dir, args.xml_path)
|
||||||
case 'mtr':
|
|
||||||
mtr = serial.Serial(port=args.port, baudrate=9600, timeout=40)
|
|
||||||
mtr.write(b'/SA')
|
|
||||||
|
|
||||||
def init_dir(project_dir, entries_xml_file, courses_xml_file):
|
def init_dir(project_dir, entries_xml_file, courses_xml_file):
|
||||||
# Lager mappe med en config fil, en csv fil med løpere og en fil med mtr data
|
# Lager mappe med en config fil, en csv fil med løpere og en fil med mtr data
|
||||||
@ -116,6 +108,7 @@ def gen(project_dir='./', xml_path='./output/'):
|
|||||||
mtr_path = project_dir + '/mtr.yaml'
|
mtr_path = project_dir + '/mtr.yaml'
|
||||||
csv_path = project_dir + '/runners.csv'
|
csv_path = project_dir + '/runners.csv'
|
||||||
event = file_io.event_from_yaml_and_csv(config_path, mtr_path, csv_path)
|
event = file_io.event_from_yaml_and_csv(config_path, mtr_path, csv_path)
|
||||||
|
file_io.write_card_dumps(event, mtr_path)
|
||||||
subprocess.run(['git', 'add', './*'], cwd=project_dir, stdout=subprocess.DEVNULL)
|
subprocess.run(['git', 'add', './*'], cwd=project_dir, stdout=subprocess.DEVNULL)
|
||||||
subprocess.run(['git', 'commit', '-m', f'Manually run'], cwd=project_dir, stdout=subprocess.DEVNULL)
|
subprocess.run(['git', 'commit', '-m', f'Manually run'], cwd=project_dir, stdout=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
@ -40,12 +40,6 @@ def event_from_yaml_and_csv(config_path, mtr_path, csv_path):
|
|||||||
data = [i.split(';') for i in f.readlines()]
|
data = [i.split(';') for i in f.readlines()]
|
||||||
data.pop(0)
|
data.pop(0)
|
||||||
for i in data: i[2] = i[2].split(',')
|
for i in data: i[2] = i[2].split(',')
|
||||||
for i in data:
|
|
||||||
# Setter starttid til None hvis den ikke er satt
|
|
||||||
if len(i[7]) > 8:
|
|
||||||
i[7] = i[7]
|
|
||||||
else:
|
|
||||||
i[7] = None
|
|
||||||
runners = [otime.Runner(id=i[0], status_override=i[1], first=i[2][0], last=i[2][1].strip(), o_class=i[3], club=i[4], card_id=int(i[5]), fork=int(i[6]), start_time=i[7]) for i in data]
|
runners = [otime.Runner(id=i[0], status_override=i[1], first=i[2][0], last=i[2][1].strip(), o_class=i[3], club=i[4], card_id=int(i[5]), fork=int(i[6]), start_time=i[7]) for i in data]
|
||||||
event.card_dumps = card_dumps
|
event.card_dumps = card_dumps
|
||||||
event.runners = runners
|
event.runners = runners
|
||||||
|
@ -30,9 +30,6 @@ def create_result_file(event, file_path, o_classes=[]):
|
|||||||
# <PersonResult>
|
# <PersonResult>
|
||||||
|
|
||||||
for n in i.runner_results:
|
for n in i.runner_results:
|
||||||
if n.status == 'DidNotStart':
|
|
||||||
continue
|
|
||||||
|
|
||||||
person_result = ET.SubElement(class_result, 'PersonResult')
|
person_result = ET.SubElement(class_result, 'PersonResult')
|
||||||
# <Person>
|
# <Person>
|
||||||
person = ET.SubElement(person_result, 'Person')
|
person = ET.SubElement(person_result, 'Person')
|
||||||
@ -67,14 +64,14 @@ def create_result_file(event, file_path, o_classes=[]):
|
|||||||
xml_child(result, 'Status', n.status)
|
xml_child(result, 'Status', n.status)
|
||||||
# <SplitTime>
|
# <SplitTime>
|
||||||
# TODO: ta utgangspunkt i løypa, ikke det brikka har stempla
|
# TODO: ta utgangspunkt i løypa, ikke det brikka har stempla
|
||||||
for code, split in zip(i.course.codes[n.fork][:-1], n.splits[:-1]):
|
for code, split in zip(i.course.codes[n.fork], n.splits):
|
||||||
st = ET.SubElement(result, 'SplitTime')
|
st = ET.SubElement(result, 'SplitTime')
|
||||||
xml_child(st, 'ControlCode', code)
|
xml_child(st, 'ControlCode', code)
|
||||||
xml_child(st, 'Time', split)
|
xml_child(st, 'Time', split)
|
||||||
# </SplitTime>
|
# </SplitTime>
|
||||||
elif n.status == 'MissingPunch':
|
elif n.status == 'MissingPunch':
|
||||||
xml_child(result, 'Status', n.status)
|
xml_child(result, 'Status', n.status)
|
||||||
for code, split in zip(i.course.codes[n.fork][:-1], n.splits[:-1]):
|
for code, split in zip(i.course.codes[n.fork], n.splits):
|
||||||
st = ET.SubElement(result, 'SplitTime')
|
st = ET.SubElement(result, 'SplitTime')
|
||||||
xml_child(st, 'ControlCode', code)
|
xml_child(st, 'ControlCode', code)
|
||||||
if split != 0: xml_child(st, 'Time', split)
|
if split != 0: xml_child(st, 'Time', split)
|
||||||
|
@ -291,19 +291,8 @@ class Event:
|
|||||||
|
|
||||||
f_control = course.codes[runner.fork][-1]
|
f_control = course.codes[runner.fork][-1]
|
||||||
# TODO: Må gjøres mer robust
|
# TODO: Må gjøres mer robust
|
||||||
if f_control not in card_dump.controls:
|
|
||||||
# Hvis løperen ikke har vært på sistepost tar vi siste stempling istedet
|
|
||||||
return card_dump.splits[-1]
|
|
||||||
index = card_dump.controls.index(f_control)
|
index = card_dump.controls.index(f_control)
|
||||||
# Hvis løperen ikke har en startid spesifisert brukes brikketid
|
return card_dump.splits[index]
|
||||||
if runner.start_time is None:
|
|
||||||
return card_dump.splits[index]
|
|
||||||
#Hvis det er en startid finner jeg tidsforskjellen mellom brikkestart og faktisk start og trekker den fra totaltida
|
|
||||||
else:
|
|
||||||
time_list = runner.start_time.split(':') # hour, minute, second
|
|
||||||
start_datetime = self.start_time.replace(hour=int(time_list[0]), minute=int(time_list[1]), second=int(time_list[2]))
|
|
||||||
diff = start_datetime - card_dump.s_time
|
|
||||||
return card_dump.splits[index] - diff.total_seconds()
|
|
||||||
|
|
||||||
def get_runner_splits(self, id):
|
def get_runner_splits(self, id):
|
||||||
# Tida brukt frem til hver post, ikke tida fra forrige post
|
# Tida brukt frem til hver post, ikke tida fra forrige post
|
||||||
|
Loading…
Reference in New Issue
Block a user