Simple Scripting Wrapper
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file efficient_app-0.5.0.tar.gz.
File metadata
- Download URL: efficient_app-0.5.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
118756da0b4d66ea28ff6dc69455506c5273e612c4103c688155f927ffd0646f
|
|
| MD5 |
6d5a007d5575bcdc688510957aa3ad9e
|
|
| BLAKE2b-256 |
ae47d6713b2af82bb3fe5eff752f47803da5c42cdb9ce71c0b76ebac617ba0f7
|
Provenance
The following attestation bundles were made for efficient_app-0.5.0.tar.gz:
Publisher:
publish.yml on joemarchionna/efficient_app
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
efficient_app-0.5.0.tar.gz -
Subject digest:
118756da0b4d66ea28ff6dc69455506c5273e612c4103c688155f927ffd0646f - Sigstore transparency entry: 1475444950
- Sigstore integration time:
-
Permalink:
joemarchionna/efficient_app@3a1790180caaa1068e2a67688b7c3303a566e17c -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/joemarchionna
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3a1790180caaa1068e2a67688b7c3303a566e17c -
Trigger Event:
release
-
Statement type:
File details
Details for the file efficient_app-0.5.0-py3-none-any.whl.
File metadata
- Download URL: efficient_app-0.5.0-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d8178b44ff3505473415964d6c74dda9d26fa25d9b2672f7e69e2b2e25343d7
|
|
| MD5 |
f7275309ed35b60273283c96be551e36
|
|
| BLAKE2b-256 |
71c46718e4e603f9bb0a4efb33946c3bc8dbf8853f0666de5223fed33bd83b53
|
Provenance
The following attestation bundles were made for efficient_app-0.5.0-py3-none-any.whl:
Publisher:
publish.yml on joemarchionna/efficient_app
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
efficient_app-0.5.0-py3-none-any.whl -
Subject digest:
4d8178b44ff3505473415964d6c74dda9d26fa25d9b2672f7e69e2b2e25343d7 - Sigstore transparency entry: 1475444998
- Sigstore integration time:
-
Permalink:
joemarchionna/efficient_app@3a1790180caaa1068e2a67688b7c3303a566e17c -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/joemarchionna
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3a1790180caaa1068e2a67688b7c3303a566e17c -
Trigger Event:
release
-
Statement type: