Useful tools I need in many projects.
Project description
obelixtools
- Install it with
pip install obelixtools
API
This is a small wrapper I wrote around the requests library. It has some extra features like a speedtest and connectivity check.
Basic use
from obelixtools import API
endpoint = API(url, 'json')
endpoint.query()
print(endpoint.content)
Speedtest and connectivity check
% python -m obelixtools
06-Oct-19 11:28:44 - obelixtools - INFO: Performing selftest with https://1.1.1.1
06-Oct-19 11:28:44 - obelixtools - INFO: Connected to the internet.
06-Oct-19 11:28:44 - obelixtools - INFO: Performing speedtest with http://speedtest.belwue.net/100M
06-Oct-19 11:29:11 - obelixtools - INFO: Connection speed is 3MB/sµ
Variables
.url : str
The URL of the API.
.format : str
Define a certain data format for the data return by the API. This can by either json, xml or raw. Any other value will sit it to raw.
.content
The content of the API response after postprocessing. Postprocessing happens by setting .format
Methods
.query(url : str, optional) -> bool
Fetched the data from the API if the age of the existing data in .content is older than .last_update. This timeout is ignored if url is set (useful for speedtests).
.check_connection(url='https://1.1.1.1', timeout=5) -> bool
Fetches the given url and and returns True if the servers returns a status code 200 and False otherwise. Comprehensive log messages are passed to the loggin module.
.speedtest(url='http://speedtest.belwue.net/100M') -> bool
Downloads the file provided at the given url and returns the speed in bytes per second. The logging module received a log message with humand readable speed (e.g. kB/s, MB/s...)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file obelixtools-1.1.1.tar.gz
.
File metadata
- Download URL: obelixtools-1.1.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/2.7.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d01956b00dd1e97457bcb1f9bf6becaba114329d75cb896ffbf10da702139970 |
|
MD5 | 155180d2c5adc138554f847f97dd20d3 |
|
BLAKE2b-256 | be4d40d610593d194c2b436a841b97884050dea28ca8b0f4e2c7230a46165b5d |
File details
Details for the file obelixtools-1.1.1-py2-none-any.whl
.
File metadata
- Download URL: obelixtools-1.1.1-py2-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/2.7.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89417ac3b3dd88081a947aa6d2edebdc6b5bfb1e826bf3b3da2c891ad6f90461 |
|
MD5 | 16c628728d43c96c4c0bd2acd58191d8 |
|
BLAKE2b-256 | c08798f61e7e1e6208b771a20fdce348fe61b3fcacde78813e376e605a0875d2 |