Skip to main content

An application framework promoting consistency

Project description

alx-common

A comprehensive Python framework for infrastructure automation, monitoring, and reporting. Designed to standardize common development tasks and eliminate code duplication in production environments.


Preamble

On first invocation, if the directory $HOME/.config/alx (or %APPDATA%/alx on Windows) is not found, then it is created along with the following files:

  • alx.ini: The module configuration file which should be used to override settings in the defaults found in alx.ini in the installed module directory
  • env: This file contains the path to the virtual environment in use and is set to the current python used to execute a script using alx-common
  • key: An encryption key used to encrypt and decrypt strings. If there are multiple developers, then it is wise to share the key so the configuration file can remain consistent. This file must be stored readable only by the user and not shared. The command to create a key is:
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

These files can (and should) be modified to suit your needs. For example, changing alx.ini and adding

[mail]
from:   Application User <valid@email.address>

would be a good idea.


Summary

alx-common provides a consistent foundation for building reliable internal applications that deal with:

  • ✅ Configuration management
  • ✅ Argument parsing
  • ✅ Different environment handling: dev, test, prod
  • ✅ Secure password, etc. handling with encryption
  • ✅ Logging (including file rotation, maximum size and console output)
  • ✅ Database utilities (MySQL, MariaDB, SQLite, PostgreSQL)
  • ✅ HTML report generation
  • ✅ Email notifications (plain, HTML, attachments, inline images)
  • ✅ Monitoring integrations (ITRS Geneos support)
  • ✅ Lightweight internal automation tools

Originally designed to simplify and standardize automation scripts, reporting jobs, monitoring pipelines, and operational tooling across real-world production environments. The aim of alx-common is to reduce hard coding and duplication of snippets.

Too many times, I have seen developers share code to 'send an email'. Then the mailhost changes and there are 200 scripts to fix. Or a shell script is copied and something edited to create a wrapper to start a python script. Or the same code is used over and over to set up logging or read a configuration file coupled with a lot of hard coding an inconsistencies.

Bad practice is endemic in the developer community as there are too many coders adopting a cut-and-paste mentality.

The name comes from my company, ALX Solutions which is no longer in operation but now lives on in PyPI and GitHub!


Features

  • Application Framework (alx.app.ALXapp)

    • Simplified argparse-based CLI definition
    • Config-driven parameter management (alx.ini)
    • Environment separation (dev/test/prod)
    • Secure password storage (Fernet encryption)
    • Dynamic path management (logs, data, config)
    • Application configuration automatically parsed and stored in alx.app.ALXapp object
    • Centralized logger management handled providing automatic house-keeping based on configuration
  • Database Utilities (alx.db_util.ALXdatabase)

    • Simplifies open source database access
    • Auto-formatted SQL logging
    • Centralized connection lifecycle
    • Transaction management
    • Simplified execution mechanism
  • Reporting (alx.html.ALXhtml)

    • Easy HTML generation
    • Promotes tidy and consistent code
  • Email creation (alx.mail.ALXmail)

    • Supports plaintext and html formats
    • Easy email formatting and sending
    • Flexible
    • Integrated with SMTP servers, attachments, and inline images
  • String manipulation (strings.py)

    • Commonly used string manipulation routines
  • ITRS Geneos Alerts (alx.itrs.alert.HtmlAlert)

    • Provides a consistent way to parse the environment on an event
    • A standard alert in html / table format
    • A class to create a toolkit sampler without the need to know internal details (alx.itrs.toolkit.Toolkit)
    • Standardised environment parsing (alx.itrs.environment.Environment)

Examples

Please refer to the files in the examples directory

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

alx_common-2.8.0.tar.gz (38.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alx_common-2.8.0-py3-none-any.whl (38.3 kB view details)

Uploaded Python 3

File details

Details for the file alx_common-2.8.0.tar.gz.

File metadata

  • Download URL: alx_common-2.8.0.tar.gz
  • Upload date:
  • Size: 38.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for alx_common-2.8.0.tar.gz
Algorithm Hash digest
SHA256 1e632b50ecce427ffccfb3f6d605d85c2ebfc0f281ced02401273ea3d3c913d8
MD5 ab401503aa986f4e1b98f043b2912f37
BLAKE2b-256 80d29ac8dbb402c82aea8b03124f4b95c85fcf5ef3429e9bb812ab8814326f41

See more details on using hashes here.

File details

Details for the file alx_common-2.8.0-py3-none-any.whl.

File metadata

  • Download URL: alx_common-2.8.0-py3-none-any.whl
  • Upload date:
  • Size: 38.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for alx_common-2.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6e670235a5a6e8409041eb0f327d173b511db593112f66f00aee4d02824ec33
MD5 527a1f3e53d94d1709d8897ec92c95ee
BLAKE2b-256 b7a9bde4d873c49a7c593da3ad684543b97fc034c98489718a1f34b04eccdefc

See more details on using hashes here.

Supported by

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