]> www.average.org Git - loctrkd.git/blob - gps303/config.py
Use command line args and config more
[loctrkd.git] / gps303 / config.py
1 from configparser import ConfigParser
2
3 PORT = 4303
4 DBFN = "/var/lib/gps303/gps303.sqlite"
5
6 def readconfig(fname):
7     config = ConfigParser()
8     config["daemon"] = {
9         "port": PORT,
10         "dbfn": DBFN,
11     }
12     config["device"] = {}
13     #_print_config(config)
14     #print("now reading", fname)
15     config.read(fname)
16     #_print_config(config)
17     return config
18
19 def _print_config(conf):
20     for section in conf.sections():
21         print("section", section)
22         for option in conf.options(section):
23             print("    ", option, conf[section][option])
24
25 if __name__ == "__main__":
26     from sys import argv
27     conf = readconfig(argv[1])
28     _print_config(conf)
29     print("binaryswitch", int(conf.get("device", "binaryswitch"), 0))