Skip to content
Snippets Groups Projects
Commit d2cfc992 authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Fix config fuckery

parent 1b927ff1
Branches
No related tags found
No related merge requests found
......@@ -70,8 +70,8 @@ def initialize_config(application_name: str, default_config: str, app) -> dict:
config_path_environment_variable = "{}_CONFIG_PATH".format(application_name.upper().replace(" ", "_").replace("-", "_"))
# If the environment variable is set, use that as a config path, otherwise use the default one
config_dir = this_or_else(os.environ.get(config_path_environment_variable), dirs["config"])
config_path = "{}/config.toml".format(config_dir.rstrip("/"))
config_dir = this_or_else(os.environ.get(config_path_environment_variable), dirs["config"]).rstrip("config.toml")
config_path = "{}/config.toml".format(config_dir.rstrip("/").rstrip("config.toml"))
# Create the config_dir if it doesn't exist
if not Path.is_dir(Path(config_dir)):
......@@ -83,9 +83,8 @@ def initialize_config(application_name: str, default_config: str, app) -> dict:
app.logger.error("Error: Not sufficient permissions to create config directory at {} (Running {} as user {})".format(config_dir, application_name, getpass.getuser()))
app.logger.error("Consider creating {} manually with write permissions for {}. After initial write of default config.toml on the first run {} won't write that file ever again".format(config_dir, getpass.getuser(), application_name), file=sys.stderr)
exit(1)
except Error as e:
app.logger.error(e)
except FileExistsError as e:
app.logger.debug("Config dir at {} already existed".format(config_dir))
# Create a default config if it does exist
if not Path.is_file(Path(config_path)):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment