예제 #1
0
파일: config.py 프로젝트: chrisnorman7/mmc2
def load():
 if application.get_host() and os.path.isdir(config_dir):
  config_file = os.path.join(config_dir, make_filename())
  try:
   logger.info("Loading configuration data from %s.", config_file)
   with open(config_file, "r") as f:
    c = application.create_config()
    parse_json(c, json.load(f), create_sections = True, create_options = True)
    application.config = c
    application.config_file = config_file
    application.update_config()
  except IOError:
   logger.warning("No configuration file could be read.")
  except ValueError as v:
   logger.exception(e)
예제 #2
0
def load_config():
 if os.path.isfile(config_file):
  with open(config_file, 'rb') as f:
   try:
    j = json.load(f)
    library.downloaded = j.get('library', {})
    if type(library.downloaded) != dict:
     library.downloaded = {} # Better to clear the user's library than have them suffer tracebacks.
    device_id = j.get('device_id', None)
    s = j.get('streams', streams)
    while streams:
     del streams[0]
    for x in s:
     streams.append(s)
    parser.parse_json(_config.config, j.get('config', {}))
    config.update(**j)
   except ValueError as e:
      wx.MessageBox('Error in config file: %s. Resetting preferences.' % e.message, 'Config Error') # They've broken their config file.
예제 #3
0
def load_config():
    if os.path.isfile(config_file):
        with open(config_file, 'rb') as f:
            try:
                j = json.load(f)
                library.downloaded = j.get('library', {})
                if type(library.downloaded) != dict:
                    library.downloaded = {
                    }  # Better to clear the user's library than have them suffer tracebacks.
                device_id = j.get('device_id', None)
                s = j.get('streams', streams)
                while streams:
                    del streams[0]
                for x in s:
                    streams.append(s)
                parser.parse_json(_config.config, j.get('config', {}))
                config.update(**j)
            except ValueError as e:
                wx.MessageBox(
                    'Error in config file: %s. Resetting preferences.' %
                    e.message,
                    'Config Error')  # They've broken their config file.