Skip to main content

A library to monitor information sources

Project description

pyAttention

A library to monitor information sources

build codecov

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 install sqlalchemy
$ pip install aiosqlite  # For sqlite database support
$ pip install asyncpg    # For PostgreSQL
$ pip install aiomysql   # For mySQL

# RSS Feeds
$ pip install httpx lxml beautifulsoup4

# socketIO services
$ pip install python-socketio[client]==4.6.* aiohttp

# Local system data
$ pip install 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 guy', '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


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.2.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

pyattention-0.1.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file pyattention-0.1.2.tar.gz.

File metadata

  • Download URL: pyattention-0.1.2.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.5.0

File hashes

Hashes for pyattention-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8c005a678e62120bcfee6c9e91439096c01d037ec4d188b8faace10b467a4b3b
MD5 05fa937054f12f33bcae4d85b3189c05
BLAKE2b-256 726722d25fbe8d443f88405f081468e1fcf54a742b1cd4d18ae8de0cb3c3b432

See more details on using hashes here.

File details

Details for the file pyattention-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyattention-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.5.0

File hashes

Hashes for pyattention-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 90c75e9ebca052d99ac2b5798bb57a6c49d0ae7722f8f54eef3f866f73e821d2
MD5 6e22409f5410094adde79ad822055e26
BLAKE2b-256 aec8eb174c13798297ecb5203199196fc2cde73caa5696a4e222b43846cb77be

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page