コード例 #1
0
ファイル: configtools.py プロジェクト: jolange/HappyFace
 def __getitem__(self, key):
     try:
         return dict.__getitem__(self, key)
     except IndexError:
         raise hf.ConfigError(
             "Required parameter '{0}' not specified".format(key))
     except KeyError:
         raise hf.ConfigError(
             "Required parameter '{0}' not specified".format(key))
コード例 #2
0
ファイル: __init__.py プロジェクト: jolange/HappyFace
def createCategoryObjects():
    '''
    Generates the category objects from the happyface configuration
    :return:
    :rtype:
    '''
    category_list = []
    used_modules = []
    category_names = hf.category.config.sections()
    if len(hf.config.get('happyface', 'categories')) > 0:
        category_names = hf.config.get('happyface', 'categories').split(',')
    for category in category_names:
        conf = hf.configtools.ConfigDict(hf.category.config.items(category))
        module_conf = {}
        for module in conf["modules"].split(","):
            try:
                if len(module) == 0:
                    continue
                if module in used_modules:
                    raise hf.ConfigError(
                        "Module '%s' used second time in category '%s'" %
                        (module, category))
                module_conf[module] = hf.configtools.ConfigDict(
                    hf.module.config.items(module))
                used_modules.append(module)
            except NoSectionError, e:
                msg = "Tried to use module '%s' in category '%s', but it was never mentioned in module configuration"
                raise hf.exceptions.ConfigError(msg % (module, category))
        category_list.append(
            hf.category.CategoryProxy(category, conf, module_conf))
コード例 #3
0
ファイル: module.py プロジェクト: jolange/HappyFace
def getModuleClass(mod_name):
    """
    Get the module class for a given module name.
    :param mod_name: Name of the module
    :ptype mod_name: string
    """
    if mod_name not in __module_class_list:
        raise hf.ConfigError("Module class {0} not found".format(mod_name))
    return __module_class_list[mod_name]
コード例 #4
0
ファイル: downloadservice.py プロジェクト: gregorv/HappyFace
 def __init__(self, download_command):
     try:
         self.download_command = download_command
         self.config_source, self.options, self.url = download_command.split("|")
         self.config_source = self.config_source.lower()
         if self.config_source == "global":
             self.options = ""
         self.tried_download = False
     except ValueError:
         raise hf.ConfigError("Download command string malformed")
     self.is_downloaded = False
     self.error = ""
     self.file_path = ""
     self.file_url = ""
     self.keep_tmp = False
     self.is_archived = False