Beremiz_cli.py
author Edouard Tisserant <edouard@beremiz.fr>
Thu, 25 Apr 2024 16:59:05 +0200
changeset 3935 bc51b5a2daa9
parent 3812 92e528718733
permissions -rw-r--r--
IDE: Fix crashing non-thread safe code using Zeroconf
3501
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/env python
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     3
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     4
import os
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     5
import posixpath
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     6
import sys
3548
da7b461f54b7 CLI: Explicitely wait for user interrupt (-k) and flush stdout each line.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3501
diff changeset
     7
import time
3618
f08b59f7c00a CLI: when using --keep, do not disconnect before being interrupted
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3548
diff changeset
     8
3501
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     9
from functools import wraps
3618
f08b59f7c00a CLI: when using --keep, do not disconnect before being interrupted
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3548
diff changeset
    10
from importlib import import_module
3501
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    11
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    12
import click
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    13
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    14
class CLISession(object):
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    15
    def __init__(self, **kwargs):
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    16
        self.__dict__.update(kwargs)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    17
        self.controller = None
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    18
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    19
pass_session = click.make_pass_decorator(CLISession)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    20
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    21
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    22
@click.group(chain=True)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    23
@click.option(
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    24
    "--project-home",
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    25
    envvar="PROJECT_HOME",
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    26
    default=".",
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    27
    metavar="PATH",
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    28
    help="Changes the project folder location.",
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    29
)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    30
@click.option(
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    31
    "--config",
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    32
    nargs=2,
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    33
    multiple=True,
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    34
    metavar="KEY VALUE",
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    35
    help="Overrides a config key/value pair.",
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    36
)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    37
@click.option(
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    38
    "--keep", "-k", is_flag=True,
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    39
    help="Keep local runtime, do not kill it after executing commands.",
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    40
)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    41
@click.option("--verbose", "-v", is_flag=True, help="Enables verbose mode.")
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    42
@click.option(
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    43
    "--buildpath", "-b", help="Where to store files created during build."
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    44
)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    45
@click.option(
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    46
    "--uri", "-u", help="URI to reach remote PLC."
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    47
)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    48
@click.version_option("0.1")
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    49
@click.pass_context
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    50
def cli(ctx, **kwargs):
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    51
    """Beremiz CLI manipulates beremiz projects and runtimes. """
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    52
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    53
    ctx.obj = CLISession(**kwargs)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    54
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    55
def ensure_controller(func):
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    56
    @wraps(func)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    57
    def func_wrapper(session, *args, **kwargs):
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    58
        if session.controller is None:
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    59
            session.controller = import_module("CLIController").CLIController(session)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    60
        ret = func(session, *args, **kwargs)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    61
        return ret
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    62
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    63
    return func_wrapper
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    64
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    65
@cli.command()
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    66
@click.option(
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    67
    "--target", "-t", help="Target system triplet."
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    68
)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    69
@pass_session
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    70
@ensure_controller
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    71
def build(session, target):
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    72
    """Builds project. """
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    73
    def processor():
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    74
        return session.controller.build_project(target)
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    75
    return processor
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    76
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    77
@cli.command()
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    78
@pass_session
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    79
@ensure_controller
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    80
def transfer(session):
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    81
    """Transfer program to PLC runtim."""
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    82
    def processor():
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    83
        return session.controller.transfer_project()
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    84
    return processor
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    85
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    86
@cli.command()
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    87
@pass_session
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    88
@ensure_controller
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    89
def run(session):
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    90
    """Run program already present in PLC. """
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    91
    def processor():
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    92
        return session.controller.run_project()
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    93
    return processor
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    94
3775
5780e7c13fd8 Add PLC stop command
GP Orcullo <kinsamanka@gmail.com>
parents: 3754
diff changeset
    95
@cli.command()
5780e7c13fd8 Add PLC stop command
GP Orcullo <kinsamanka@gmail.com>
parents: 3754
diff changeset
    96
@pass_session
5780e7c13fd8 Add PLC stop command
GP Orcullo <kinsamanka@gmail.com>
parents: 3754
diff changeset
    97
@ensure_controller
5780e7c13fd8 Add PLC stop command
GP Orcullo <kinsamanka@gmail.com>
parents: 3754
diff changeset
    98
def stop(session):
5780e7c13fd8 Add PLC stop command
GP Orcullo <kinsamanka@gmail.com>
parents: 3754
diff changeset
    99
    """Stop program running in PLC. """
5780e7c13fd8 Add PLC stop command
GP Orcullo <kinsamanka@gmail.com>
parents: 3754
diff changeset
   100
    def processor():
5780e7c13fd8 Add PLC stop command
GP Orcullo <kinsamanka@gmail.com>
parents: 3754
diff changeset
   101
        return session.controller.stop_project()
5780e7c13fd8 Add PLC stop command
GP Orcullo <kinsamanka@gmail.com>
parents: 3754
diff changeset
   102
    return processor
5780e7c13fd8 Add PLC stop command
GP Orcullo <kinsamanka@gmail.com>
parents: 3754
diff changeset
   103
3501
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   104
3754
98a76dbb1b6d updated click api
GP Orcullo <kinsamanka@gmail.com>
parents: 3618
diff changeset
   105
@cli.result_callback()
3501
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   106
@pass_session
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   107
def process_pipeline(session, processors, **kwargs):
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   108
    ret = 0
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   109
    for processor in processors:
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   110
        ret = processor()
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   111
        if ret != 0:
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   112
            if len(processors) > 1 :
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   113
                click.echo("Command sequence aborted")
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   114
            break
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   115
3548
da7b461f54b7 CLI: Explicitely wait for user interrupt (-k) and flush stdout each line.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3501
diff changeset
   116
    if session.keep:
da7b461f54b7 CLI: Explicitely wait for user interrupt (-k) and flush stdout each line.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3501
diff changeset
   117
        click.echo("Press Ctrl+C to quit")
3618
f08b59f7c00a CLI: when using --keep, do not disconnect before being interrupted
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3548
diff changeset
   118
        try:
f08b59f7c00a CLI: when using --keep, do not disconnect before being interrupted
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3548
diff changeset
   119
            while True:
3812
92e528718733 CLI: simpler status polling, fixing pyro5 thread
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3775
diff changeset
   120
                session.controller.UpdateMethodsFromPLCStatus()
92e528718733 CLI: simpler status polling, fixing pyro5 thread
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3775
diff changeset
   121
                time.sleep(0.5)
3618
f08b59f7c00a CLI: when using --keep, do not disconnect before being interrupted
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3548
diff changeset
   122
        except KeyboardInterrupt:
f08b59f7c00a CLI: when using --keep, do not disconnect before being interrupted
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3548
diff changeset
   123
            pass
f08b59f7c00a CLI: when using --keep, do not disconnect before being interrupted
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3548
diff changeset
   124
f08b59f7c00a CLI: when using --keep, do not disconnect before being interrupted
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3548
diff changeset
   125
    session.controller.finish()
3548
da7b461f54b7 CLI: Explicitely wait for user interrupt (-k) and flush stdout each line.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3501
diff changeset
   126
3501
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   127
    return ret
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   128
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   129
if __name__ == '__main__':
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   130
    cli()
fa291393aac7 Added preliminary CLI. Supports building a project, transfering and running on PLC.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   131