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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ecoledirecte-0.2.8.tar.gz
  • Upload date:
  • Size: 21.1 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.8.tar.gz
Algorithm Hash digest
SHA256 78c39d95db86408f09d738ab9b2370db344ed5fd64a09715069651a469da05ba
MD5 755ecaaa10bd20c186582736afca1569
BLAKE2b-256 3a43a9ed99a0ca41303147344597a5f3ab76ed82b9bb908b0708b15d234156b0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: ecoledirecte-0.2.8-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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 1a5955c1c6cdb39214c6a7a91814df3e6277bda6ae4d5e1cc249bbebd55352b4
MD5 ba51af8ba6a9c26d36656f2bb3198442
BLAKE2b-256 e41de3dc20d2dbc059931e966fe23449a2e7f947ce4e43515e26d4b1c7a8b5d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ecoledirecte-0.2.8-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