diff --git a/README.md b/README.md index 941207223d782cdee306dfa1ab2e30057d697f71..93eedd5c42bf4cf90a29dbddbf7fde12bd74536d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ import common_config from common_config import initialize_config, read_settings, main # Name of this application, used in directory names, etc -APPLICATION_NAME = "eigenservice" +APPLICATION_NAME = "my_application" # suffix added to the config files (e.g. `00-suffix.toml`) SUFFIX = "config" diff --git a/common_config/__init__.py b/common_config/__init__.py index 0d72cd9006d93c7b9e50273517ffb053e7df19f0..f8fb29d3d1b2617a9de70d6b220a3196f47d3b1d 100644 --- a/common_config/__init__.py +++ b/common_config/__init__.py @@ -1,2 +1,2 @@ -__version__ = '0.1.3' +__version__ = '0.1.4' from common_config.common import * \ No newline at end of file diff --git a/common_config/common.py b/common_config/common.py index d7288b34bca2dae895eccdf023fdee5c6e5bae7f..27ea294df67b10d713537ca55ecffe58ace678ad 100644 --- a/common_config/common.py +++ b/common_config/common.py @@ -389,7 +389,9 @@ def create_config(): print("Error: Didn't have the permissions to create the config directory at {}".format(selection["path"]), file=sys.stderr) print("Hint: Change the owner of the directory temporarily to {} or run {} config create with more permissions".format(getpass.getuser(), APPLICATION_NAME)) - subprocess.call(['sudo', 'python3', *sys.argv]) + # Run again with priviledges + python_path = f"{sys.prefix}/bin/python3" + subprocess.call(['sudo', python_path, *sys.argv]) sys.exit() config_path = Path(f"{selection['path']}/00-{SUFFIX}.toml") diff --git a/examples/config.py b/examples/config.py new file mode 100644 index 0000000000000000000000000000000000000000..e211a40bc90e40ccaeeceff0e53dfc7b55c4031d --- /dev/null +++ b/examples/config.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +#-*- coding: utf-8 -*- +import common_config +from common_config import initialize_config, read_settings, main + +# Name of this application, used in directory names, etc +APPLICATION_NAME = "my_application" + +# suffix added to the config files (e.g. `00-suffix.toml`) +SUFFIX = "config" + +# Do not change here, just use an override instead +DEFAULT_CONFIG = """ +[application] +loglevel = "info" +level = 9001 +mood = "very" +""" + +# Override the global variables in the common-config.common module +common_config.common.APPLICATION_NAME = APPLICATION_NAME +common_config.common.SUFFIX = SUFFIX +common_config.common.DEFAULT_CONFIG = DEFAULT_CONFIG + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml index 516208ab00e7351add521c7c87b08c3f749208e5..b0f526974ace3c4c53803840fbbf12fd21249f80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "common-config" -version = "0.1.3" +version = "0.1.4" description = "A config library for eigenservice" authors = ["David Huss <dh@atoav.com>"]