3
0

config.py 933 B

123456789101112131415161718192021222324
  1. # return a configuration objects with default values
  2. def myCar_read_config_defaults(config):
  3. import configparser
  4. if not config.sections():
  5. # there is nothing, lets setup default values
  6. config['paths'] = { 'app' : '/opt/myCar',
  7. 'log' : 'data/log',
  8. 'record' : 'data/rec' }
  9. config['connections'] = { 'bt_dev' : '/dev/rfcomm',
  10. 'gps_dev' : '/dev/ttyS1',
  11. 'wifi_pwd' : 'myCar123' }
  12. config['startup'] = { 'bt_connect' : True,
  13. 'autorecord' : True }
  14. # return a valid config object either
  15. # with or without default values
  16. return config
  17. def myCar_save_config(config):
  18. import configparser, logging
  19. with open('data/etc/myCar.conf', 'w') as configfile:
  20. config.write(configfile)
  21. logging.info('configuration saved')