Пример #1
0
    def findsc(sous_chef_dir):

        # internal sous chefs
        if incl_internal:
            for fp in recursive_listdir(SOUS_CHEF_DIR):
                if _is_config_file(fp):
                    sc = sous_chef_schema.load(fp)
                    if 'slug' in sc:
                        yield sc, fp

        # sous chef modules.
        if os.path.exists(sous_chef_dir):
            for fp in recursive_listdir(sous_chef_dir):
                if _is_config_file(fp):
                    sc = sous_chef_schema.load(fp)
                    if 'slug' in sc:
                        yield sc, fp
Пример #2
0
def run(config, **kw):
    """
    Programmatically execute a sous chef given configutations
    and recipe options. Will not load data back into NewsLynx. This can
    only be done via Recipes.
    """
    try:
        # load config file
        if not isinstance(config, types.DictType):
            if isinstance(config, basestring) and \
               (config.endswith('yaml') or config.endswith('json') or
                    config.endswith('yml')):
                config = sous_chef_schema.load(config)
            else:
                msg = 'Invalid input for config file: {}'.format(config)
                raise SousChefExecError(msg)
        else:
            config = sous_chef_schema.validate(config, None)

        # parse keyword arguments
        sc_opts = dict(
            org=kw.pop('org'),
            apikey=kw.pop('apikey'),
            passthrough=True,
            config=config
        )

        # format all other options as a recipe
        recipe = dict(
            status='stable',
            id=-1
        )
        recipe.update(kw)

        sc_opts['recipe'] = recipe_schema.validate(recipe, config)

        # import sous chef
        SC = from_import_path(config['runs'])

        # initialize it with kwargs and cook
        return SC(**sc_opts).run()

    # bubble up traceback.
    except:
        raise SousChefExecError(format_exc())
Пример #3
0
def run(config, **kw):
    """
    Programmatically execute a sous chef given configutations
    and recipe options. Will not load data back into NewsLynx. This can
    only be done via Recipes.
    """
    try:
        # load config file
        if not isinstance(config, types.DictType):
            if isinstance(config, basestring) and \
               (config.endswith('yaml') or config.endswith('json') or
                    config.endswith('yml')):
                config = sous_chef_schema.load(config)
            else:
                msg = 'Invalid input for config file: {}'.format(config)
                raise SousChefExecError(msg)
        else:
            config = sous_chef_schema.validate(config, None)

        # parse keyword arguments
        sc_opts = dict(org=kw.pop('org'),
                       apikey=kw.pop('apikey'),
                       passthrough=True,
                       config=config)

        # format all other options as a recipe
        recipe = dict(status='stable', id=-1)
        recipe.update(kw)

        sc_opts['recipe'] = recipe_schema.validate(recipe, config)

        # import sous chef
        SC = from_import_path(config['runs'])

        # initialize it with kwargs and cook
        return SC(**sc_opts).run()

    # bubble up traceback.
    except:
        raise SousChefExecError(format_exc())