Skip to main content

Common tooling for Brinkhaus industrial applications

Project description

brinkhaustools

Common infrastructure toolkit for Brinkhaus industrial applications.

What is brinkhaustools?

brinkhaustools is a Python package providing reusable components for industrial monitoring and control applications. Zero external dependencies for the core — just the Python standard library.

It bundles:

  • App -- central wiring object that connects all components
  • ShutdownHandler -- graceful shutdown with signal handling and cleanup hooks
  • LoggingHelper -- rotating file logs with an in-memory ring buffer
  • Settings -- thread-safe JSON settings with hierarchical key access
  • SelfDiagnosisEngine -- error/warning tracking with numeric codes and timeouts
  • StatusEngine -- periodic status collection from pluggable sources
  • HeartbeatEngine -- watchdog for detecting hung threads
  • VersionInformation -- CI-generated version metadata
  • Fleet management -- HTTPS-based reporting to BrinkhausFleetManager
  • RestServer -- Flask + Waitress HTTP server with standard endpoints

Quick Example

from brinkhaustools.common import App

app = App(
    name="my-service",
    settings_path="data/settings/settings_main.json",
    fleet_config_path="fleetManagementData/config.json",
    version_file="helper/version.json",
)
app.start()
app.wait()  # blocks until shutdown

Installation

pip install brinkhaustools

Optional Extras

Extra What it adds
rest Flask, Waitress, bcrypt -- needed for RestServer
dev pytest, mypy -- development tools
pip install brinkhaustools[rest]

Requirements: Python >= 3.10. The core has no external dependencies.

Getting Started

The App Object

App wires together all components with sensible defaults:

Attribute Component Default config
app.shutdown ShutdownHandler always created
app.logging LoggingHelper data/logs/
app.settings Settings data/settings/settings_main.json
app.diagnosis SelfDiagnosisEngine always created
app.status StatusEngine always created
app.heartbeat HeartbeatEngine 300s default timeout
app.version VersionInformation helper/version.json
app.fleet StatusMonitor fleetManagementData/config.json

Pass None to skip any component:

app = App(name="my-service", settings_path=None, fleet_config_path=None)

Settings

timeout = app.settings.get(["expert", "timeout"], default=300)
# or with dot-notation:
timeout = app.settings.get("expert.timeout", default=300)

Diagnostics

app.diagnosis.notify(code=1001, message="Database unreachable", critical=True)
app.diagnosis.clear(code=1001)

Heartbeat Watchdog

app.heartbeat.register("main-loop", timeout_sec=60)

while not app.shutdown.is_shutdown():
    app.heartbeat.register("main-loop", timeout_sec=60)  # refresh
    do_work()

Fleet Management

Report status and diagnostics to BrinkhausFleetManager by placing a fleetManagementData/config.json:

{
    "fleetmanagement": {
        "customer_name": "my-customer",
        "machine": "machine-01",
        "broker": "fleet.brinkhaus-gmbh.de",
        "heartbeat_interval_sec": 60,
        "token": "fmt_..."
    }
}

Diagnostics are automatically forwarded to the FleetManager when App is started with a fleet config.

REST Server

Install the rest extra, then:

from brinkhaustools.rest import RestServer

server = RestServer(app=app, port=8080)
server.start()
app.wait()

Graceful Shutdown

app.wait()                          # block until SIGTERM/SIGINT
app.shutdown.trigger()              # or trigger programmatically

Documentation

Full API reference, guides, and configuration details are available on the documentation site:

brinkhaus.gitlab.io/brinkhaustools

License

MIT

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

brinkhaustools-0.2.2.tar.gz (34.9 kB view details)

Uploaded Source

Built Distribution

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

brinkhaustools-0.2.2-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file brinkhaustools-0.2.2.tar.gz.

File metadata

  • Download URL: brinkhaustools-0.2.2.tar.gz
  • Upload date:
  • Size: 34.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for brinkhaustools-0.2.2.tar.gz
Algorithm Hash digest
SHA256 0769f0b48e852041398782c6a1f3a3b5235924761f95e8a6b4e0f159fc1fa8a9
MD5 e52cd95691d6ab4e362c8f36543c4686
BLAKE2b-256 1dc3d051742e900e5f8a06adc965c9aea2f1bbe646696c5adcf6f64b982b0132

See more details on using hashes here.

File details

Details for the file brinkhaustools-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: brinkhaustools-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for brinkhaustools-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 01ad582f555125e90a44127689260074ef2b77c81182748bcc3dac7d6ae2d4e5
MD5 c81a68609dbfa48dbd01bb889931a1e3
BLAKE2b-256 626557c8fc4ac84d9ea3c4251beb70afb986af195277c5e0efe5561938e8819d

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