Automation toolbox

All these features require an Automation Toolbox License.

Otii Automation Toolbox is a software license that elevates Otii software with scripting capabilities to automate measurements based on the project's needs.

This toolbox features:

  • Scripting in any language using the Otii TCP Server API
  • Packaged scripting modules available from Github for Python, C#, Java and Matlab
  • Otii Server, a headless server that easily can be integrated in test setups

The Otii Automation Toolbox license is:

  • Associated with a user, not a specific piece of hardware.
  • Sharable; a user can share it with another user, but it can only be used by one user at a time.

You can also configure a license pool that automatically shares the licenses among your automation setups. When using a shared pool, your test scripts can be configured to wait for a license to become available before execution.

Otii TCP Server

It is possible to control Otii from another application using the Otii TCP Server API.

Using this API you can control Otii from any application that includes support for standard TCP sockets.

Otii Server is available in both the Otii 3 Desktop App and in the Otii Server application. You can not run both at the same time on the same computer.

At Qoitech's Github page you will also find wrappers for a few popular languages like Python, C#, Java & Matlab.

Otii Server

Command Line Interface

You can also start the TCP server using otii_server, the command line version of Otii.

The server is packaged within the application and to find where it is located on your system, select Help › Find otii_server in Otii Desktop App.

If you run otii_server with the --help option you will see all available options:

# otii_server --help

Options:
  -V, --version               output the version number
  -v, --verbose               verbose output
  -c, --config <config-file>  configuration file
  -h, --help                  display help for command

To start a server run the command:

# otii_server

The server is by default listening on host address 127.0.0.1 and port 1905. If you want to change the default settings, or need to add settings for a proxy, create a config.json file:

{
    "tcpserver": {
        "host": "127.0.0.1",
        "port": 1907
    },
    "proxy": {
        "host": "192.168.1.1",
        "port": "8080",
        "auth": {
            "username": "johndoe",
            "password": "mypassword"
        }
    }
}

and start the server with:

# otii_server --config config.json

The server will run until you stop it by pressing Ctrl-C.

In a future release Otii will ship with tools that will make it possible to run otii_server as a Windows Service, or a daemon in Ubuntu and macOS.

User management

User management in Desktop application

Read more about logging in and reserving licenses in the Otii 3 Desktop App here:

User management in test script

It is possible to use the TCP-API directly in the test script for user management:

#!/usr/bin/env python3
'''
If you want the script to login and reserve a license automatically
add a configuration file called credentials.json in the current folder
using the following format:

    {
        "username": "YOUR USERNAME",
        "password": "YOUR PASSWORD"
    }

Alternatively you can set the environment
variables OTII_USERNAME and OTII_PASSWORD.

'''
from otii_tcp_client import otii_client

def my_test(otii):
    # INSERT TEST CODE HERE

def main() -> None:
    # Connect and login to Otii 3
    client = otii_client.OtiiClient()
    with client.connect() as otii:
        my_test(otii)

if __name__ == '__main__':
    main()

The `client.connect() is used to connect, login and reserve licenses. It works like this:

  • If the TCP server isn't already logged in, the credentials will be read from a credentials.json file in the current directory, or from the environment variable OTIIUSERNAME and OTIIPASSWORD.
  • If there is no Automation Toolbox license reserved and there is a license available, it will automatically be reserved.
  • By default the system will only try to reserve an Automation Toolbox license. If you need to reserve another Toolbox as well add all the licenses you need to the licensesparameter:
client.connect(licenses = [ 'Automation', 'Battery' ])
  • When disconnecting from Otii all licenses that were implicitly reserved will be returned, and if the connect method logged in to the system, it will log out again.
  • If you want to manually reserve a specific license, you use an empty array for the licenses parameter:
#!/usr/bin/env python3
from otii_tcp_client import otii_client

# Connect and login to Otii 3
client = otii_client.OtiiClient()
with client.connect(licenses = []) as otii:
    # List all licenses
    licenses = otii.get_licenses()
    for license in licenses:
        items = [
            f'{license["id"]:4d}',
            f'{license["type"]:12}',
            f'{license["reserved_to"]:15}',
            f'{license["hostname"]}'
        ]
        print(' '.join(items))

    # Reserve a license
    otii.reserve_license(licenses[0]["id"])

    # INSERT TEST CODE HERE

    # Return license
    otii.return_license(licenses[0]["id"])

User management with Python tool

You can do the user management from the command line using our python module. You install the module with:

python3 -m pip install --upgrade otii_tcp_client

You can then use the otii_control tool for user management:

python3 -m otii_tcp_client.otii_control --help

usage: otii_control.py [-h] {login,logout,list-licenses,reserve-license,return-license} ...

Otii Control

options:
  -h, --help            show this help message and exit

commands:
  {login,logout,list-licenses,reserve-license,return-license}
    login               Log in to Qoitech server
    logout              Log out from Qoitech server
    list-licenses       List all available licenses
    reserve-license     Reserve license
    return-license      Return license

And here is an example bash script:

#!/usr/bin/env bash

python3 -m otii_tcp_client.otii_control login --username johndoe --password mypassword
python3 -m otii_tcp_client.otii_control reserve-license --id 1234
./my_test.py
python3 -m otii_tcp_client.otii_control return-license --id 1234
python3 -m otii_tcp_client.otii_control logout