From 69596de7a3520a26646f1eb05e18b716704c7d74 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 3 Jan 2020 09:16:28 +0100 Subject: [PATCH] Fix #9 - initial setup fails because directory doesn't exist for logging. --- cleantoots/commands/config.py | 1 - cleantoots/main.py | 2 +- cleantoots/utils.py | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cleantoots/commands/config.py b/cleantoots/commands/config.py index 58af968..4447b64 100644 --- a/cleantoots/commands/config.py +++ b/cleantoots/commands/config.py @@ -23,7 +23,6 @@ def config_command(): @click.pass_obj def setup(config: CleanTootsConfig): """Initial setup for configuration directories and files.""" - os.makedirs(config.dir, exist_ok=True) if os.path.isfile(config.main_file): click.secho( "{} found. Not touching anything.".format(config.main_file), fg="yellow" diff --git a/cleantoots/main.py b/cleantoots/main.py index 2dadf82..9741502 100644 --- a/cleantoots/main.py +++ b/cleantoots/main.py @@ -42,7 +42,7 @@ def cli(ctx, config_dir, config_file): 3. run `clean --delete` """ ctx.obj = CleanTootsConfig(config_dir, config_file) - log_file = os.path.join(click.get_app_dir("cleantoots"), "cleantoots.log") + log_file = os.path.join(config_dir, "cleantoots.log") logging.config.dictConfig( { "version": 1, diff --git a/cleantoots/utils.py b/cleantoots/utils.py index c5f6ca8..33db5ec 100644 --- a/cleantoots/utils.py +++ b/cleantoots/utils.py @@ -55,6 +55,7 @@ class CleanTootsConfig(configparser.ConfigParser): def __init__(self, config_dir, config_file_name, *args, **kwargs): super().__init__(*args, **kwargs) self.dir = config_dir + os.makedirs(self.dir, exist_ok=True) self.main_file = os.path.join(config_dir, config_file_name) self.read(self.main_file)