Exemplo n.º 1
0
def list(item_type, **kwargs):
    """
    List all available items of a specified type.

    :param item_type: experiment/campaign
    """
    data, title = [['Name']], None
    if item_type == 'experiments':
        title = 'Available experiments'
        data.extend([['- {}'.format(x).ljust(25)] for x in list_experiments()])
    elif item_type == 'campaigns':
        title = 'Available campaigns'
        data.extend([['- {}'.format(x).ljust(25)] for x in list_campaigns()])
    if title is not None:
        table = SingleTable(data, title)
        print(table.table)
Exemplo n.º 2
0
def list(item_type, **kwargs):
    """
    List all available items of a specified type.

    :param item_type: experiment/campaign
    """
    data, title = [['Name']], None
    if item_type == 'experiments':
        title = 'Available experiments'
        data.extend([['- {}'.format(x).ljust(25)] for x in list_experiments()])
    elif item_type == 'campaigns':
        title = 'Available campaigns'
        data.extend([['- {}'.format(x).ljust(25)] for x in list_campaigns()])
    if title is not None:
        table = SingleTable(data, title)
        print(table.table)
Exemplo n.º 3
0
    :param not_exists: a tuple with the name of an argument to be checked for non-existence and a dictionary with up to
                        4 keys: 'loglvl' which indicates the log level for the message, 'msg' the message itself, 'ask'
                        for asking the user for confirmation to continue and 'confirm' the message to be displayed
                        when asking for confirmation
    :param exists: same structure as for 'not_exists' but handling existence instead
    :param start_msg: message to be displayed before calling 'f'
    :param reexec_on_emptyline: boolean indicating if the command is to be re-executed when an empty line is
                                 input in the console
    :param __base__: special parameter to be used if the command is to be multi-processed, it holds the
                      "monitored" version of the command (that is, encapsulated inside a try-except)

"""


# ****************************** TASKS ON INDIVIDUAL EXPERIMENT ******************************
@command(autocomplete=lambda: list_experiments(),
         examples=["my-simulation"],
         expand=('name', {'new_arg': 'path', 'into': EXPERIMENT_FOLDER}),
         not_exists=('path', {'loglvl': 'error', 'msg': (" > Experiment '{}' does not exist !", 'name')}),
         exists=('path', {'on_boolean': 'ask', 'confirm': "Before continuing, please check that your hardware is"
                                                          " plugged.\n Are you ready ? (yes|no) [default: no] "}),
         start_msg=("BUILDING MALICIOUS MOTE BASED ON EXPERIMENT '{}'", 'name'))
def build(name, ask=True, **kwargs):
    """
    Build the malicious mote to its target hardware.

    :param name: experiment name (or absolute path to experiment)
    :param ask: ask confirmation
    :param path: expanded path of the experiment (dynamically filled in through 'command' decorator with 'expand'
    """
    console = kwargs.get('console')
Exemplo n.º 4
0
    :param not_exists: a tuple with the name of an argument to be checked for non-existence and a dictionary with up to
                        4 keys: 'loglvl' which indicates the log level for the message, 'msg' the message itself, 'ask'
                        for asking the user for confirmation to continue and 'confirm' the message to be displayed
                        when asking for confirmation
    :param exists: same structure as for 'not_exists' but handling existence instead
    :param start_msg: message to be displayed before calling 'f'
    :param reexec_on_emptyline: boolean indicating if the command is to be re-executed when an empty line is
                                 input in the console
    :param __base__: special parameter to be used if the command is to be multi-processed, it holds the
                      "monitored" version of the command (that is, encapsulated inside a try-except)

"""


# ****************************** TASKS ON INDIVIDUAL EXPERIMENT ******************************
@command(autocomplete=lambda: list_experiments(),
         examples=["my-simulation"],
         expand=('name', {
             'new_arg': 'path',
             'into': EXPERIMENT_FOLDER
         }),
         not_exists=('path', {
             'loglvl': 'error',
             'msg': (" > Experiment '{}' does not exist !", 'name')
         }),
         exists=('path', {
             'on_boolean':
             'ask',
             'confirm':
             "Before continuing, please check that your hardware is"
             " plugged.\n Are you ready ? (yes|no) [default: no] "