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
Metadata
Release files for mergetb 1.3.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mergetb-1.3.16.tar.gz | 13.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mergetb-1.3.16-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.0 kB
Release files / mergetb-1.3.16.tar.gz
| Download URL | mergetb-1.3.16.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dad35b9ac8cd544e45e7f4e0920d397c256a856ee60ca0ae19046d471e4caab2
|
|
BLAKE2b-256 checksum How to use checksums |
d1160574ee6c027e31672beae04ac89db0cb99b79ceccf16932822c73320c5ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.2
|
Release files / mergetb-1.3.16-py3-none-any.whl
| Download URL | mergetb-1.3.16-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de67f247060bf07be5a2d6180809d72d7a62c3490e6a6e5f6a67ae0aee1bc4b6
|
|
BLAKE2b-256 checksum How to use checksums |
27ba33b28f2c77b388c5ae631e9c2995ab9e56f7e044927be7d8322b69b882b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.2
|