Knowledge Base Administration Guide

Python API

If you want to integrate Simscope API's using Python, there is a built-in client which can be import-ed into Python:

  • simscope_client.py

NOTE: to access the API, you need an API token.

Python3 Requirements

Simscope requires Python3.

  • Python2 support has been deprecated.

Setting Python Location

Simscope scripts use a default /usr/bin/env python3 to locate the Python interpreter.

If this is choosing the wrong location of Python for your group, you can override this by prefixing the Python binary location inside your simscope.config file.

For example, instead of this script command:

[bugtracker "JIRA"]
createplugin = "/PATH/TO/simscope-jira-create.py"

Use this script command:

[bugtracker "JIRA"]
createplugin = "/my/path/bin/python3 /PATH/TO/simscope-jira-create.py"

Example Simscope Python scripts

Simscope includes many Python scripts/plugins in the bin/ directory which use the API, so you should probably use an existing script if you want to do API calls.

Example scripts:

  • simscope-regr-search — list Regressions
  • simscope-rules — list Rules
  • simscope-sig-search — search Signatures
  • simscope-test-search — search tests (ie jobs) from Regressions
  • simscope-assignments.py — list or remove issue assignments

Using Python API

To use from a Python script, you can call:

from simscope_client import SimscopeClient

# FIXME: need to document instantiating SimscopeClient() in Python...

Administrators: ad-hoc SQL interface via Command-Line

Administrators can execute ad-hoc SQL commands from the command-line, using the simscope-admin-sql script.

The results are emitted in TSV format. You can change the output delimiter via the --delimiter=X option.

  • For example, to emit CSV (comma-separated-value) format, use --delimiter=,

Here is an example SQL command to print pass/fail for the latest regressions:

> PATH/simscope-admin-sql 'select id, name, modelbranch, passed, failed, jobs from regressions order by startedns desc limit 2'

Here is an example query response (in TSV format):

id	name	modelbranch	passed	failed	jobs
19274	dev/15751x	default	1	1	2
19273	release/15750	default	3	1	4

Here is the same query in CSV format:

id,name,modelbranch,passed,failed,jobs
19274,dev/15751x,default,1,1,2
19273,release/15750,default,3,1,4

SQL table rebuild

Administrators can run an SQL table rebuild via:

> PATH/simscope-admin-sql --repopulate-tables

This repopulates the snapshot_coverage and snapshot_triage SQL tables.

  • Contact VerOps for more information on using these tables.

Python Self-Signed SSL

If you are using Simscope via HTTPS with self-signed certificates, and receive an error similar to this when running Simscope Python scripts:

error: HTTPSConnectionPool(host='aaa.company.com', port=443): Max retries exceeded with url:
(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate
verify failed: self signed certificate in certificate chain')))

You can fix this by adding an environment variable to point to your SSL certificate chain bundle file:

> export REQUESTS_CA_BUNDLE=/path/to/your/certificate.pem