efficient-app - Simple Scripting Wrapper
Script configuration and logging setup
Usage
Here's an example of a simple entry to a script, it also uses the package 'efficient-args', but that isn't required to use this package, the args just need to be returned as a dictionary:
from kisspy.decorators.pidFile import pidFile
from efficient_args import FORMATTER, addBaseArgs, parseArgs
from efficient_app import appWrapper
import argparse
import logging
import time
def getArgs() -> dict:
parser = argparse.ArgumentParser(description="Example App", formatter_class=FORMATTER)
addBaseArgs(parser, addEnvironment=True)
return parseArgs(parser)
@pidFile()
@appWrapper("myapp", cmdArgs=getArgs())
def yourProgramStartPoint(*args, **kwargs):
logger = logging.getLogger(__name__)
logger.debug("Do A Bunch Of Stuff Here!")
# raise Exception("Doh!!")
logger.info("KWARGS: {}".format(kwargs))
time.sleep(1)
logger.info("Done!!")
if __name__ == "__main__":
yourProgramStartPoint()
The kwargs dict passed into the start point method looks like this, obviously the actual data would look different, but from there you can call your methods...
{
"appCfgDir": "wkdir/test/cfg/",
"appCfg": {
"dbConn": "host=<fqhostname> dbname=<dbname> user=<usr> password=<pswd>",
"api": {
"baseUrl": "<http://baseurl>",
"apiKey": "<apikey>"
}
},
"appArgs": {
},
"cmdArgs": {
"environment": "test"
}
}
By default, the configuration and log files are created in this structure at the root of the project directory:
wkdir/
├── prod
│ ├── cfg
│ │ ├── appCfg.json
│ │ └── logCfg.json
│ └── logs
│ ├── appLog.txt
│ └── unhandled_exc_20260320T002548.txt
└── test
├── cfg
│ ├── appCfg.json
│ └── logCfg.json
└── logs
├── appLog.txt
├── appLog.txt.2026-03-12
├── appLog.txt.2026-03-17
├── unhandled_exc_20260312T202100.txt
└── unhandled_exc_20260312T202244.txt
Note that when the script encounters an unhandled exception, it will save the stack trace to a date and time stamped file for reference. This occurs when the app first runs, as it creates a default app config file and assumes the default isn't going to cut it. Edit to your hearts content and re-run.
The package also contains two methods to assist with temp directories:
from efficient_app import createDTUniqueTempDir, cleanUpTempDirs
from datetime import timedelta
# create the temp directory
dirPath = createDTUniqueTempDir(baseDir="wkdir/dev/files/")
# ...
# do some stuff with the files added to the directory
# ...
# at some point in the future, if you want to clean it up...
cleanUpTempDirs(baseDir="wkdir/dev/files/", olderThan=timedelta(days=90))
Installation
Using In Projects
Installation:
pip install efficient-app
Cloning For Development
Set up a virtual environment. Once an environment is set up, run the command below to:
- validate the environment variable
- activate the environment (if not already activated)
- install all of the necessary packages into the local environment
pip install -U -r requirements/dev.txt
The dev.txt file includes:
- BLACK, a code formatter, see notes at the bottom of this file for details
Dependancies
This project uses the following projects:
- kisspy-python
- distlib
Tests
To run tests:
python -m unittest discover -s tests/
Code Formatting
Code formatting is done using BLACK. BLACK allows almost no customization to how code is formatted with the exception of line length, which has been set to 119 characters.
Use the following to bulk format files:
black . -l 144
Creating A New Release
Please do the following when making a new release, most are documented above:
- Run tests
- Code format
- Be sure to update the change log and _metadata.json with version and notes
- git add, commit, and push changes
- run the following code to generate a wheel:
python -m build
Metadata
Release files for efficient-app 0.5.0
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 |
|---|---|---|---|---|
| efficient_app-0.5.0.tar.gz | 11.8 kB | With provenance | Details for efficient_app-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| efficient_app-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for efficient_app-0.5.0-py3-none-any.whl |
Total release size: 24.1 kB
Release files / efficient_app-0.5.0.tar.gz
| Download URL | efficient_app-0.5.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
118756da0b4d66ea28ff6dc69455506c5273e612c4103c688155f927ffd0646f
|
|
BLAKE2b-256 checksum How to use checksums |
ae47d6713b2af82bb3fe5eff752f47803da5c42cdb9ce71c0b76ebac617ba0f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 8, 2026.
Transparency logRelease files / efficient_app-0.5.0-py3-none-any.whl
| Download URL | efficient_app-0.5.0-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d8178b44ff3505473415964d6c74dda9d26fa25d9b2672f7e69e2b2e25343d7
|
|
BLAKE2b-256 checksum How to use checksums |
71c46718e4e603f9bb0a4efb33946c3bc8dbf8853f0666de5223fed33bd83b53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 8, 2026.
Transparency logSecurity for efficient-app 0.5.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for efficient_app-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 8, 2026.
Transparency logA 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.