modulepy
easily build modular applications
installation
pip3 install modulepy
# or
pip3 install git+https://github.com/nbdy/modulepy
features
- process based module baseline
- module loader
- one-line module loading
- one-line directory loading
- module manager
- add module
- remove module
- reload module directory
- module dependency resolution
- ipc
- module fault detection
example
main.py
from time import sleep
from modulepy.Manager import Manager
from pathlib import Path
if __name__ == '__main__':
manager = Manager(Path.cwd() / "modules")
try:
manager.start()
while manager.data.get("do_run"):
sleep(0.1)
except KeyboardInterrupt:
manager.stop()
manager.join()
modules/GPS.py
from typing import Optional
from gps import gps, WATCH_ENABLE
from modulepy import log
from modulepy.Base import Base, Information, Version
class GPS(Base):
information = Information("GPS", Version(1, 0, 0))
client: Optional[gps] = None
def on_start(self):
log.debug("Creating GPS client")
try:
self.client = gps(mode=WATCH_ENABLE)
log.debug("Created client")
self.data.set("error", None)
except ConnectionRefusedError:
self.data.set("error", "ConnectionRefusedError")
log.error("Could not create client")
pass
def on_stop(self):
log.debug("Closing GPS client")
if self.client:
self.client.close()
def work(self):
if self.client:
self.client.next()
self.data.set("latitude", self.client.fix.latitude)
self.data.set("longitude", self.client.fix.longitude)
self.data.set("altitude", self.client.fix.altitude)
self.data.set("speed", self.client.fix.speed)
self.data.set("track", self.client.fix.track)
self.data.set("satellites", self.client.satellites)
self.data.set("timestamp", self.client.utc)
modules/UI.py
from modulepy.Base import Base, Information, Version
from modulepy import log
from pyray import *
class UI(Base):
information = Information("TestUI", Version(1, 0, 0))
dependencies = [Information("Manager", Version(1, 0, 0)), Information("GPS", Version(1, 0, 0))]
def on_start(self):
log.debug("Initializing window")
init_window(800, 600, "TestUI")
set_target_fps(30)
self.data.text = "init text"
def on_stop(self):
log.debug("Closing window")
close_window()
def work(self):
error = self.clients["GPS"].get("error")
if error is None:
error = "None"
begin_drawing()
clear_background(BLACK)
draw_text(error, 100, 100, 24, GREEN)
if not error:
draw_text("Client is not connected", 100, 120, 18, RED)
else:
draw_text("Connected client", 100, 120, 18, GREEN)
end_drawing()
tmp = window_should_close()
self.data.set("do_run", not tmp)
if tmp:
print("Setting manager do_run to false")
self.clients["Manager"].set("do_run", False)
Metadata
Release files for modulepy 0.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| modulepy-0.18.tar.gz | 6.0 kB | Without provenance | Details for modulepy-0.18.tar.gz |
Release files / modulepy-0.18.tar.gz
| Download URL | modulepy-0.18.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f84685abf897c7b543d391c1e83bfde74c9bbe03cfa9e2c6ce73ac392555e69
|
|
BLAKE2b-256 checksum How to use checksums |
dbcadd948dd29c8ad834fa12aa5733b709799e1c216f4d1993db853cdb0df04f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Security for modulepy 0.18
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.