Ejemplo n.º 1
0
def _load_agent_template(template_name):
    data_root = get_volttron_data()
    setup_path = os.path.join(data_root, AGENT_TEMPLATE_SETUP)
    agent_path = os.path.join(data_root, AGENT_TEMPLATE_PATH_TEMPLATE.format(name=template_name,
                                                                             file="agent.py_"))
    config_path = os.path.join(data_root, AGENT_TEMPLATE_PATH_TEMPLATE.format(name=template_name,
                                                                                file="config"))

    setup_template = None
    agent_template = None
    config_template = None

    try:
        with open(setup_path) as f:
            setup_template = f.read()

        with open(agent_path) as f:
            agent_template = f.read()

        with open(config_path) as f:
            config_template = f.read()
    except IOError as e:
        _log.error("Error loading template: {}".format(str(e)))
        sys.exit(1)

    return setup_template, agent_template, config_template
Ejemplo n.º 2
0
def _load_agent_template(template_name):
    data_root = get_volttron_data()
    setup_path = os.path.join(data_root, AGENT_TEMPLATE_SETUP)
    agent_path = os.path.join(
        data_root,
        AGENT_TEMPLATE_PATH_TEMPLATE.format(name=template_name,
                                            file="agent.py_"))
    config_path = os.path.join(
        data_root,
        AGENT_TEMPLATE_PATH_TEMPLATE.format(name=template_name, file="config"))

    setup_template = None
    agent_template = None
    config_template = None

    try:
        with open(setup_path) as f:
            setup_template = f.read()

        with open(agent_path) as f:
            agent_template = f.read()

        with open(config_path) as f:
            config_template = f.read()
    except IOError as e:
        _log.error("Error loading template: {}".format(str(e)))
        sys.exit(1)

    return setup_template, agent_template, config_template
Ejemplo n.º 3
0
def _get_agent_template_list():
    data_root = get_volttron_data()
    template_path = os.path.join(data_root, AGENT_TEMPLATE_PATH)
    return [
        o for o in os.listdir(template_path)
        if os.path.isdir(os.path.join(template_path, o))
    ]
Ejemplo n.º 4
0
def _get_agent_template_list():
    data_root = get_volttron_data()
    template_path = os.path.join(data_root, AGENT_TEMPLATE_PATH)
    return [o for o in os.listdir(template_path)
            if os.path.isdir(os.path.join(template_path,o))]