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.tar.gz (11.2 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-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pmhclib-0.9.0.tar.gz
  • Upload date:
  • Size: 11.2 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.tar.gz
Algorithm Hash digest
SHA256 c75e09506247229035f3127aa54e8c3a0543d6ff7a3ea3e5475279d61d314d51
MD5 bda9767e8ffb45ef1feee90b4b3b42b3
BLAKE2b-256 b0aa1e57d26e886133103d032187245a1275991c40f0365a9c38b0f0ca63fee9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pmhclib-0.9.0.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-py3-none-any.whl.

File metadata

  • Download URL: pmhclib-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 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-py3-none-any.whl
Algorithm Hash digest
SHA256 33b6947ac371df9629698c69891f9f57b108e28804111c536bfc5620e000d27b
MD5 ce0ff205c9c334c1d108fb0bd9fa632a
BLAKE2b-256 86a7bf9537a7c3fc670ff7828529d0060fa9c026fb01b803dcabf5b5d5a87430

See more details on using hashes here.

Provenance

The following attestation bundles were made for pmhclib-0.9.0-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