FoundryProductsTechnologyCompanyInvestor relationsResource libraryNews
Contact us
Resource library
    Resource library home
    Developer resources
    Applications
    Lessons
    Research and publications
    Support
      Software packages
        eqc-direct software package
        qci-client software package
          Getting Started
          Basic Usage
          qci-client
          Dependencies
          Index
          Module Index
        uqrng-direct software package
        emucore-direct software package
        eqc-models software package
      Spec sheets
      User guides

Couldn’t find what you are looking for? Reach out to technical support.

Contact support
Privacy PolicyCookie PolicyTerms of UseForward Looking StatementsAccessibility Statement
Terms and Conditions of SaleEnd User License Agreement

© 2018-2026 Quantum Computing Inc.

Download

Default

Source code for qci_client.utilities

  • # Copyright 2023-2024, Quantum Computing Incorporated
  • """Package-wide utilities."""
  • from datetime import datetime, timezone
  • import requests
  • [docs]
  • def raise_for_status(*, response: requests.Response) -> None:
  • """
  • Wrap requests method of same name to include response text in exception message.
  • :param response: a response from any API call using the requests package
  • """
  • try:
  • # The requests package does special handling here, so build off of this.
  • response.raise_for_status()
  • except requests.HTTPError as err:
  • # Include response body in exception message to aid user understanding.
  • raise requests.HTTPError(
  • str(err) + f" with response body: {response.text}"
  • ) from err
  • [docs]
  • def log_to_console(*, log: str, verbose: bool = True) -> None:
  • """If verbose is true, then print log with timestamp prefix."""
  • if verbose:
  • print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - {log}")
  • [docs]
  • def now_utc_ms() -> str:
  • """Get current time in UTC with microsecond (i.e., maximum) precision."""
  • return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
Previous page

Content

  • Source code for qci_client.utilities