Skip to main content

pmhclib

pmhclib is a Python wrapper for the unofficial PMHC MDS portal API. You can use it to automate uploads and downloads to the PMHC portal.

Install

pmhclib is a Python package. You should be able to install it directly with pip or poetry:

pip install pmhclib@git+https://github.com/swsphn/pmhclib.git

OR

poetry add pmhclib@git+https://github.com/swsphn/pmhclib.git

This will install pmhclib as an importable Python library.

Usage

pmhclib.PMHC is intended to be used with a context manager. This ensures that the requests session which performs the login process and the API requests is correctly closed when the script exits. The standard use pattern is as follows:

from pmhclib import PMHC
with PMHC('PHN105') as pmhc:
    pmhc.login()
    ...
    # other pmhc methods.

pmhc.login() will read credentials from the following environment variables if they are set:

PMHC_USERNAME
PMHC_PASSWORD
PMHC_TOTP_SECRET

Otherwise, you will be prompted for credentials interactively.

In PowerShell, you can set the environment variables interactively as follows:

$env:PMHC_USERNAME='your_username_here'
$env:PMHC_PASSWORD=python -c 'import getpass; print(getpass.getpass())'
$env:PMHC_TOTP_SECRET=python -c 'import getpass; print(getpass.getpass("TOTP Secret: "))'

In a Unix shell (Mac, Linux), you can do:

export PMHC_USERNAME='your_username_here'
read -rs PMHC_PASSWORD && export PMHC_PASSWORD
read -rs PMHC_TOTP_SECRET && export PMHC_TOTP_SECRET

NOTE: PMHC_TOTP_SECRET is the unchanging base32-encoded TOTP secret, not the time-based six-digit code. You can likely find this secret in the 'advanced' section of your TOTP app. It will be a long string of upper-case letters and digits. See below for a list of TOTP apps which support viewing the TOTP secret. It is also possible to get the secret by scanning the setup QR code with a generic QR code reader, or by clicking the Trouble scanning button on the website to manually configure the TOTP app:

manually view totp secret

The six-digit code will be automatically calculated based on the current time as required if PMHC_TOTP_SECRET is specified. Otherwise, the user will be prompted to enter the current six-digit code.

Not all TOTP apps support viewing the secret. The following are known to support this:

For more details, see the list of recommended authenticator apps on our Data Wiki.

Documentation

See the online documentation.

Built-in docs

Review the built-in documentation from Python as follows:

>>> from pmhclib import PMHC
>>> help(PMHC)

Build docs

You can also generate html documentation locally using Sphinx if you have a local copy of the repository.

Linux:

cd docs
make html

PowerShell:

cd docs
./make.bat html

The generated documentation can be viewed at docs/_build/html/index.html.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pmhclib-0.9.0.post1.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pmhclib-0.9.0.post1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file pmhclib-0.9.0.post1.tar.gz.

File metadata

  • Download URL: pmhclib-0.9.0.post1.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pmhclib-0.9.0.post1.tar.gz
Algorithm Hash digest
SHA256 755496c3f8cdb89eced36ba81dd9df5366c354ed62b4263b3b7eeb948700fe1c
MD5 c054478daa1910e311d24e8412c04b91
BLAKE2b-256 d802a33e09d4663e030d289c2b3b3cc7d4464e3ac077bd6bbea8e546d2e80d23

See more details on using hashes here.

Provenance

The following attestation bundles were made for pmhclib-0.9.0.post1.tar.gz:

Publisher: pypi.yml on swsphn/pmhclib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pmhclib-0.9.0.post1-py3-none-any.whl.

File metadata

  • Download URL: pmhclib-0.9.0.post1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pmhclib-0.9.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 fba0f5ddf28ddd4a3435b6f7de9b4f66e7df08bb3f4b2748077766fc55a4837d
MD5 27c3af4c3e162879607b4b35c8fa7d95
BLAKE2b-256 1c52015ccd586eefac71edc27b1087ae94076d760beec1734e80e65f1c41b138

See more details on using hashes here.

Provenance

The following attestation bundles were made for pmhclib-0.9.0.post1-py3-none-any.whl:

Publisher: pypi.yml on swsphn/pmhclib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page