('MergeTB Python client library',)
Project description
mergetb
This package contains a client interface to the MergeTB API.
Structure
This package implements classes that reflect the core objects defined by the MergeTB API, including:
- Identity
- User
- Project
- Organization
- Experiment
- Realization
- Materialization
- XDC
Each of these classes implements a GRPC client interface that allows object data to be pushed to / pulled from a MergeTB portal.
Example
The following example shows how a user can log into a MergeTB portal and list the projects they belong to:
import mergetb.mergetb as mergetb
from mergetb.identity import Identity
from mergetb.grpc_client import MergeGRPCError
# login
username = 'xxx' # replace with your MergeTB account username
password = 'xxx' # replace with your MergeTB account password
try:
identity = Identity(username, password)
identity.login()
# get projects
projects = mergetb.get_projects().projects
print("Username %s has the following projects:" % username)
for project in projects:
summary="""Project: %s
Description: %s
Members: %s
Experiments: %s
Access Mode: %d
GID: %d
Organization: %s
Category: %s
Subcategory: %s""" % (
project.name,
project.description,
project.members,
project.experiments,
project.access_mode,
project.gid,
project.organization,
project.category,
project.subcategory,
)
print(summary)
except MergeGRPCError as e:
print(e)
except Exception as e:
print(f"An unexpected error occurred: {e}")
API objects
Note that this package is a wrapper around the mergetbapi, a
separate Python package which provides Python language bindings for the data structures defined in
the Merge API specification. This library should be understood as a
wrapper around the mergetbapi
package that provides a more convenient interface for users to work
with.
Tests
There are tests defined in the tests directory that show further examples of how this package can be used to interact with a MergeTB portal:
- test_identity.py
- test_user.py
- test_workflow.py
To run a test, do the following. NOTE: tests must be run from the package's root directory:
python3 -m tests.test_<testname>.py
Pass the -h
option to see what command line options the test accepts; e.g., for the
test_identity
test:
python3 -m tests.test_identity -h
usage: test_identity.py [-h] [-u USERNAME] [-p PASSWORD] [-S SERVER] [-P PORT] [-X]
options:
-h, --help show this help message and exit
-u USERNAME, --username USERNAME
Username for your MergeTB account
-p PASSWORD, --password PASSWORD
Password for your MergeTB account
-S SERVER, --server SERVER
MergeTB portal GRPC address
-P PORT, --port PORT MergeTB portal GRPC port
-X, --disable-tls Disable TLS when communication with the MergeTB portal
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mergetb-1.3.15.tar.gz
.
File metadata
- Download URL: mergetb-1.3.15.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b588f8e9faccc279f92896be31ef31286519eb79a72acd2fe657555db577c16f |
|
MD5 | da702ba9f1a300e71e2236f239f8e0c2 |
|
BLAKE2b-256 | 3d321b715f803323114843d683e97dafc26696d4b96ea88c7d9cec743dd4cfb7 |
File details
Details for the file mergetb-1.3.15-py3-none-any.whl
.
File metadata
- Download URL: mergetb-1.3.15-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aadfa3e2f9f3e8a194d55de6930422936f4f23fad53ed373e241cc89c8ca8b2a |
|
MD5 | f83a4b8b67d3b0f87734d691b370c20b |
|
BLAKE2b-256 | 4554e3f12a401a6e13b43e96dfeb99d5d7bd3b3f49689e2d4510c310c9e47dfe |