diff options
author | morpheus65535 <[email protected]> | 2024-05-02 22:53:36 -0400 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2024-05-02 22:53:36 -0400 |
commit | 0bddb5ba55eaae0db0919af5e4a21e408a6050bc (patch) | |
tree | dc0e793a3d0cc1c58291454f2d356dc3889f7b87 | |
parent | 2c4ed03817c724463701bf313f7fcb7b48039f81 (diff) | |
download | bazarr-0bddb5ba55eaae0db0919af5e4a21e408a6050bc.tar.gz bazarr-0bddb5ba55eaae0db0919af5e4a21e408a6050bc.zip |
no log: pep8 fixesv1.4.3-beta.30
-rw-r--r-- | bazarr/api/system/logs.py | 1 | ||||
-rw-r--r-- | bazarr/app/config.py | 2 | ||||
-rw-r--r-- | bazarr/app/logger.py | 25 | ||||
-rw-r--r-- | bazarr/app/scheduler.py | 1 | ||||
-rw-r--r-- | bazarr/app/server.py | 4 | ||||
-rw-r--r-- | bazarr/constants.py | 1 | ||||
-rw-r--r-- | bazarr/init.py | 3 | ||||
-rw-r--r-- | bazarr/main.py | 3 | ||||
-rw-r--r-- | bazarr/subtitles/sync.py | 6 | ||||
-rw-r--r-- | bazarr/subtitles/tools/subsyncer.py | 4 | ||||
-rw-r--r-- | bazarr/utilities/central.py | 15 |
11 files changed, 35 insertions, 30 deletions
diff --git a/bazarr/api/system/logs.py b/bazarr/api/system/logs.py index 7293f44c2..23daa98b4 100644 --- a/bazarr/api/system/logs.py +++ b/bazarr/api/system/logs.py @@ -7,7 +7,6 @@ from flask_restx import Resource, Namespace, fields, marshal from app.config import settings from app.logger import empty_log -from app.get_args import args from utilities.central import get_log_file_path from ..utils import authenticate diff --git a/bazarr/app/config.py b/bazarr/app/config.py index 49ae4cf32..af3a7ae05 100644 --- a/bazarr/app/config.py +++ b/bazarr/app/config.py @@ -58,7 +58,7 @@ class Validator(OriginalValidator): def check_parser_binary(value): try: get_binary(value) - except BinaryNotFound as e: + except BinaryNotFound: raise ValidationError(f"Executable '{value}' not found in search path. Please install before making this selection.") return True diff --git a/bazarr/app/logger.py b/bazarr/app/logger.py index 8470944d5..a47acf3dc 100644 --- a/bazarr/app/logger.py +++ b/bazarr/app/logger.py @@ -11,7 +11,6 @@ from logging.handlers import TimedRotatingFileHandler from utilities.central import get_log_file_path from pytz_deprecation_shim import PytzUsageWarning -from .get_args import args from .config import settings @@ -62,18 +61,18 @@ class UnwantedWaitressMessageFilter(logging.Filter): if settings.general.debug: # no filtering in debug mode return True - - unwantedMessages = [ - "Exception while serving /api/socket.io/", - ['Session is disconnected', 'Session not found' ], - - "Exception while serving /api/socket.io/", - ["'Session is disconnected'", "'Session not found'" ], - - "Exception while serving /api/socket.io/", - ['"Session is disconnected"', '"Session not found"' ], - - "Exception when servicing %r", + + unwantedMessages = [ + "Exception while serving /api/socket.io/", + ['Session is disconnected', 'Session not found'], + + "Exception while serving /api/socket.io/", + ["'Session is disconnected'", "'Session not found'"], + + "Exception while serving /api/socket.io/", + ['"Session is disconnected"', '"Session not found"'], + + "Exception when servicing %r", [], ] diff --git a/bazarr/app/scheduler.py b/bazarr/app/scheduler.py index 00b038c49..39cbe88b3 100644 --- a/bazarr/app/scheduler.py +++ b/bazarr/app/scheduler.py @@ -10,7 +10,6 @@ from apscheduler.triggers.date import DateTrigger from apscheduler.events import EVENT_JOB_SUBMITTED, EVENT_JOB_EXECUTED, EVENT_JOB_ERROR from datetime import datetime, timedelta from calendar import day_name -from math import floor from random import randrange from tzlocal import get_localzone try: diff --git a/bazarr/app/server.py b/bazarr/app/server.py index 5caefbf67..1def54dab 100644 --- a/bazarr/app/server.py +++ b/bazarr/app/server.py @@ -87,9 +87,9 @@ class Server: pass def close_all(self): - print(f"Closing database...") + print("Closing database...") close_database() - print(f"Closing webserver...") + print("Closing webserver...") self.server.close() def shutdown(self, status=EXIT_NORMAL): diff --git a/bazarr/constants.py b/bazarr/constants.py index f49c07cc0..b96236625 100644 --- a/bazarr/constants.py +++ b/bazarr/constants.py @@ -1,7 +1,6 @@ # coding=utf-8 import os -import re # set Bazarr user-agent used to make requests HEADERS = {"User-Agent": os.environ["SZ_USER_AGENT"]} diff --git a/bazarr/init.py b/bazarr/init.py index 98b7d3129..6dded426c 100644 --- a/bazarr/init.py +++ b/bazarr/init.py @@ -19,7 +19,8 @@ from utilities.backup import restore_from_backup from app.database import init_db -from literals import * +from literals import (EXIT_CONFIG_CREATE_ERROR, ENV_BAZARR_ROOT_DIR, DIR_BACKUP, DIR_CACHE, DIR_CONFIG, DIR_DB, DIR_LOG, + DIR_RESTORE, EXIT_REQUIREMENTS_ERROR) from utilities.central import make_bazarr_dir, restart_bazarr, stop_bazarr # set start time global variable as epoch diff --git a/bazarr/main.py b/bazarr/main.py index 15af61e97..ab25f6ae5 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -1,7 +1,6 @@ # coding=utf-8 import os -import io from threading import Thread @@ -42,6 +41,8 @@ from languages.get_languages import load_language_in_db # noqa E402 from app.signalr_client import sonarr_signalr_client, radarr_signalr_client # noqa E402 from app.server import webserver, app # noqa E402 from app.announcements import get_announcements_to_file # noqa E402 +from utilities.central import stop_bazarr # noqa E402 +from literals import EXIT_NORMAL # noqa E402 if args.create_db_revision: create_db_revision(app) diff --git a/bazarr/subtitles/sync.py b/bazarr/subtitles/sync.py index dffc24fcb..f7a3a69c4 100644 --- a/bazarr/subtitles/sync.py +++ b/bazarr/subtitles/sync.py @@ -33,9 +33,9 @@ def sync_subtitles(video_path, srt_path, srt_lang, forced, percent_score, sonarr 'max_offset_seconds': str(settings.subsync.max_offset_seconds), 'no_fix_framerate': settings.subsync.no_fix_framerate, 'gss': settings.subsync.gss, - 'reference': None, # means choose automatically within video file - 'sonarr_series_id': sonarr_series_id, - 'sonarr_episode_id': sonarr_episode_id, + 'reference': None, # means choose automatically within video file + 'sonarr_series_id': sonarr_series_id, + 'sonarr_episode_id': sonarr_episode_id, 'radarr_id': radarr_id, } subsync.sync(**sync_kwargs) diff --git a/bazarr/subtitles/tools/subsyncer.py b/bazarr/subtitles/tools/subsyncer.py index 72364aa5e..a71424516 100644 --- a/bazarr/subtitles/tools/subsyncer.py +++ b/bazarr/subtitles/tools/subsyncer.py @@ -30,8 +30,8 @@ class SubSyncer: self.vad = 'subs_then_webrtc' self.log_dir_path = os.path.join(args.config_dir, 'log') - def sync(self, video_path, srt_path, srt_lang, - max_offset_seconds, no_fix_framerate, gss, reference=None, + def sync(self, video_path, srt_path, srt_lang, + max_offset_seconds, no_fix_framerate, gss, reference=None, sonarr_series_id=None, sonarr_episode_id=None, radarr_id=None): self.reference = video_path self.srtin = srt_path diff --git a/bazarr/utilities/central.py b/bazarr/utilities/central.py index 3a0ed8378..009c42e1d 100644 --- a/bazarr/utilities/central.py +++ b/bazarr/utilities/central.py @@ -6,30 +6,37 @@ import logging import os from pathlib import Path -from literals import * + +from literals import ENV_BAZARR_ROOT_DIR, DIR_LOG, ENV_STOPFILE, ENV_RESTARTFILE, EXIT_NORMAL, FILE_LOG + def get_bazarr_dir(sub_dir): path = os.path.join(os.environ[ENV_BAZARR_ROOT_DIR], sub_dir) return path + def make_bazarr_dir(sub_dir): path = get_bazarr_dir(sub_dir) if not os.path.exists(path): os.mkdir(path) + def get_log_file_path(): path = os.path.join(get_bazarr_dir(DIR_LOG), FILE_LOG) return path + def get_stop_file_path(): return os.environ[ENV_STOPFILE] - + + def get_restart_file_path(): return os.environ[ENV_RESTARTFILE] + def stop_bazarr(status_code=EXIT_NORMAL, exit_main=True): try: - with open(get_stop_file_path(),'w', encoding='UTF-8') as file: + with open(get_stop_file_path(), 'w', encoding='UTF-8') as file: # write out status code for final exit file.write(f'{status_code}\n') file.close() @@ -39,6 +46,7 @@ def stop_bazarr(status_code=EXIT_NORMAL, exit_main=True): if exit_main: raise SystemExit(status_code) + def restart_bazarr(): try: Path(get_restart_file_path()).touch() @@ -46,4 +54,3 @@ def restart_bazarr(): logging.error(f'BAZARR Cannot create restart file: {repr(e)}') logging.info('Bazarr is being restarted...') raise SystemExit(EXIT_NORMAL) -
\ No newline at end of file |