Merge branch 'configDir' into develop

This commit is contained in:
Timmy Welch 2022-04-18 20:10:50 -07:00
commit 298f50cb45
3 changed files with 25 additions and 14 deletions

View File

@ -95,6 +95,10 @@ def rotate(handler: logging.handlers.RotatingFileHandler, filename: pathlib.Path
def ctmain():
opts = Options()
opts.parse_cmd_line_args()
SETTINGS = ComicTaggerSettings(opts.config_path)
os.makedirs(ComicTaggerSettings.get_settings_folder() / "logs", exist_ok=True)
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.WARNING)
@ -111,11 +115,7 @@ def ctmain():
format="%(asctime)s | %(name)s | %(levelname)s | %(message)s",
datefmt="%Y-%m-%dT%H:%M:%S",
)
opts = Options()
opts.parse_cmd_line_args()
# Need to load setting before anything else
SETTINGS = ComicTaggerSettings()
# manage the CV API key
if opts.cv_api_key:

View File

@ -28,13 +28,16 @@ logger = logging.getLogger(__name__)
class ComicTaggerSettings:
folder = ""
@staticmethod
def get_settings_folder():
if platform.system() == "Windows":
folder = os.path.join(os.environ["APPDATA"], "ComicTagger")
else:
folder = os.path.join(os.path.expanduser("~"), ".ComicTagger")
return pathlib.Path(folder)
if not ComicTaggerSettings.folder:
if platform.system() == "Windows":
ComicTaggerSettings.folder = os.path.join(os.environ["APPDATA"], "ComicTagger")
else:
ComicTaggerSettings.folder = os.path.join(os.path.expanduser("~"), ".ComicTagger")
return pathlib.Path(ComicTaggerSettings.folder)
@staticmethod
def base_dir():
@ -123,7 +126,7 @@ class ComicTaggerSettings:
self.remove_archive_after_successful_match = False
self.wait_and_retry_on_rate_limit = False
def __init__(self):
def __init__(self, folder):
# General Settings
self.rar_exe_path = ""
self.allow_cbi_in_rar = True
@ -194,12 +197,15 @@ class ComicTaggerSettings:
self.wait_and_retry_on_rate_limit = False
self.config = configparser.RawConfigParser()
self.folder = ComicTaggerSettings.get_settings_folder()
if folder:
ComicTaggerSettings.folder = pathlib.Path(folder)
else:
ComicTaggerSettings.folder = ComicTaggerSettings.get_settings_folder()
if not os.path.exists(self.folder):
os.makedirs(self.folder)
if not os.path.exists(ComicTaggerSettings.folder):
os.makedirs(ComicTaggerSettings.folder)
self.settings_file = os.path.join(self.folder, "settings")
self.settings_file = os.path.join(ComicTaggerSettings.folder, "settings")
# if config file doesn't exist, write one out
if not os.path.exists(self.settings_file):

View File

@ -130,6 +130,11 @@ class VolumeSelectionWindow(QtWidgets.QDialog):
self.immediate_autoselect = autoselect
self.cover_index_list = cover_index_list
self.cv_search_results = None
self.ii = None
self.iddialog = None
self.id_thread = None
self.progdialog = None
self.search_thread = None
self.use_filter = self.settings.always_use_publisher_filter