Пример #1
0
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(script, clear = True):
 """
 Extends functionality with a Python script.
 
 Arguments:
  script - The script to load.
  clear - If True, triggers and enabled classes will be restored to defaults before the load is performed.
 """
 if clear:
  triggers.enabled_triggers = []
  triggers.literal_triggers = dict()
  triggers.disabled_triggers = set()
  triggers.enabled_classes = set()
 try:
  execfile(script, functions)
  application.update_config()
 except Exception as e:
  logger.exception(e)