示例#1
0
def configure_loggers(name=None):
    # first off, configure defaults
    # to enable the use of the logger
    # even before the init was executed.
    _name = name if name else __name__
    _configure_defaults(name=_name)

    from aria_core import utils
    if utils.is_initialized():
        # init was already called
        # use the configuration file.
        _configure_from_file()

    return logging.getLogger(name=name if name else __name__)
示例#2
0
def init(blueprint_id,
         blueprint_path,
         inputs,
         install_plugins_):
    print("Staring blueprint initialization.")
    aria_api = api.AriaCoreAPI()
    if os.path.isdir(utils.storage_dir(blueprint_id)):
        shutil.rmtree(utils.storage_dir(blueprint_id))

    if not utils.is_initialized():
        aria_cli.init(reset_config=False, skip_logging=True)

    try:
        if install_plugins_:
            requirements = aria_api.blueprints.create_requirements(
                blueprint_path=blueprint_path
            )
            print_utils.print_dict({'requirements': '\n'.join(requirements)})
        aria_api.blueprints.initialize(
            blueprint_id,
            blueprint_path,
            inputs=inputs,
            install_plugins=install_plugins_,
        )
    except BaseException as e:
        e.possible_solutions = [
            "Run 'aria init --install-plugins -p {0} -b {1}'"
            .format(blueprint_path,
                    blueprint_id)
        ]
        LOG.exception(str(e))
        print(str(e))
        raise e

    msg = (
        "Initiated {0}\nIf you make changes to the "
        "blueprint, "
        "Run 'aria init -b {1} -p {0}' "
        "again to apply them"
        .format(blueprint_path, blueprint_id))
    LOG.info(msg)
    print(msg)