Files
onefinity-firmware/scripts/check-config-vars.py
OneFinityCNC 24dfa6c64d Verison 1.0.3 Release
Based on Buildbotics 0.4.14
2020-08-27 23:20:27 -04:00

38 lines
835 B
Python

#!/usr/bin/env python3
'''Check that the configuration variable template used on the RPi matches the
variables used in the AVR'''
import sys
import json
templ = json.load(open('src/resources/config-template.json', 'r'))
vars = json.load(open('avr/build/vars.json', 'r'))
def check(section):
errors = 0
for name, entry in section.items():
if 'type' in entry:
ok = False
# TODO check that defaults are valid
# TODO check that types match
if 'code' in entry and not entry['code'] in vars:
print('"%s" with code "%s" not found' % (name, entry['code']))
else: ok = True
if not ok: errors += 1
else: errors += check(entry)
return errors
errors = check(templ)
print('\n%d errors' % errors)
sys.exit(errors != 0)