Skip to main content

Async Python client to interact with Ecole Directe API.

Project description

PyPI Python Version License

A fully async and easy to use API client for the Ecole Directe API. This package is mainly used by Home Assistant, to offer the Ecole Directe integration. If you want to use this package in your own project, you can look at the Home Assistant Code for more examples.

Features

  • TODO

Installation

$ pip install ecoledirecte

Getting started

import asyncio
import json
import logging
from pathlib import Path
from ecoledirecte_api.client import EDClient
from ecoledirecte_api.exceptions import BaseEcoleDirecteException

logger = logging.getLogger(__name__)

async def save_question(qcm_json):
    """Save question to file."""
    with Path("qcm.json").open(
        "w",
        encoding="utf-8",
    ) as fp:
        json.dump(qcm_json, fp, indent=4, ensure_ascii=False)
    logger.info("Saved question to file", qcm_json)


async def main():
    logging.basicConfig(filename="myapp.log", level=logging.DEBUG)
    logger.info("Started")
    try:
        qcm_json = {}
        with Path("qcm.json").open(
            "r",
            encoding="utf-8",
        ) as fp:
            qcm_json = json.load(fp)

            async with EDClient(
                "user", "password", qcm_json
            ) as client:
                client.on_new_question(save_question)
                l = await client.login()
                logger.info(f"l= {l}")
                logger.info(f"Logged in as {client.username}")
                logger.info("Finished")
                await client.close()
    except BaseEcoleDirecteException as e:
        logger.exception(e.message)
        return
    except Exception as e:
        logger.exception(e)
        return

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Project details


Download files

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

Source Distribution

ecoledirecte-0.2.9.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

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

ecoledirecte-0.2.9-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file ecoledirecte-0.2.9.tar.gz.

File metadata

  • Download URL: ecoledirecte-0.2.9.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ecoledirecte-0.2.9.tar.gz
Algorithm Hash digest
SHA256 4d154a4a3a9e0398a1c6603bf688cca3213005e989860a6959eaae02f1e90728
MD5 0087693c43d71b31e5ca3a505844d8dc
BLAKE2b-256 1640b61fba08305c94647e9c0fdbdc81c324c9bfd35c20c5cc7be9357c7e0ef4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ecoledirecte-0.2.9.tar.gz:

Publisher: release.yml on hacf-fr/ecoledirecte_api

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

File details

Details for the file ecoledirecte-0.2.9-py3-none-any.whl.

File metadata

  • Download URL: ecoledirecte-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ecoledirecte-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 aab33a4906bdd4408d779e451d0109c892236df5a90fc226301084783c094f76
MD5 3ff38d2e097a0f5298d9139b23bb4686
BLAKE2b-256 94b6dab80f2beddd32b818f27f319853a83995184e017eda82bd39ae37a7967f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ecoledirecte-0.2.9-py3-none-any.whl:

Publisher: release.yml on hacf-fr/ecoledirecte_api

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