Tutorial -------- Installing ~~~~~~~~~~ To install from pypi simply use: .. code-block:: bash pip install ctp-client Alternatively, you can get yourself a copy of the source code: .. code-block:: bash git clone https://gitlab.com/radiology/infrastructure/data-curation-tools/CTPy Create a connection ~~~~~~~~~~~~~~~~~~~ To create a connection import the package and use the ``connect`` function: .. code-block:: python >>> import ctpy >>> connection = ctpy.connect("http://ctp.example.com", port=8080, username="myuser", password="secret") Once connected you can use the CTP client object to query data from the CTP server. .. note:: The module to import for the ctp-client is called ``ctpy`` Getting summaries ~~~~~~~~~~~~~~~~~ Getting the summary for all pipelines can be done with a single method: .. code-block:: python >>> connection.get_ctp_summary() If you want the information about a single step for a pipeline you can use: .. code-block:: python >>> connection.get_ctp_step(pipeline=0, step=1) User management ~~~~~~~~~~~~~~~ Getting the users and their roles with method: .. code-block::python >>> connection.get_users() Above code will return a list of Users. Each of the ``Users`` will have a name and a list of ``UserRoles``. To add a new user: .. code-block::python >>> from ctpy.helpers import User >>> from ctpy.helpers import UserRoles >>> new_user = User('Audit', [UserRoles.audit, UserRoles.qadmin]) >>> new_user.password = 'password' >>> users.append(new_user) >>> ctpy.update_password(users) If you prefer to create the users before starting the CTP it is possible to create the users.xml (CTP's method to store users/roles and passwords). This can be done using CTPy's command line interface: .. code-block::bash ctpy create-users-xml -u Audit,password,audit,qadmin -u admin,qwerty,admin -u king,password,admin -u test,test,admin Each user (-u) is represented as a comma seperated string {username},{password},{role_1},..,{role_n}.