Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?


JSA Python Helper Library Functions


The JSA Python helper library (qpylib ) contains several useful functions that you can use to add logging, make REST API calls, and convert JSON objects to Python dictionaries.

All functions that you import into your app's file can be called globally.

The following table describes functions that you can import into your app's file.

Table 1: Functions That You Can Import Into Your App





def log(message, level='info'):

Here's an example:

from qpylib import qpylib .. #in precedence order from lowest level to highest log('debug message' ,'debug') log('info message' ,'info') log('warning message' ,'warning') log('error message' ,'error') log('critical message' ,'critical')

Import the qpylib helper library into your app's to use the log() function. This function writes messages at your chosen log level to the /store/log/app.log file.

By default, logging is turned on and set to INFO level. Lower level logging messages are ignored. Use the POST /log_level endpoint to change

set_log_level( log_level )

def set_log_level(log_level='info'):

Set the current log level. Used by the POST /log_level endpoint but can also be called programmatically.


def REST( RESTtype, requestURL, headers={}, data=None, params=None, json=None, version=None ):

For example:

try: headers = {'content-type' : 'text/plain'} arielOptions = qpylib.REST( 'get', '/api/ariel/databases', headers = headers ) except Exception as e: qpylib.log( "Error " + str(e) ) raise

Import the qpylib library to use this function to make calls to the JSA REST API endpoints. The endpoint takes care of authentication and authorization by reusing the security tokens that are passed on the request from JSA.

to_json_dict( JSON )

def to_json_dict(python_obj):

Converts a JSON object in to a Python dictionary.