From 487878819e3697e3cbe29c760630fd655a712e78 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 27 Apr 2020 12:03:54 +0200 Subject: [PATCH] Move a few variables around This should prevent a couple of crashes due to undeclared variables. --- cps/comic.py | 2 +- cps/constants.py | 2 +- cps/helper.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cps/comic.py b/cps/comic.py index 9f0a3aa2..bfb8ee36 100755 --- a/cps/comic.py +++ b/cps/comic.py @@ -37,9 +37,9 @@ except ImportError as e: def extractCover(tmp_file_name, original_file_extension): + cover_data = extension = None if use_comic_meta: archive = ComicArchive(tmp_file_name) - cover_data = None for index, name in enumerate(archive.getPageNameList()): ext = os.path.splitext(name) if len(ext) > 1: diff --git a/cps/constants.py b/cps/constants.py index d1fc299a..5fc026ee 100644 --- a/cps/constants.py +++ b/cps/constants.py @@ -101,8 +101,8 @@ DEFAULT_MAIL_SERVER = "mail.example.org" DEFAULT_PASSWORD = "admin123" DEFAULT_PORT = 8083 +env_CALIBRE_PORT = os.environ.get("CALIBRE_PORT", DEFAULT_PORT) try: - env_CALIBRE_PORT = os.environ.get("CALIBRE_PORT", DEFAULT_PORT) DEFAULT_PORT = int(env_CALIBRE_PORT) except ValueError: print('Environment variable CALIBRE_PORT has invalid value (%s), faling back to default (8083)' % env_CALIBRE_PORT) diff --git a/cps/helper.py b/cps/helper.py index 5e5bde29..a518a215 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -303,8 +303,8 @@ def update_dir_structure_file(book_id, calibrepath, first_author): new_titledir = get_valid_filename(localbook.title) + " (" + str(book_id) + ")" if titledir != new_titledir: + new_title_path = os.path.join(os.path.dirname(path), new_titledir) try: - new_title_path = os.path.join(os.path.dirname(path), new_titledir) if not os.path.exists(new_title_path): os.renames(path, new_title_path) else: @@ -321,8 +321,8 @@ def update_dir_structure_file(book_id, calibrepath, first_author): return _("Rename title from: '%(src)s' to '%(dest)s' failed with error: %(error)s", src=path, dest=new_title_path, error=str(ex)) if authordir != new_authordir: + new_author_path = os.path.join(calibrepath, new_authordir, os.path.basename(path)) try: - new_author_path = os.path.join(calibrepath, new_authordir, os.path.basename(path)) os.renames(path, new_author_path) localbook.path = new_authordir + '/' + localbook.path.split('/')[1] except OSError as ex: