From e7eb7030fdad788468518e74c006fe732cf8dd08 Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Wed, 10 May 2023 07:37:19 +0000 Subject: automatic import of python-pytrackunit --- .gitignore | 1 + python-pytrackunit.spec | 411 ++++++++++++++++++++++++++++++++++++++++++++++++ sources | 1 + 3 files changed, 413 insertions(+) create mode 100644 python-pytrackunit.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore index e69de29..c01e1e1 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/pytrackunit-2.4.1.tar.gz diff --git a/python-pytrackunit.spec b/python-pytrackunit.spec new file mode 100644 index 0000000..4f40c4f --- /dev/null +++ b/python-pytrackunit.spec @@ -0,0 +1,411 @@ +%global _empty_manifest_terminate_build 0 +Name: python-pytrackunit +Version: 2.4.1 +Release: 1 +Summary: Easy access for TrackUnit REST API +License: MIT License +URL: https://github.com/einsteinmaster/TrackUnitPython +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/ee/73/a4831a37eedcf5fc0c9508bf707dafd42192d88ccc2acb5c2b7b5e2411ad/pytrackunit-2.4.1.tar.gz +BuildArch: noarch + +Requires: python3-aiohttp +Requires: python3-aiofiles +Requires: python3-tqdm +Requires: python3-dateutil +Requires: python3-aiosqlite +Requires: python3-aioprocessing + +%description +# TrackUnitPython + +![test](https://github.com/einsteinmaster/TrackUnitPython/actions/workflows/test.yml/badge.svg) +![lint](https://github.com/einsteinmaster/TrackUnitPython/actions/workflows/pylint.yml/badge.svg) +![Coverage Status](https://coveralls.io/repos/github/kmodexc/TrackUnitPython/badge.svg?branch=main) + +Python API for Trackunit + +## What is this package + +This packages contains some usefull functions for an easy interface to TrackUnit's REST API. For information to the data see [here](https://dev.trackunit.com/docs). + +Features: +- caches requests for faster access +- for timespan's bigger than 30 days it sufficiantly devides it into allowed requests +- asyncio functions availeble +- if data is cached it can process 12000 cached requests with 20 million data points in under 5 minutes. +- uses sqlite to cache data efficiently +- requests throttle function (Trackunit-API limits to 50 requests per second) +- provides stream-based generators for processing of big data + +For more features write an issue [here](https://github.com/einsteinmaster/TrackUnitPython/issues/new). Pull requests are welcome. + +## How to use + +### Install + +Install the package via pip + +``` sh +pip install pytrackunit +``` + +Create a file in your execution directory with the name `api.key` which contains your TrackUnit API token. If that doesnt work for you, you can set the token in the constructor by calling `tu = TrackUnit(api_key="")`. + +### Example + +``` python +from pytrackunit.TrackUnit import TrackUnit + +# Create the API +# It loads the key from api.key by default +tu = TrackUnit() +# alternatively +tu = TrackUnit(api_key="") + +# Get all vehicles from trackunit +# This is executing the 'Unit' request +vehicles = tu.get_unitlist() + +# Get history is executing 'Report/UnitHistory' +# Gets the history for the last 100 days +history = tu.get_history(vehicles[0]['id'],100) + +# Get extended data 'Report/UnitExtendedInfo' +# Gets the history for the last 100 days +data = tu.get_candata(vehicles[0]['id'],100) + +# Get faults 'Report/UnitActiveFaults' +# Gets the history for the last 100 days +data = tu.get_faults(vehicles[0]['id'],100) + +# The library supports processing multiple vehicles too +# For memory intensive requests it supports preprocessing requests +# By default it prints a progress bar when using this function. +# Returns an iterator allowing processing big data +for x, _id in tu.get_multi_history( ['123456', '234567'] , 365): + print(x, _id) +``` + +### Example async + +``` python +import asyncio +from pytrackunit.TrackUnit import TrackUnit + +async def main(): + # Create the API + # It loads the key from api.key by default + tu = TrackUnit(use_async_generator=True) + + # Get all vehicles from trackunit + # This is executing the 'Unit' request + vehicles = await tu.async_get_unitlist() + + # Get history is executing 'Report/UnitHistory' + # Gets the history for the last 100 days + history = await tu.async_get_history('123456',100) + + # Get extended data 'Report/UnitExtendedInfo' + # Gets the history for the last 100 days + data = await tu.async_get_candata('123456',100) + + # Get faults 'Report/UnitActiveFaults' + # Gets the history for the last 100 days + data = await tu.async_get_faults('123456',100) + + # The library supports processing multiple vehicles too + # For memory intensive requests it supports preprocessing requests + # By default it prints a progress bar when using this function. + # Returns an iterator allowing processing big data + # This is prefered if data gets bigger, because it only collects data when needed, + # thus reducing needed memory + async for x, _id in tu.get_multi_history( ['123456', '234567'] , 365): + print(x, _id) + +if __name__ == '__main__': + asyncio.run(main()) +``` + + + + +%package -n python3-pytrackunit +Summary: Easy access for TrackUnit REST API +Provides: python-pytrackunit +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-pytrackunit +# TrackUnitPython + +![test](https://github.com/einsteinmaster/TrackUnitPython/actions/workflows/test.yml/badge.svg) +![lint](https://github.com/einsteinmaster/TrackUnitPython/actions/workflows/pylint.yml/badge.svg) +![Coverage Status](https://coveralls.io/repos/github/kmodexc/TrackUnitPython/badge.svg?branch=main) + +Python API for Trackunit + +## What is this package + +This packages contains some usefull functions for an easy interface to TrackUnit's REST API. For information to the data see [here](https://dev.trackunit.com/docs). + +Features: +- caches requests for faster access +- for timespan's bigger than 30 days it sufficiantly devides it into allowed requests +- asyncio functions availeble +- if data is cached it can process 12000 cached requests with 20 million data points in under 5 minutes. +- uses sqlite to cache data efficiently +- requests throttle function (Trackunit-API limits to 50 requests per second) +- provides stream-based generators for processing of big data + +For more features write an issue [here](https://github.com/einsteinmaster/TrackUnitPython/issues/new). Pull requests are welcome. + +## How to use + +### Install + +Install the package via pip + +``` sh +pip install pytrackunit +``` + +Create a file in your execution directory with the name `api.key` which contains your TrackUnit API token. If that doesnt work for you, you can set the token in the constructor by calling `tu = TrackUnit(api_key="")`. + +### Example + +``` python +from pytrackunit.TrackUnit import TrackUnit + +# Create the API +# It loads the key from api.key by default +tu = TrackUnit() +# alternatively +tu = TrackUnit(api_key="") + +# Get all vehicles from trackunit +# This is executing the 'Unit' request +vehicles = tu.get_unitlist() + +# Get history is executing 'Report/UnitHistory' +# Gets the history for the last 100 days +history = tu.get_history(vehicles[0]['id'],100) + +# Get extended data 'Report/UnitExtendedInfo' +# Gets the history for the last 100 days +data = tu.get_candata(vehicles[0]['id'],100) + +# Get faults 'Report/UnitActiveFaults' +# Gets the history for the last 100 days +data = tu.get_faults(vehicles[0]['id'],100) + +# The library supports processing multiple vehicles too +# For memory intensive requests it supports preprocessing requests +# By default it prints a progress bar when using this function. +# Returns an iterator allowing processing big data +for x, _id in tu.get_multi_history( ['123456', '234567'] , 365): + print(x, _id) +``` + +### Example async + +``` python +import asyncio +from pytrackunit.TrackUnit import TrackUnit + +async def main(): + # Create the API + # It loads the key from api.key by default + tu = TrackUnit(use_async_generator=True) + + # Get all vehicles from trackunit + # This is executing the 'Unit' request + vehicles = await tu.async_get_unitlist() + + # Get history is executing 'Report/UnitHistory' + # Gets the history for the last 100 days + history = await tu.async_get_history('123456',100) + + # Get extended data 'Report/UnitExtendedInfo' + # Gets the history for the last 100 days + data = await tu.async_get_candata('123456',100) + + # Get faults 'Report/UnitActiveFaults' + # Gets the history for the last 100 days + data = await tu.async_get_faults('123456',100) + + # The library supports processing multiple vehicles too + # For memory intensive requests it supports preprocessing requests + # By default it prints a progress bar when using this function. + # Returns an iterator allowing processing big data + # This is prefered if data gets bigger, because it only collects data when needed, + # thus reducing needed memory + async for x, _id in tu.get_multi_history( ['123456', '234567'] , 365): + print(x, _id) + +if __name__ == '__main__': + asyncio.run(main()) +``` + + + + +%package help +Summary: Development documents and examples for pytrackunit +Provides: python3-pytrackunit-doc +%description help +# TrackUnitPython + +![test](https://github.com/einsteinmaster/TrackUnitPython/actions/workflows/test.yml/badge.svg) +![lint](https://github.com/einsteinmaster/TrackUnitPython/actions/workflows/pylint.yml/badge.svg) +![Coverage Status](https://coveralls.io/repos/github/kmodexc/TrackUnitPython/badge.svg?branch=main) + +Python API for Trackunit + +## What is this package + +This packages contains some usefull functions for an easy interface to TrackUnit's REST API. For information to the data see [here](https://dev.trackunit.com/docs). + +Features: +- caches requests for faster access +- for timespan's bigger than 30 days it sufficiantly devides it into allowed requests +- asyncio functions availeble +- if data is cached it can process 12000 cached requests with 20 million data points in under 5 minutes. +- uses sqlite to cache data efficiently +- requests throttle function (Trackunit-API limits to 50 requests per second) +- provides stream-based generators for processing of big data + +For more features write an issue [here](https://github.com/einsteinmaster/TrackUnitPython/issues/new). Pull requests are welcome. + +## How to use + +### Install + +Install the package via pip + +``` sh +pip install pytrackunit +``` + +Create a file in your execution directory with the name `api.key` which contains your TrackUnit API token. If that doesnt work for you, you can set the token in the constructor by calling `tu = TrackUnit(api_key="")`. + +### Example + +``` python +from pytrackunit.TrackUnit import TrackUnit + +# Create the API +# It loads the key from api.key by default +tu = TrackUnit() +# alternatively +tu = TrackUnit(api_key="") + +# Get all vehicles from trackunit +# This is executing the 'Unit' request +vehicles = tu.get_unitlist() + +# Get history is executing 'Report/UnitHistory' +# Gets the history for the last 100 days +history = tu.get_history(vehicles[0]['id'],100) + +# Get extended data 'Report/UnitExtendedInfo' +# Gets the history for the last 100 days +data = tu.get_candata(vehicles[0]['id'],100) + +# Get faults 'Report/UnitActiveFaults' +# Gets the history for the last 100 days +data = tu.get_faults(vehicles[0]['id'],100) + +# The library supports processing multiple vehicles too +# For memory intensive requests it supports preprocessing requests +# By default it prints a progress bar when using this function. +# Returns an iterator allowing processing big data +for x, _id in tu.get_multi_history( ['123456', '234567'] , 365): + print(x, _id) +``` + +### Example async + +``` python +import asyncio +from pytrackunit.TrackUnit import TrackUnit + +async def main(): + # Create the API + # It loads the key from api.key by default + tu = TrackUnit(use_async_generator=True) + + # Get all vehicles from trackunit + # This is executing the 'Unit' request + vehicles = await tu.async_get_unitlist() + + # Get history is executing 'Report/UnitHistory' + # Gets the history for the last 100 days + history = await tu.async_get_history('123456',100) + + # Get extended data 'Report/UnitExtendedInfo' + # Gets the history for the last 100 days + data = await tu.async_get_candata('123456',100) + + # Get faults 'Report/UnitActiveFaults' + # Gets the history for the last 100 days + data = await tu.async_get_faults('123456',100) + + # The library supports processing multiple vehicles too + # For memory intensive requests it supports preprocessing requests + # By default it prints a progress bar when using this function. + # Returns an iterator allowing processing big data + # This is prefered if data gets bigger, because it only collects data when needed, + # thus reducing needed memory + async for x, _id in tu.get_multi_history( ['123456', '234567'] , 365): + print(x, _id) + +if __name__ == '__main__': + asyncio.run(main()) +``` + + + + +%prep +%autosetup -n pytrackunit-2.4.1 + +%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-pytrackunit -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 10 2023 Python_Bot - 2.4.1-1 +- Package Spec generated diff --git a/sources b/sources new file mode 100644 index 0000000..c66f09d --- /dev/null +++ b/sources @@ -0,0 +1 @@ +457757f4bc58daf8933982009a9dc42b pytrackunit-2.4.1.tar.gz -- cgit v1.2.3