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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ecoledirecte-0.2.6.tar.gz
  • Upload date:
  • Size: 21.3 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.6.tar.gz
Algorithm Hash digest
SHA256 546cd068da073ed8d5df522e3789b14821d4d2e2319dd4393f424cf80a494321
MD5 c859846b6431963bd0ff00830f7b271e
BLAKE2b-256 51a0b00640aebbb8c9bc4f0c9bb6f36edcb76a6c265b74f491c073ba03562eb7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: ecoledirecte-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 21.4 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 40aa503d79ae625a339df4439f72e06768491a2f381c266164b09b9835ba3ef5
MD5 b3ef0eb4140cc594ba83ab0fbe729aaa
BLAKE2b-256 a8e39a1afd61851e687f7d057de0e71aa5b40da3a1cbbe15ad03afa9ef90dcd5

See more details on using hashes here.

Provenance

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