%global _empty_manifest_terminate_build 0 Name: python-aioambient Version: 2023.4.0 Release: 1 Summary: A clean, async-friendly library for the Ambient Weather API License: MIT URL: https://github.com/bachya/aioambient Source0: https://mirrors.nju.edu.cn/pypi/web/packages/45/ce/0c80f2bc8114dfcc45ecc699889d52fceca1b705746cf0bcb9af5228cd69/aioambient-2023.4.0.tar.gz BuildArch: noarch Requires: python3-aiohttp Requires: python3-engineio Requires: python3-socketio Requires: python3-websockets %description # 🌤 aioambient: An async library for Ambient Weather Personal Weather Stations [![CI][ci-badge]][ci] [![PyPI][pypi-badge]][pypi] [![Version][version-badge]][version] [![License][license-badge]][license] [![Code Coverage][codecov-badge]][codecov] [![Maintainability][maintainability-badge]][maintainability] Buy Me A Coffee `aioambient` is a Python3, asyncio-driven library that interfaces with both the REST and Websocket APIs provided by [Ambient Weather][ambient-weather]. - [Installation](#installation) - [Python Versions](#python-versions) - [API and Application Keys](#api-and-application-keys) - [Usage](#usage) - [Contributing](#contributing) # Installation ```bash pip install aioambient ``` # Python Versions `aioambient` is currently supported on: - Python 3.9 - Python 3.10 - Python 3.11 # API and Application Keys Utilizing `aioambient` requires both an Application Key and an API Key from Ambient Weather. You can generate both from the Profile page in your [Ambient Weather Dashboard][ambient-weather-dashboard]. # Usage ## REST API ```python import asyncio from datetime import date from aiohttp import ClientSession from aioambient import API async def main() -> None: """Create the aiohttp session and run the example.""" api = API("", "") # Get all devices in an account: await api.get_devices() # Get all stored readings from a device: await api.get_device_details("") # Get all stored readings from a device (starting at a datetime): await api.get_device_details("", end_date=date(2019, 1, 16)) asyncio.run(main()) ``` By default, the library creates a new connection to Ambient Weather with each coroutine. If you are calling a large number of coroutines (or merely want to squeeze out every second of runtime savings possible), an [`aiohttp`][aiohttp] `ClientSession` can be used for connection pooling: ```python import asyncio from datetime import date from aiohttp import ClientSession from aioambient import API async def main() -> None: """Create the aiohttp session and run the example.""" async with ClientSession() as session: api = API("", "") # Get all devices in an account: await api.get_devices() # Get all stored readings from a device: await api.get_device_details("") # Get all stored readings from a device (starting at a datetime): await api.get_device_details("", end_date=date(2019, 1, 16)) asyncio.run(main()) ``` Please be aware of Ambient Weather's [rate limiting policies][ambient-weather-rate-limiting]. ## Websocket API ```python import asyncio from aiohttp import ClientSession from aioambient import Websocket async def main() -> None: """Create the aiohttp session and run the example.""" websocket = Websocket("", "") # Note that you can watch multiple API keys at once: websocket = Websocket("YOUR APPLICATION KEY", ["", ""]) # Define a method that should be fired when the websocket client # connects: def connect_method(): """Print a simple "hello" message.""" print("Client has connected to the websocket") websocket.on_connect(connect_method) # Alternatively, define a coroutine handler: async def connect_coroutine(): """Waits for 3 seconds, then print a simple "hello" message.""" await asyncio.sleep(3) print("Client has connected to the websocket") websocket.async_on_connect(connect_coroutine) # Define a method that should be run upon subscribing to the Ambient # Weather cloud: def subscribed_method(data): """Print the data received upon subscribing.""" print(f"Subscription data received: {data}") websocket.on_subscribed(subscribed_method) # Alternatively, define a coroutine handler: async def subscribed_coroutine(data): """Waits for 3 seconds, then print the incoming data.""" await asyncio.sleep(3) print(f"Subscription data received: {data}") websocket.async_on_subscribed(subscribed_coroutine) # Define a method that should be run upon receiving data: def data_method(data): """Print the data received.""" print(f"Data received: {data}") websocket.on_data(data_method) # Alternatively, define a coroutine handler: async def data_coroutine(data): """Wait for 3 seconds, then print the data received.""" await asyncio.sleep(3) print(f"Data received: {data}") websocket.async_on_data(data_coroutine) # Define a method that should be run when the websocket client # disconnects: def disconnect_method(data): """Print a simple "goodbye" message.""" print("Client has disconnected from the websocket") websocket.on_disconnect(disconnect_method) # Alternatively, define a coroutine handler: async def disconnect_coroutine(data): """Wait for 3 seconds, then print a simple "goodbye" message.""" await asyncio.sleep(3) print("Client has disconnected from the websocket") websocket.async_on_disconnect(disconnect_coroutine) # Connect to the websocket: await websocket.connect() # At any point, disconnect from the websocket: await websocket.disconnect() asyncio.run(main()) ``` # Contributing Thanks to all of [our contributors][contributors] so far! 1. [Check for open features/bugs][issues] or [initiate a discussion on one][new-issue]. 2. [Fork the repository][fork]. 3. (_optional, but highly recommended_) Create a virtual environment: `python3 -m venv .venv` 4. (_optional, but highly recommended_) Enter the virtual environment: `source ./.venv/bin/activate` 5. Install the dev environment: `script/setup` 6. Code your new feature or bug fix on a new branch. 7. Write tests that cover your new functionality. 8. Run tests and ensure 100% code coverage: `poetry run pytest --cov aioambient tests` 9. Update `README.md` with any new documentation. 10. Submit a pull request! [aiohttp]: https://github.com/aio-libs/aiohttp [ambient-weather-dashboard]: https://dashboard.ambientweather.net [ambient-weather-rate-limiting]: https://ambientweather.docs.apiary.io/#introduction/rate-limiting [ambient-weather]: https://ambientweather.net [ci-badge]: https://github.com/bachya/aioambient/workflows/CI/badge.svg [ci]: https://github.com/bachya/aioambient/actions [codecov-badge]: https://codecov.io/gh/bachya/aioambient/branch/dev/graph/badge.svg [codecov]: https://codecov.io/gh/bachya/aioambient [contributors]: https://github.com/bachya/aioambient/graphs/contributors [fork]: https://github.com/bachya/aioambient/fork [issues]: https://github.com/bachya/aioambient/issues [license-badge]: https://img.shields.io/pypi/l/aioambient.svg [license]: https://github.com/bachya/aioambient/blob/main/LICENSE [maintainability-badge]: https://api.codeclimate.com/v1/badges/81a9f8274abf325b2fa4/maintainability [maintainability]: https://codeclimate.com/github/bachya/aioambient/maintainability [new-issue]: https://github.com/bachya/aioambient/issues/new [new-issue]: https://github.com/bachya/aioambient/issues/new [pypi-badge]: https://img.shields.io/pypi/v/aioambient.svg [pypi]: https://pypi.python.org/pypi/aioambient [version-badge]: https://img.shields.io/pypi/pyversions/aioambient.svg [version]: https://pypi.python.org/pypi/aioambient %package -n python3-aioambient Summary: A clean, async-friendly library for the Ambient Weather API Provides: python-aioambient BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-aioambient # 🌤 aioambient: An async library for Ambient Weather Personal Weather Stations [![CI][ci-badge]][ci] [![PyPI][pypi-badge]][pypi] [![Version][version-badge]][version] [![License][license-badge]][license] [![Code Coverage][codecov-badge]][codecov] [![Maintainability][maintainability-badge]][maintainability] Buy Me A Coffee `aioambient` is a Python3, asyncio-driven library that interfaces with both the REST and Websocket APIs provided by [Ambient Weather][ambient-weather]. - [Installation](#installation) - [Python Versions](#python-versions) - [API and Application Keys](#api-and-application-keys) - [Usage](#usage) - [Contributing](#contributing) # Installation ```bash pip install aioambient ``` # Python Versions `aioambient` is currently supported on: - Python 3.9 - Python 3.10 - Python 3.11 # API and Application Keys Utilizing `aioambient` requires both an Application Key and an API Key from Ambient Weather. You can generate both from the Profile page in your [Ambient Weather Dashboard][ambient-weather-dashboard]. # Usage ## REST API ```python import asyncio from datetime import date from aiohttp import ClientSession from aioambient import API async def main() -> None: """Create the aiohttp session and run the example.""" api = API("", "") # Get all devices in an account: await api.get_devices() # Get all stored readings from a device: await api.get_device_details("") # Get all stored readings from a device (starting at a datetime): await api.get_device_details("", end_date=date(2019, 1, 16)) asyncio.run(main()) ``` By default, the library creates a new connection to Ambient Weather with each coroutine. If you are calling a large number of coroutines (or merely want to squeeze out every second of runtime savings possible), an [`aiohttp`][aiohttp] `ClientSession` can be used for connection pooling: ```python import asyncio from datetime import date from aiohttp import ClientSession from aioambient import API async def main() -> None: """Create the aiohttp session and run the example.""" async with ClientSession() as session: api = API("", "") # Get all devices in an account: await api.get_devices() # Get all stored readings from a device: await api.get_device_details("") # Get all stored readings from a device (starting at a datetime): await api.get_device_details("", end_date=date(2019, 1, 16)) asyncio.run(main()) ``` Please be aware of Ambient Weather's [rate limiting policies][ambient-weather-rate-limiting]. ## Websocket API ```python import asyncio from aiohttp import ClientSession from aioambient import Websocket async def main() -> None: """Create the aiohttp session and run the example.""" websocket = Websocket("", "") # Note that you can watch multiple API keys at once: websocket = Websocket("YOUR APPLICATION KEY", ["", ""]) # Define a method that should be fired when the websocket client # connects: def connect_method(): """Print a simple "hello" message.""" print("Client has connected to the websocket") websocket.on_connect(connect_method) # Alternatively, define a coroutine handler: async def connect_coroutine(): """Waits for 3 seconds, then print a simple "hello" message.""" await asyncio.sleep(3) print("Client has connected to the websocket") websocket.async_on_connect(connect_coroutine) # Define a method that should be run upon subscribing to the Ambient # Weather cloud: def subscribed_method(data): """Print the data received upon subscribing.""" print(f"Subscription data received: {data}") websocket.on_subscribed(subscribed_method) # Alternatively, define a coroutine handler: async def subscribed_coroutine(data): """Waits for 3 seconds, then print the incoming data.""" await asyncio.sleep(3) print(f"Subscription data received: {data}") websocket.async_on_subscribed(subscribed_coroutine) # Define a method that should be run upon receiving data: def data_method(data): """Print the data received.""" print(f"Data received: {data}") websocket.on_data(data_method) # Alternatively, define a coroutine handler: async def data_coroutine(data): """Wait for 3 seconds, then print the data received.""" await asyncio.sleep(3) print(f"Data received: {data}") websocket.async_on_data(data_coroutine) # Define a method that should be run when the websocket client # disconnects: def disconnect_method(data): """Print a simple "goodbye" message.""" print("Client has disconnected from the websocket") websocket.on_disconnect(disconnect_method) # Alternatively, define a coroutine handler: async def disconnect_coroutine(data): """Wait for 3 seconds, then print a simple "goodbye" message.""" await asyncio.sleep(3) print("Client has disconnected from the websocket") websocket.async_on_disconnect(disconnect_coroutine) # Connect to the websocket: await websocket.connect() # At any point, disconnect from the websocket: await websocket.disconnect() asyncio.run(main()) ``` # Contributing Thanks to all of [our contributors][contributors] so far! 1. [Check for open features/bugs][issues] or [initiate a discussion on one][new-issue]. 2. [Fork the repository][fork]. 3. (_optional, but highly recommended_) Create a virtual environment: `python3 -m venv .venv` 4. (_optional, but highly recommended_) Enter the virtual environment: `source ./.venv/bin/activate` 5. Install the dev environment: `script/setup` 6. Code your new feature or bug fix on a new branch. 7. Write tests that cover your new functionality. 8. Run tests and ensure 100% code coverage: `poetry run pytest --cov aioambient tests` 9. Update `README.md` with any new documentation. 10. Submit a pull request! [aiohttp]: https://github.com/aio-libs/aiohttp [ambient-weather-dashboard]: https://dashboard.ambientweather.net [ambient-weather-rate-limiting]: https://ambientweather.docs.apiary.io/#introduction/rate-limiting [ambient-weather]: https://ambientweather.net [ci-badge]: https://github.com/bachya/aioambient/workflows/CI/badge.svg [ci]: https://github.com/bachya/aioambient/actions [codecov-badge]: https://codecov.io/gh/bachya/aioambient/branch/dev/graph/badge.svg [codecov]: https://codecov.io/gh/bachya/aioambient [contributors]: https://github.com/bachya/aioambient/graphs/contributors [fork]: https://github.com/bachya/aioambient/fork [issues]: https://github.com/bachya/aioambient/issues [license-badge]: https://img.shields.io/pypi/l/aioambient.svg [license]: https://github.com/bachya/aioambient/blob/main/LICENSE [maintainability-badge]: https://api.codeclimate.com/v1/badges/81a9f8274abf325b2fa4/maintainability [maintainability]: https://codeclimate.com/github/bachya/aioambient/maintainability [new-issue]: https://github.com/bachya/aioambient/issues/new [new-issue]: https://github.com/bachya/aioambient/issues/new [pypi-badge]: https://img.shields.io/pypi/v/aioambient.svg [pypi]: https://pypi.python.org/pypi/aioambient [version-badge]: https://img.shields.io/pypi/pyversions/aioambient.svg [version]: https://pypi.python.org/pypi/aioambient %package help Summary: Development documents and examples for aioambient Provides: python3-aioambient-doc %description help # 🌤 aioambient: An async library for Ambient Weather Personal Weather Stations [![CI][ci-badge]][ci] [![PyPI][pypi-badge]][pypi] [![Version][version-badge]][version] [![License][license-badge]][license] [![Code Coverage][codecov-badge]][codecov] [![Maintainability][maintainability-badge]][maintainability] Buy Me A Coffee `aioambient` is a Python3, asyncio-driven library that interfaces with both the REST and Websocket APIs provided by [Ambient Weather][ambient-weather]. - [Installation](#installation) - [Python Versions](#python-versions) - [API and Application Keys](#api-and-application-keys) - [Usage](#usage) - [Contributing](#contributing) # Installation ```bash pip install aioambient ``` # Python Versions `aioambient` is currently supported on: - Python 3.9 - Python 3.10 - Python 3.11 # API and Application Keys Utilizing `aioambient` requires both an Application Key and an API Key from Ambient Weather. You can generate both from the Profile page in your [Ambient Weather Dashboard][ambient-weather-dashboard]. # Usage ## REST API ```python import asyncio from datetime import date from aiohttp import ClientSession from aioambient import API async def main() -> None: """Create the aiohttp session and run the example.""" api = API("", "") # Get all devices in an account: await api.get_devices() # Get all stored readings from a device: await api.get_device_details("") # Get all stored readings from a device (starting at a datetime): await api.get_device_details("", end_date=date(2019, 1, 16)) asyncio.run(main()) ``` By default, the library creates a new connection to Ambient Weather with each coroutine. If you are calling a large number of coroutines (or merely want to squeeze out every second of runtime savings possible), an [`aiohttp`][aiohttp] `ClientSession` can be used for connection pooling: ```python import asyncio from datetime import date from aiohttp import ClientSession from aioambient import API async def main() -> None: """Create the aiohttp session and run the example.""" async with ClientSession() as session: api = API("", "") # Get all devices in an account: await api.get_devices() # Get all stored readings from a device: await api.get_device_details("") # Get all stored readings from a device (starting at a datetime): await api.get_device_details("", end_date=date(2019, 1, 16)) asyncio.run(main()) ``` Please be aware of Ambient Weather's [rate limiting policies][ambient-weather-rate-limiting]. ## Websocket API ```python import asyncio from aiohttp import ClientSession from aioambient import Websocket async def main() -> None: """Create the aiohttp session and run the example.""" websocket = Websocket("", "") # Note that you can watch multiple API keys at once: websocket = Websocket("YOUR APPLICATION KEY", ["", ""]) # Define a method that should be fired when the websocket client # connects: def connect_method(): """Print a simple "hello" message.""" print("Client has connected to the websocket") websocket.on_connect(connect_method) # Alternatively, define a coroutine handler: async def connect_coroutine(): """Waits for 3 seconds, then print a simple "hello" message.""" await asyncio.sleep(3) print("Client has connected to the websocket") websocket.async_on_connect(connect_coroutine) # Define a method that should be run upon subscribing to the Ambient # Weather cloud: def subscribed_method(data): """Print the data received upon subscribing.""" print(f"Subscription data received: {data}") websocket.on_subscribed(subscribed_method) # Alternatively, define a coroutine handler: async def subscribed_coroutine(data): """Waits for 3 seconds, then print the incoming data.""" await asyncio.sleep(3) print(f"Subscription data received: {data}") websocket.async_on_subscribed(subscribed_coroutine) # Define a method that should be run upon receiving data: def data_method(data): """Print the data received.""" print(f"Data received: {data}") websocket.on_data(data_method) # Alternatively, define a coroutine handler: async def data_coroutine(data): """Wait for 3 seconds, then print the data received.""" await asyncio.sleep(3) print(f"Data received: {data}") websocket.async_on_data(data_coroutine) # Define a method that should be run when the websocket client # disconnects: def disconnect_method(data): """Print a simple "goodbye" message.""" print("Client has disconnected from the websocket") websocket.on_disconnect(disconnect_method) # Alternatively, define a coroutine handler: async def disconnect_coroutine(data): """Wait for 3 seconds, then print a simple "goodbye" message.""" await asyncio.sleep(3) print("Client has disconnected from the websocket") websocket.async_on_disconnect(disconnect_coroutine) # Connect to the websocket: await websocket.connect() # At any point, disconnect from the websocket: await websocket.disconnect() asyncio.run(main()) ``` # Contributing Thanks to all of [our contributors][contributors] so far! 1. [Check for open features/bugs][issues] or [initiate a discussion on one][new-issue]. 2. [Fork the repository][fork]. 3. (_optional, but highly recommended_) Create a virtual environment: `python3 -m venv .venv` 4. (_optional, but highly recommended_) Enter the virtual environment: `source ./.venv/bin/activate` 5. Install the dev environment: `script/setup` 6. Code your new feature or bug fix on a new branch. 7. Write tests that cover your new functionality. 8. Run tests and ensure 100% code coverage: `poetry run pytest --cov aioambient tests` 9. Update `README.md` with any new documentation. 10. Submit a pull request! [aiohttp]: https://github.com/aio-libs/aiohttp [ambient-weather-dashboard]: https://dashboard.ambientweather.net [ambient-weather-rate-limiting]: https://ambientweather.docs.apiary.io/#introduction/rate-limiting [ambient-weather]: https://ambientweather.net [ci-badge]: https://github.com/bachya/aioambient/workflows/CI/badge.svg [ci]: https://github.com/bachya/aioambient/actions [codecov-badge]: https://codecov.io/gh/bachya/aioambient/branch/dev/graph/badge.svg [codecov]: https://codecov.io/gh/bachya/aioambient [contributors]: https://github.com/bachya/aioambient/graphs/contributors [fork]: https://github.com/bachya/aioambient/fork [issues]: https://github.com/bachya/aioambient/issues [license-badge]: https://img.shields.io/pypi/l/aioambient.svg [license]: https://github.com/bachya/aioambient/blob/main/LICENSE [maintainability-badge]: https://api.codeclimate.com/v1/badges/81a9f8274abf325b2fa4/maintainability [maintainability]: https://codeclimate.com/github/bachya/aioambient/maintainability [new-issue]: https://github.com/bachya/aioambient/issues/new [new-issue]: https://github.com/bachya/aioambient/issues/new [pypi-badge]: https://img.shields.io/pypi/v/aioambient.svg [pypi]: https://pypi.python.org/pypi/aioambient [version-badge]: https://img.shields.io/pypi/pyversions/aioambient.svg [version]: https://pypi.python.org/pypi/aioambient %prep %autosetup -n aioambient-2023.4.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-aioambient -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Wed Apr 12 2023 Python_Bot - 2023.4.0-1 - Package Spec generated