summaryrefslogtreecommitdiff
path: root/voctogui/lib/config.py
blob: b18acfb803881a7364932bdc7eff5b4b232d426a (plain)
  1. #!/usr/bin/python3
  2. import logging
  3. import os.path
  4. from configparser import SafeConfigParser
  5. from lib.args import Args
  6. import lib.connection as Connection
  7. __all__ = ['Config']
  8. def getlist(self, section, option):
  9. return [x.strip() for x in self.get(section, option).split(',')]
  10. def fetchRemoteConfig(self):
  11. log = logging.getLogger('Config')
  12. log.info("reading server-config %s", Connection)
  13. Connection.ask('config')
  14. SafeConfigParser.getlist = getlist
  15. SafeConfigParser.fetchRemoteConfig = fetchRemoteConfig
  16. files = [
  17. os.path.join(os.path.dirname(os.path.realpath(__file__)), '../default-config.ini'),
  18. os.path.join(os.path.dirname(os.path.realpath(__file__)), '../config.ini'),
  19. '/etc/voctogui.ini',
  20. os.path.expanduser('~/.voctogui.ini'),
  21. ]
  22. if Args.ini_file is not None:
  23. files.append(Args.ini_file)
  24. Config = SafeConfigParser()
  25. Config.read(files)