File: example.py

package info (click to toggle)
pylaunches 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 272 kB
  • sloc: python: 545; makefile: 7; sh: 5
file content (30 lines) | stat: -rw-r--r-- 714 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Example usage of pylaunches."""

import asyncio
import logging
import os


from pylaunches import PyLaunches, PyLaunchesError

logging.basicConfig(
    level=logging.INFO,
    format="%(message)s",
    handlers=[logging.StreamHandler()],
)

log = logging.getLogger(__name__)


async def example():
    """Example usage of pylaunches."""
    async with PyLaunches(token=os.environ.get("LAUNCH_TOKEN"), dev=True) as client:
        try:
            events = await client.event_upcoming(filters={"limit": 1})
            for event in events:
                log.info("%s: %s", event["date"], event["name"])
        except PyLaunchesError as exception:
            log.exception(exception)


asyncio.run(example())