from functools import wraps
from importlib import import_module
class CLISession(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
pass_session = click.make_pass_decorator(CLISession)
help="Changes the project folder location.",
help="Overrides a config key/value pair.",
"--keep", "-k", is_flag=True,
help="Keep local runtime, do not kill it after executing commands.",
@click.option("--verbose", "-v", is_flag=True, help="Enables verbose mode.")
"--buildpath", "-b", help="Where to store files created during build."
"--uri", "-u", help="URI to reach remote PLC."
@click.version_option("0.1")
"""Beremiz CLI manipulates beremiz projects and runtimes. """
ctx.obj = CLISession(**kwargs)
def ensure_controller(func):
def func_wrapper(session, *args, **kwargs):
if session.controller is None:
session.controller = import_module("CLIController").CLIController(session)
ret = func(session, *args, **kwargs)
"--target", "-t", help="Target system triplet."
def build(session, target):
return session.controller.build_project(target)
"""Transfer program to PLC runtim."""
return session.controller.transfer_project()
"""Run program already present in PLC. """
return session.controller.run_project()
"""Stop program running in PLC. """
return session.controller.stop_project()
return session.controller.connect_project()
def process_pipeline(session, processors, **kwargs):
for processor in processors:
click.echo("Command sequence aborted")
click.echo("Press Ctrl+C to quit")
session.controller.UpdateMethodsFromPLCStatus()
except KeyboardInterrupt:
session.controller.finish()
if __name__ == '__main__':