A library to monitor information sources
Project description
pyAttention
A library to monitor information sources
Key Features
- Retrieves data from TCP servers, socketIO services, RSS feeds, and SQL databases
- Retrieves basic system data from linux-based computers (disk space, IP address, temperatures)
- Provides a queue interface for retrieving received information
- Supports polling and asynchronous monitoring
- Sources can be run individually or monitored together as a collection
- Sources run in their own thread or can share a thread across a collection
Installation
# Installation from pypi
pip pyAttention
# or
# Installation from github
$ git clone https://github.com/dhrone/pyAttention
# Install optional dependencies
# Databases
$ pip sqlalchemy
$ pip aiosqlite # For sqlite database support
$ pip asyncpg # For PostgreSQL
$ pip aiomysql # For mySQL
# RSS Feeds
$ pip httpx, lxml, beautifulsoup4
# socketIO services
$ pip python-socketio[client]=^4.6.1, aiohttp
# Local system data
$ pip psutil, netifaces
Quickstart
To retrieve data from a RSS feed
from pyattention.source import rss
# EXAMPLE: Pull 3 day forecast of Manchester, UK from the BBC News RSS feed
url = 'https://weather-broker-cdn.api.bbci.co.uk/en/forecast/rss/3day/2643123'
from pyattention.source import rss
src = rss(url, frequency=21600) # Query feed every 6 hours
weather = src.get()
To retrieve data from a socketIO service
# EXAMPLE: monitor Volumio metadata from its socketIO API (see https://volumio.org)
from pyattention.source import socketIO
url = 'http://localhost:3000'
src = socketIO(url)
async def callback(data):
await src.put(data)
src.subscribe('pushState', callback)
src.emit('getState') # Command needed to get Volumio to send a pushState message
state = src.get()
To retrieve data from a database
# EXAMPLE: pull data from a locally stored sqlite database
# Create test db
import sqlite3
con = sqlite3.connect('songs.db')
cur = con.cursor()
cur.execute('''CREATE TABLE songs (artist text, title text, album text)''')
cur.execute('''INSERT INTO songs VALUES ('Billie Eilish', 'bad buy', 'When We All Fall Asleep, Where Do We Go?')''')
cur.close()
from pyattention.source import database
uri = 'sqlite+aiosqlite:///./songs.db'
src = database(uri, 'select * from songs')
songs = src.get()
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
pyAttention-0.1.0.tar.gz
(13.8 kB
view details)
Built Distribution
File details
Details for the file pyAttention-0.1.0.tar.gz
.
File metadata
- Download URL: pyAttention-0.1.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.9.1 Darwin/18.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5aaca5841d9fc5f9252c05d904922b838eb3b232436ccce872f77ae2404fc2f |
|
MD5 | 4dda9e163980c506ef69bdfc2485d565 |
|
BLAKE2b-256 | f1eb38e274bc50a092c856d54abe1968bd03d4158cec6eb5ba8edaa224f91d55 |
File details
Details for the file pyAttention-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pyAttention-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.9.1 Darwin/18.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c969796b1a3dc494d1350213903a3d7cbd391b7da70dec0cfbabe4106fb5306 |
|
MD5 | 2e591ec56026e7cd13f15ac32b62c96b |
|
BLAKE2b-256 | bcc80d2a3da22ed25d4ccdaf174f8081518188d1f48d79a37a8102a9cabcb2bd |