Fix config.py: remove dead code after main(), fix work_place key, remove idmasa.txt write
This commit is contained in:
18
config.py
18
config.py
@@ -43,7 +43,7 @@ def _read_config():
|
|||||||
p = configparser.ConfigParser()
|
p = configparser.ConfigParser()
|
||||||
p.read(CONFIG_PATH)
|
p.read(CONFIG_PATH)
|
||||||
return {
|
return {
|
||||||
"device_name": p.get("device", "name", fallback="notconfig"),
|
"device_name": p.get("device", "work_place", fallback="notconfig"),
|
||||||
"hostname": p.get("device", "hostname", fallback=socket.gethostname()),
|
"hostname": p.get("device", "hostname", fallback=socket.gethostname()),
|
||||||
"device_ip": p.get("device", "ip", fallback=_get_local_ip()),
|
"device_ip": p.get("device", "ip", fallback=_get_local_ip()),
|
||||||
"location": p.get("device", "location", fallback=""),
|
"location": p.get("device", "location", fallback=""),
|
||||||
@@ -80,7 +80,7 @@ def _write_config(cfg):
|
|||||||
p.set("server", "internet_check_host", cfg.get("internet_check_host", ""))
|
p.set("server", "internet_check_host", cfg.get("internet_check_host", ""))
|
||||||
|
|
||||||
p.add_section("device")
|
p.add_section("device")
|
||||||
p.set("device", "name", cfg["device_name"])
|
p.set("device", "work_place", cfg["device_name"])
|
||||||
p.set("device", "hostname", cfg["hostname"])
|
p.set("device", "hostname", cfg["hostname"])
|
||||||
p.set("device", "ip", cfg["device_ip"])
|
p.set("device", "ip", cfg["device_ip"])
|
||||||
p.set("device", "location", cfg.get("location", ""))
|
p.set("device", "location", cfg.get("location", ""))
|
||||||
@@ -97,10 +97,6 @@ def _write_config(cfg):
|
|||||||
f.write(f"# Last updated by config.py: {now_ts}\n\n")
|
f.write(f"# Last updated by config.py: {now_ts}\n\n")
|
||||||
p.write(f)
|
p.write(f)
|
||||||
|
|
||||||
# Keep legacy idmasa.txt in sync for older code paths
|
|
||||||
with open("./data/idmasa.txt", "w") as f:
|
|
||||||
f.write(cfg["device_name"])
|
|
||||||
|
|
||||||
print(f"✓ config.txt saved (last_synced={now_ts})")
|
print(f"✓ config.txt saved (last_synced={now_ts})")
|
||||||
|
|
||||||
|
|
||||||
@@ -268,16 +264,6 @@ def main():
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
window.close()
|
|
||||||
# daca variabila nook este 1
|
|
||||||
time.sleep(2)
|
|
||||||
if n_config == 0:
|
|
||||||
os.system("sudo reboot now")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user