Skip to content

robot.rebot

Module implementing the command line entry point for post-processing outputs.

This module can be executed from the command line using the following approaches::

1
2
python -m robot.rebot
python path/to/robot/rebot.py

Instead of python it is possible to use also other Python interpreters. This module is also used by the installed rebot start-up script.

This module also provides :func:rebot and :func:rebot_cli functions that can be used programmatically. Other code is for internal usage.

rebot_cli

rebot_cli(arguments=None, exit=True)

Command line execution entry point for post-processing outputs.

:param arguments: Command line options and arguments as a list of strings. Defaults to sys.argv[1:] if not given. :param exit: If True, call sys.exit with the return code denoting execution status, otherwise just return the rc.

Entry point used when post-processing outputs from the command line, but can also be used by custom scripts. Especially useful if the script itself needs to accept same arguments as accepted by Rebot, because the script can just pass them forward directly along with the possible default values it sets itself.

Example::

1
2
3
from robot import rebot_cli

rebot_cli(['--name', 'Example', '--log', 'NONE', 'o1.xml', 'o2.xml'])

See also the :func:rebot function that allows setting options as keyword arguments like name="Example" and generally has a richer API for programmatic Rebot execution.

Source code in src/robot/rebot.py
def rebot_cli(arguments=None, exit=True):
    """Command line execution entry point for post-processing outputs.

    :param arguments: Command line options and arguments as a list of strings.
        Defaults to ``sys.argv[1:]`` if not given.
    :param exit: If ``True``, call ``sys.exit`` with the return code denoting
        execution status, otherwise just return the rc.

    Entry point used when post-processing outputs from the command line, but
    can also be used by custom scripts. Especially useful if the script itself
    needs to accept same arguments as accepted by Rebot, because the script can
    just pass them forward directly along with the possible default values it
    sets itself.

    Example::

        from robot import rebot_cli

        rebot_cli(['--name', 'Example', '--log', 'NONE', 'o1.xml', 'o2.xml'])

    See also the :func:`rebot` function that allows setting options as keyword
    arguments like ``name="Example"`` and generally has a richer API for
    programmatic Rebot execution.
    """
    if arguments is None:
        arguments = sys.argv[1:]
    return Rebot().execute_cli(arguments, exit=exit)

rebot

rebot(*outputs, **options)

Programmatic entry point for post-processing outputs.

:param outputs: Paths to Robot Framework output files similarly as when running the rebot command on the command line. :param options: Options to configure processing outputs. Accepted options are mostly same as normal command line options to the rebot command. Option names match command line option long names without hyphens so that, for example, --name becomes name.

The semantics related to passing options are exactly the same as with the :func:~robot.run.run function. See its documentation for more details.

Examples::

1
2
3
4
5
from robot import rebot

rebot('path/to/output.xml')
with open('stdout.txt', 'w') as stdout:
    rebot('o1.xml', 'o2.xml', name='Example', log=None, stdout=stdout)

Equivalent command line usage::

1
2
rebot path/to/output.xml
rebot --name Example --log NONE o1.xml o2.xml > stdout.txt
Source code in src/robot/rebot.py
def rebot(*outputs, **options):
    """Programmatic entry point for post-processing outputs.

    :param outputs: Paths to Robot Framework output files similarly
        as when running the ``rebot`` command on the command line.
    :param options: Options to configure processing outputs. Accepted
        options are mostly same as normal command line options to the ``rebot``
        command. Option names match command line option long names without
        hyphens so that, for example, ``--name`` becomes ``name``.

    The semantics related to passing options are exactly the same as with the
    :func:`~robot.run.run` function. See its documentation for more details.

    Examples::

        from robot import rebot

        rebot('path/to/output.xml')
        with open('stdout.txt', 'w') as stdout:
            rebot('o1.xml', 'o2.xml', name='Example', log=None, stdout=stdout)

    Equivalent command line usage::

        rebot path/to/output.xml
        rebot --name Example --log NONE o1.xml o2.xml > stdout.txt
    """
    return Rebot().execute(*outputs, **options)