Beispiel #1
0
def update_db():
    db = database()
    for filepath in DEVICE_DIR.walkfiles('*.json'):
        with open(filepath) as f:
            print "Reading {0}".format(filepath)
            data = f.read()
            json_dict = json.loads(data)
            # TODO: should check device here to see if it is valid
            db['devices'].update({'type': json_dict['type']},json_dict,upsert=True)
Beispiel #2
0
def check_devices(dont_stop=True):
    for filepath in DEVICE_DIR.walkfiles('*.json'):
        try:
            check_device(filepath)
        except Exception as e:
            print traceback.print_exc()
            print "Failed device check"
            if dont_stop:
                continue
            else:
                raise e