Customized App mainline helper
Project description
An opinionated class to build a mainline executable.
Usage
from my_app import MyApp, VERSION
from delfick_app import App
import logging
class MyApp(App):
# Setting both VERSION and boto_useragent_name
# Will change boto's useragent to include {name}/{VERSION}
# Not setting them means boto's useragent is unchanged
VERSION = VERSION
boto_useragent_name = "myapp"
# Cli options for configuration special cli options
cli_categories = ['app']
cli_description = "My amazing app"
cli_environment_defaults = {"CONFIG_LOCATION": ("--config", './config.yml')}
cli_positional_replacements = [('--task', 'list_tasks'), '--environment']
def execute(self, args, cli_args, logging_handler):
app = MyApp()
app.start(cli_args)
def setup_other_logging(self, args, verbose=False, silent=False, debug=False):
logging.getLogger("boto").setLevel([logging.CRITICAL, logging.ERROR][verbose or debug])
def specify_other_args(self, parser, defaults):
parser.add_argument("--task"
, help = "The task to execute"
, **defaults['--task']
)
parser.add_argument("--environment"
, help = "the environment to use"
, **defaults["--environment"]
)
parser.add_argument("--config"
, help = "The configuration to use"
, **defaults["--config"]
)
main = MyApp.main
if __name__ == '__main__':
main()
With the above configuration, the following three usages are equivalent:
$ ./app.py some_task dev --config ./config.yml $ ./app.py --task some_task --environment dev --config ./config.yml $ APP_CONFIG=./config.yml ./app.py some_task dev
Installation
Just use pip:
$ pip install delfick_app
Tests
Run the following:
$ mkvirtualenv delfick_app $ workon delfick_app $ pip install -e . $ pip install -e ".[tests]"
To install delfick_app and it’s dependencies.
Then to run the tests:
$ ./test.sh
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
delfick_app-0.5.tar.gz
(5.4 kB
view details)
File details
Details for the file delfick_app-0.5.tar.gz.
File metadata
- Download URL: delfick_app-0.5.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77e0ad187a2ca3e566df0c6066d899abeeda0c57a6e30d609a26baf4fc2198e0
|
|
| MD5 |
1b81fa71f9d4321e87d7143a551ff9de
|
|
| BLAKE2b-256 |
41592802a458c452013c7a26c31f1dc0530e9cc02f20be9cad2a281d9549504e
|