From 76c84006adc4c7e9d567e1fd5fbb3695134959fb Mon Sep 17 00:00:00 2001 From: alemidev Date: Mon, 23 May 2022 02:36:44 +0200 Subject: [PATCH] put session files under data folder --- src/treepuncher/__main__.py | 5 +++++ src/treepuncher/storage.py | 4 ++-- src/treepuncher/treepuncher.py | 5 ++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/treepuncher/__main__.py b/src/treepuncher/__main__.py index adacddd..f99c980 100644 --- a/src/treepuncher/__main__.py +++ b/src/treepuncher/__main__.py @@ -87,6 +87,11 @@ def main(): if args.server: kwargs["server"] = args.server + if not os.path.isdir('log'): + os.mkdir('log') + if not os.path.isdir('data'): + os.mkdir('data') + try: client = Treepuncher( args.name, diff --git a/src/treepuncher/storage.py b/src/treepuncher/storage.py index fc1fc26..142052e 100644 --- a/src/treepuncher/storage.py +++ b/src/treepuncher/storage.py @@ -27,8 +27,8 @@ class Storage: def __init__(self, name:str): self.name = name - init = not os.path.isfile(f"{name}.session") - self.db = sqlite3.connect(f'{name}.session') + init = not os.path.isfile(name) + self.db = sqlite3.connect(name) if init: self._init_db() diff --git a/src/treepuncher/treepuncher.py b/src/treepuncher/treepuncher.py index 8815b22..3a488f0 100644 --- a/src/treepuncher/treepuncher.py +++ b/src/treepuncher/treepuncher.py @@ -50,8 +50,7 @@ class Treepuncher( self.name = name self.config = ConfigParser() - config_path = config_file or f'{self.name}.ini' - self.config.read(config_path) + self.config.read(config_file or f"{self.name}.ini") # TODO wrap with pathlib authenticator : AuthInterface @@ -94,7 +93,7 @@ class Treepuncher( resolve_srv=opt('resolve_srv', default=True, t=bool), ) - self.storage = Storage(self.name) + self.storage = Storage(opt('session_file') or f"data/{name}.session") # TODO wrap with pathlib self.notifier = Notifier(self)