diff --git a/common_config/__init__.py b/common_config/__init__.py index f8fb29d3d1b2617a9de70d6b220a3196f47d3b1d..4e0b0941db63dd365f52346d95dfd5dd68f8ec3e 100644 --- a/common_config/__init__.py +++ b/common_config/__init__.py @@ -1,2 +1,2 @@ -__version__ = '0.1.4' +__version__ = '0.1.6' from common_config.common import * \ No newline at end of file diff --git a/common_config/common.py b/common_config/common.py index 27ea294df67b10d713537ca55ecffe58ace678ad..dc1ae1fa88c498d0c36fd3b3646a86717bbb2d55 100644 --- a/common_config/common.py +++ b/common_config/common.py @@ -385,12 +385,13 @@ def create_config(): try: selection["path"].mkdir(mode=0o755, parents=True, exist_ok=True) except PermissionError: + python_path = f"{sys.prefix}/bin/python3" print() - 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)) + print(f"Error: Didn't have the permissions to create the config directory at {selection['path']}", file=sys.stderr) + print(f"Hint: Change the owner of the directory temporarily to {getpass.getuser()} or run {APPLICATION_NAME} config create with more permissions", file=sys.stderr) + print(f"Hint: The python executable used by this script is located at \"{python_path}\"", file=sys.stderr) # Run again with priviledges - python_path = f"{sys.prefix}/bin/python3" subprocess.call(['sudo', python_path, *sys.argv]) sys.exit() @@ -423,12 +424,16 @@ def create_config(): try: config_path.write_text(DEFAULT_CONFIG) except PermissionError as e: + python_path = f"{sys.prefix}/bin/python3" print() print(f"Error: Didn't have the permissions to write the file to {config_path}", file=sys.stderr) print(f" Directory \"{selection['path']}\" belongs to user {selection['path'].owner()} (was running as user {getpass.getuser()})", file=sys.stderr) print() print(f"Hint: Change the owner of the directory temporarily to {getpass.getuser()} or run {APPLICATION_NAME} config create with more permissions") - exit() + print(f"Hint: The python executable used by this script is located at \"{python_path}\"", file=sys.stderr) + # Run again with priviledges + subprocess.call(['sudo', python_path, *sys.argv]) + sys.exit() print(f"Default Config has been written to {config_path}") diff --git a/pyproject.toml b/pyproject.toml index b0f526974ace3c4c53803840fbbf12fd21249f80..626276e6f0c2a36435b7156bede919ebd37b73be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "common-config" -version = "0.1.4" +version = "0.1.6" description = "A config library for eigenservice" authors = ["David Huss <dh@atoav.com>"]