kutu/pyirsdk

Feature Requests

zane-shus opened this issue · 1 comments

Would I be able to request two features for this:

  1. Different exit code from running irsdk.py --parse output.yaml
    successfully =0
    unsuccessfully = 1 (if there is a error (like when Sim is not running) )

  2. Option to output as JSON instead of YAML

ta

kutu commented
import irsdk
import json
from pathlib import Path
from pprint import pp

test_file = None
# test_file = 'your_file.bin'

ir = irsdk.IRSDK()

if test_file:
    ir.startup(test_file=test_file)
else:
    ir.startup()
    if not ir.is_connected:
        exit(1)

try:
    params = set([
            'CameraInfo',
            'CarSetup',
            'DriverInfo',
            'QualifyResultsInfo',
            'RadioInfo',
            'SessionInfo',
            'SplitTimeInfo',
            'WeekendInfo',
        ] + ir.var_headers_names
    )
    # pp(params)

    data = {p: ir[p] for p in params}
    # pp(json.dumps(data))

    json.dump(data, Path('parsed.json').open('w'))
except:
    exit(1)