La til gen kommando
This commit is contained in:
parent
f1612cf838
commit
a39c5e4615
30
otime/cli.py
30
otime/cli.py
@ -28,22 +28,32 @@ def main():
|
|||||||
parser_init.add_argument('--port', required=False, dest='port', action='store', help='specify a serial port')
|
parser_init.add_argument('--port', required=False, dest='port', action='store', help='specify a serial port')
|
||||||
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('viewer', help='View otime data')
|
parser_init = subparsers.add_parser('gen', help='Generate result files')
|
||||||
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('view', help='View otime data')
|
||||||
|
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')
|
||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if not args.xml_path:
|
try:
|
||||||
args.xml_path = args.dir + '/output'
|
if not args.xml_path:
|
||||||
|
args.xml_path = args.dir + '/output'
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
match args.command:
|
match args.command:
|
||||||
case 'init':
|
case 'init':
|
||||||
init_dir(args.dir, args.entries_file, args.courses_file)
|
init_dir(args.dir, args.entries_file, args.courses_file)
|
||||||
case 'run':
|
case 'run':
|
||||||
run(args.port, args.dir, args.xml_path)
|
run(args.port, args.dir, args.xml_path)
|
||||||
case 'viewer':
|
case 'view':
|
||||||
search_tui.main(args.dir)
|
search_tui.main(args.dir)
|
||||||
|
case 'gen':
|
||||||
|
gen(args.dir, args.xml_path)
|
||||||
|
|
||||||
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
|
||||||
@ -93,6 +103,18 @@ def run(port='/dev/ttyUSB0', project_dir='./', xml_path='./output/'):
|
|||||||
meat = mtr.read(55)
|
meat = mtr.read(55)
|
||||||
inspect(status)
|
inspect(status)
|
||||||
|
|
||||||
|
def gen(project_dir='./', xml_path='./output/'):
|
||||||
|
config_path = project_dir + '/config.yaml'
|
||||||
|
mtr_path = project_dir + '/mtr.yaml'
|
||||||
|
csv_path = project_dir + '/runners.csv'
|
||||||
|
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', 'commit', '-m', f'Manually run'], cwd=project_dir, stdout=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
iof_xml.create_result_file(event, xml_path + '/results.xml')
|
||||||
|
pdf.create_result_list(event, project_dir + '/output/results.pdf')
|
||||||
|
|
||||||
def runner_info(event, card_dump):
|
def runner_info(event, card_dump):
|
||||||
runner = next((i for i in event.runners if str(i.card_id) == str(card_dump.card)), None)
|
runner = next((i for i in event.runners if str(i.card_id) == str(card_dump.card)), None)
|
||||||
if runner is None:
|
if runner is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user