I am trying to save some run-time configurations to a text file using ujson module.
Configurations look like this.
Code: Select all
{"ARM": "0",
"T": "Test",
"P4": "phone4",
"C2": "disarm": "disarmed",
"P1": "phone1",
"A4": "alarm IN4",
"P3": "phone3",
"P2": "phone2",
"A1": "alarm IN1",
"A2": "alarm IN2",
"C1": "arm": "armed",
"D": "Reset OK",
"A3": "alarm IN3"}
Code: Select all
with open('config.txt','w')as f:
f.seek(0)
f.write(ujson.dumps(data))
f.flush()
os.sync()
Am I supposed to split the data into chunks and write to a file? I am also seeing NUL character is being added at the end of the data, so added f.seek(0) before writing to the file.
If I delete default boot.py and main.py and configuration files, it is creating boot.py only on hard reset. Some times even that boot.py only contains y symbols.
Thank you!