Fix #9 - initial setup fails because directory doesn't exist for logging.

This commit is contained in:
Gabriel Augendre 2020-01-03 09:16:28 +01:00
parent fb2361e703
commit 69596de7a3
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
3 changed files with 2 additions and 2 deletions

View file

@ -23,7 +23,6 @@ def config_command():
@click.pass_obj @click.pass_obj
def setup(config: CleanTootsConfig): def setup(config: CleanTootsConfig):
"""Initial setup for configuration directories and files.""" """Initial setup for configuration directories and files."""
os.makedirs(config.dir, exist_ok=True)
if os.path.isfile(config.main_file): if os.path.isfile(config.main_file):
click.secho( click.secho(
"{} found. Not touching anything.".format(config.main_file), fg="yellow" "{} found. Not touching anything.".format(config.main_file), fg="yellow"

View file

@ -42,7 +42,7 @@ def cli(ctx, config_dir, config_file):
3. run `clean --delete` 3. run `clean --delete`
""" """
ctx.obj = CleanTootsConfig(config_dir, config_file) 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( logging.config.dictConfig(
{ {
"version": 1, "version": 1,

View file

@ -55,6 +55,7 @@ class CleanTootsConfig(configparser.ConfigParser):
def __init__(self, config_dir, config_file_name, *args, **kwargs): def __init__(self, config_dir, config_file_name, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.dir = config_dir self.dir = config_dir
os.makedirs(self.dir, exist_ok=True)
self.main_file = os.path.join(config_dir, config_file_name) self.main_file = os.path.join(config_dir, config_file_name)
self.read(self.main_file) self.read(self.main_file)