From 453a3e736c0c0fce849b432f33e99b091fa4c602 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:06:38 -0500 Subject: [PATCH 01/17] Remove `failed` parameter from `process` --- core/auto_process/tv.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/core/auto_process/tv.py b/core/auto_process/tv.py index 8e1cd500..fd52eb81 100644 --- a/core/auto_process/tv.py +++ b/core/auto_process/tv.py @@ -38,7 +38,6 @@ def process( dir_name: str, input_name: str = '', status: int = 0, - failed: bool = False, client_agent: str = 'manual', download_id: str = '', input_category: str = '', @@ -79,7 +78,6 @@ def process( force = int(cfg.get('force', 0)) delete_on = int(cfg.get('delete_on', 0)) ignore_subs = int(cfg.get('ignore_subs', 0)) - status = int(failed) # Begin processing @@ -185,11 +183,9 @@ def process( if valid_files == num_files and not status == 0: logger.info('Found Valid Videos. Setting status Success') status = 0 - failed = 0 if valid_files < num_files and status == 0: logger.info('Found corrupt videos. Setting status Failed') status = 1 - failed = 1 if ( 'NZBOP_VERSION' in os.environ and os.environ['NZBOP_VERSION'][0:5] >= '14.0' @@ -220,23 +216,19 @@ def process( logger.info( 'Check for media files ignored because nzbExtractionBy is set to Destination.', ) - if int(failed) == 0: + if status == 0: logger.info('Setting Status Success.') - status = 0 - failed = 0 else: logger.info( 'Downloader reported an error during download or verification. Processing this as a failed download.', ) status = 1 - failed = 1 else: logger.warning( f'No media files found in directory {dir_name}. Processing this as a failed download', section, ) status = 1 - failed = 1 if ( 'NZBOP_VERSION' in os.environ and os.environ['NZBOP_VERSION'][0:5] >= '14.0' @@ -275,7 +267,7 @@ def process( # Part of the refactor if init_sickbeard.fork_obj: init_sickbeard.fork_obj.initialize( - dir_name, input_name, failed, client_agent='manual', + dir_name, input_name, status, client_agent='manual', ) # configure SB params to pass @@ -289,9 +281,9 @@ def process( for param in copy.copy(fork_params): if param == 'failed': - if failed > 1: - failed = 1 - fork_params[param] = failed + if status > 1: + status = 1 + fork_params[param] = status if 'proc_type' in fork_params: del fork_params['proc_type'] if 'type' in fork_params: From 1bf9acae5462fc030d3f7674fd44de0244d52a75 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:09:44 -0500 Subject: [PATCH 02/17] Fix incompatible types in assignment --- core/auto_process/comics.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/auto_process/comics.py b/core/auto_process/comics.py index 1743c698..872f17a5 100644 --- a/core/auto_process/comics.py +++ b/core/auto_process/comics.py @@ -113,10 +113,7 @@ def process( f'{r.status_code}', ) - result = r.text - if not type(result) == list: - result = result.split('\n') - for line in result: + for line in r.text.split('\n'): if line: logger.postprocess(line, section) if 'Post Processing SUCCESSFUL' in line: From 054ac044740919cec9f9ae7334cf2d2dc4d2f478 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:10:15 -0500 Subject: [PATCH 03/17] Fix incompatible types in assignment --- core/auto_process/movies.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index 0755f591..4f485335 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -578,11 +578,11 @@ def process( f'{section} will keep searching', ) - # Added a release that was not in the wanted list so confirm rename successful by finding this movie media.list. + # Added a release that was not in the wanted list so confirm rename + # successful by finding this movie media.list. if not release: - download_id = ( - None # we don't want to filter new releases based on this. - ) + # we don't want to filter new releases based on this. + download_id = '' if no_status_check: return ProcessResult.success( From baef434332e1c489cdafa91ad2cc35b601420fda Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:17:00 -0500 Subject: [PATCH 04/17] Fix incompatible types in assignment --- core/auto_process/music.py | 3 +-- core/auto_process/tv.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/auto_process/music.py b/core/auto_process/music.py index 2e9c7170..3a29624a 100644 --- a/core/auto_process/music.py +++ b/core/auto_process/music.py @@ -158,12 +158,11 @@ def process( else: logger.debug(f'path: {dir_name}', section) data = {'name': 'Rename', 'path': dir_name} - data = json.dumps(data) try: logger.debug(f'Opening URL: {url} with data: {data}', section) r = requests.post( url, - data=data, + data=json.dumps(data), headers=headers, stream=True, verify=False, diff --git a/core/auto_process/tv.py b/core/auto_process/tv.py index fd52eb81..6f7f4980 100644 --- a/core/auto_process/tv.py +++ b/core/auto_process/tv.py @@ -429,7 +429,6 @@ def process( } if not download_id: data.pop('downloadClientId') - data = json.dumps(data) url = core.utils.common.create_url(scheme, host, port, route) try: if section == 'SickBeard': @@ -509,7 +508,7 @@ def process( logger.debug(f'Opening URL: {url} with data: {data}', section) r = requests.post( url, - data=data, + data=json.dumps(data), headers=headers, stream=True, verify=False, From 43c4138361517fc7af428f031941fe70ff38c77e Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:17:19 -0500 Subject: [PATCH 05/17] Fix invalid string formatting --- core/auto_process/movies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index 4f485335..162140f1 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -389,7 +389,7 @@ def process( scan_id = None elif section == 'Watcher3' and result['status'] == 'finished': update_movie_status = result['tasks']['update_movie_status'] - logger.postprocess('Watcher3 updated status to {}'.format()) + logger.postprocess(f'Watcher3 updated status to {section}') if update_movie_status == 'Finished': return ProcessResult( message=f'{section}: Successfully post-processed {input_name}', From d0f0c2819811259d52bafa61a48663be34e5981a Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:18:10 -0500 Subject: [PATCH 06/17] Don't disable urllib3 warnings --- core/auto_process/movies.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index 162140f1..3d00b268 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -32,9 +32,6 @@ from core.utils.paths import remove_dir from core.utils.network import server_responding -requests.packages.urllib3.disable_warnings() - - def process( *, section: str, From 3808564b6f6aea4cacbab315d364c310c90e4c46 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:19:05 -0500 Subject: [PATCH 07/17] Fix invalid string formatting --- core/utils/files.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/utils/files.py b/core/utils/files.py index ffc11a16..958dd263 100644 --- a/core/utils/files.py +++ b/core/utils/files.py @@ -277,9 +277,7 @@ def backup_versioned_file(old_file, version): try: logger.log( - 'Trying to back up {old} to {new]'.format( - old=old_file, new=new_file, - ), + f'Trying to back up {old_file} to {new_file}', logger.DEBUG, ) shutil.copy(old_file, new_file) From 097048b89d2cf893a6c235ae6a612670ca017219 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:20:22 -0500 Subject: [PATCH 08/17] Remove `failed` parameter from `process` --- core/auto_process/books.py | 1 - core/auto_process/comics.py | 1 - core/auto_process/games.py | 1 - core/auto_process/movies.py | 1 - core/auto_process/music.py | 1 - 5 files changed, 5 deletions(-) diff --git a/core/auto_process/books.py b/core/auto_process/books.py index dbf26802..3fe18aff 100644 --- a/core/auto_process/books.py +++ b/core/auto_process/books.py @@ -38,7 +38,6 @@ def process( dir_name: str, input_name: str = '', status: int = 0, - failed: bool = False, client_agent: str = 'manual', download_id: str = '', input_category: str = '', diff --git a/core/auto_process/comics.py b/core/auto_process/comics.py index 872f17a5..3105701d 100644 --- a/core/auto_process/comics.py +++ b/core/auto_process/comics.py @@ -38,7 +38,6 @@ def process( dir_name: str, input_name: str = '', status: int = 0, - failed: bool = False, client_agent: str = 'manual', download_id: str = '', input_category: str = '', diff --git a/core/auto_process/games.py b/core/auto_process/games.py index e13c3fdf..ab34b531 100644 --- a/core/auto_process/games.py +++ b/core/auto_process/games.py @@ -38,7 +38,6 @@ def process( dir_name: str, input_name: str = '', status: int = 0, - failed: bool = False, client_agent: str = 'manual', download_id: str = '', input_category: str = '', diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index 3d00b268..f1f79c32 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -38,7 +38,6 @@ def process( dir_name: str, input_name: str = '', status: int = 0, - failed: bool = False, client_agent: str = 'manual', download_id: str = '', input_category: str = '', diff --git a/core/auto_process/music.py b/core/auto_process/music.py index 3a29624a..27dfbd9e 100644 --- a/core/auto_process/music.py +++ b/core/auto_process/music.py @@ -38,7 +38,6 @@ def process( dir_name: str, input_name: str = '', status: int = 0, - failed: bool = False, client_agent: str = 'manual', download_id: str = '', input_category: str = '', From 2e589fde962a051a6c6965d4a6880997bf572a2f Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:22:02 -0500 Subject: [PATCH 09/17] Fix incompatible types in assignment --- core/utils/processes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/utils/processes.py b/core/utils/processes.py index 92beb40e..59fe1c8e 100644 --- a/core/utils/processes.py +++ b/core/utils/processes.py @@ -4,6 +4,7 @@ import os import socket import subprocess import sys +import typing import core from core import APP_FILENAME @@ -96,8 +97,9 @@ class PosixProcess: os.unlink(self.pidpath) +ProcessType = typing.Type[typing.Union[PosixProcess, WindowsProcess]] if os.name == 'nt': - RunningProcess = WindowsProcess + RunningProcess: ProcessType = WindowsProcess else: RunningProcess = PosixProcess From 7d20a40d5af9fd69bc30fdba1359022078fbfad4 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:24:59 -0500 Subject: [PATCH 10/17] Fix missing return --- core/auto_process/music.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/auto_process/music.py b/core/auto_process/music.py index 27dfbd9e..4e8ecf1f 100644 --- a/core/auto_process/music.py +++ b/core/auto_process/music.py @@ -259,6 +259,8 @@ def process( f'support failed downloads', ) + return ProcessResult.failure() + def get_status(url, apikey, dir_name): logger.debug( From cace1271ae71a01f673a9a6824a8f27a8e41f696 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:31:45 -0500 Subject: [PATCH 11/17] Raise error if processing without a loaded config --- core/auto_process/books.py | 2 ++ core/auto_process/comics.py | 2 ++ core/auto_process/games.py | 2 ++ core/auto_process/movies.py | 2 ++ core/auto_process/music.py | 2 ++ core/auto_process/tv.py | 2 ++ 6 files changed, 12 insertions(+) diff --git a/core/auto_process/books.py b/core/auto_process/books.py index 3fe18aff..0daa49b3 100644 --- a/core/auto_process/books.py +++ b/core/auto_process/books.py @@ -44,6 +44,8 @@ def process( failure_link: str = '', ) -> ProcessResult: # Get configuration + if core.CFG is None: + raise RuntimeError('Configuration not loaded.') cfg = core.CFG[section][input_category] # Base URL diff --git a/core/auto_process/comics.py b/core/auto_process/comics.py index 3105701d..e8cb4e6b 100644 --- a/core/auto_process/comics.py +++ b/core/auto_process/comics.py @@ -44,6 +44,8 @@ def process( failure_link: str = '', ) -> ProcessResult: # Get configuration + if core.CFG is None: + raise RuntimeError('Configuration not loaded.') cfg = core.CFG[section][input_category] # Base URL diff --git a/core/auto_process/games.py b/core/auto_process/games.py index ab34b531..0a197358 100644 --- a/core/auto_process/games.py +++ b/core/auto_process/games.py @@ -44,6 +44,8 @@ def process( failure_link: str = '', ) -> ProcessResult: # Get configuration + if core.CFG is None: + raise RuntimeError('Configuration not loaded.') cfg = core.CFG[section][input_category] # Base URL diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index f1f79c32..0acece69 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -44,6 +44,8 @@ def process( failure_link: str = '', ) -> ProcessResult: # Get configuration + if core.CFG is None: + raise RuntimeError('Configuration not loaded.') cfg = core.CFG[section][input_category] # Base URL diff --git a/core/auto_process/music.py b/core/auto_process/music.py index 4e8ecf1f..bce5f0bc 100644 --- a/core/auto_process/music.py +++ b/core/auto_process/music.py @@ -44,6 +44,8 @@ def process( failure_link: str = '', ) -> ProcessResult: # Get configuration + if core.CFG is None: + raise RuntimeError('Configuration not loaded.') cfg = core.CFG[section][input_category] # Base URL diff --git a/core/auto_process/tv.py b/core/auto_process/tv.py index 6f7f4980..d2a88e6d 100644 --- a/core/auto_process/tv.py +++ b/core/auto_process/tv.py @@ -44,6 +44,8 @@ def process( failure_link: str = '', ) -> ProcessResult: # Get configuration + if core.CFG is None: + raise RuntimeError('Configuration not loaded.') cfg = core.CFG[section][input_category] # Base URL From 44f3d4a35fede526748528ee708b0f50ce698718 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:33:30 -0500 Subject: [PATCH 12/17] Fix type-hint for forks --- core/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 84c4d9aa..e41b326f 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -9,6 +9,7 @@ import re import subprocess import sys import time +import typing import eol @@ -91,6 +92,7 @@ TORRENT_CLIENTS = [ 'manual', ] + # sickbeard fork/branch constants FORK_DEFAULT = 'default' FORK_FAILED = 'failed' @@ -105,7 +107,7 @@ FORK_SICKGEAR = 'SickGear' FORK_SICKGEAR_API = 'SickGear-api' FORK_STHENO = 'Stheno' -FORKS = { +FORKS: typing.Mapping[str, typing.Mapping] = { FORK_DEFAULT: {'dir': None}, FORK_FAILED: {'dirName': None, 'failed': None}, FORK_FAILED_TORRENT: {'dir': None, 'failed': None, 'process_method': None}, @@ -201,7 +203,10 @@ ALL_FORKS = { for k in set( list( itertools.chain.from_iterable( - [FORKS[x].keys() for x in FORKS.keys()], + [ + FORKS[x].keys() + for x in FORKS.keys() + ], ), ), ) From cd5d9c4bc255609ce2341bd77d9cb86df556360b Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:40:29 -0500 Subject: [PATCH 13/17] Add type-hints --- core/__init__.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index e41b326f..2f876bdf 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -33,16 +33,16 @@ APP_ROOT = SOURCE_ROOT.parent # init preliminaries SYS_ARGV = sys.argv[1:] -APP_FILENAME = sys.argv[0] -APP_NAME = os.path.basename(APP_FILENAME) -LOG_DIR = os.path.join(APP_ROOT, 'logs') -LOG_FILE = os.path.join(LOG_DIR, 'nzbtomedia.log') -PID_FILE = os.path.join(LOG_DIR, 'nzbtomedia.pid') -CONFIG_FILE = os.path.join(APP_ROOT, 'autoProcessMedia.cfg') -CONFIG_SPEC_FILE = os.path.join(APP_ROOT, 'autoProcessMedia.cfg.spec') -CONFIG_MOVIE_FILE = os.path.join(APP_ROOT, 'autoProcessMovie.cfg') -CONFIG_TV_FILE = os.path.join(APP_ROOT, 'autoProcessTv.cfg') -TEST_FILE = os.path.join(APP_ROOT, 'tests', 'test.mp4') +APP_FILENAME = pathlib.Path(sys.argv[0]) +APP_NAME: str = APP_FILENAME.name +LOG_DIR: pathlib.Path = APP_ROOT / 'logs' +LOG_FILE: pathlib.Path = LOG_DIR / 'nzbtomedia.log' +PID_FILE = LOG_DIR / 'nzbtomedia.pid' +CONFIG_FILE = APP_ROOT / 'autoProcessMedia.cfg' +CONFIG_SPEC_FILE = APP_ROOT / 'autoProcessMedia.cfg.spec' +CONFIG_MOVIE_FILE = APP_ROOT / 'autoProcessMovie.cfg' +CONFIG_TV_FILE = APP_ROOT / 'autoProcessTv.cfg' +TEST_FILE = APP_ROOT / 'tests' / 'test.mp4' MYAPP = None from core import logger, main_db, version_check, databases, transcoder @@ -255,7 +255,7 @@ TORRENT_CLIENT_AGENT = None TORRENT_CLASS = None USE_LINK = None OUTPUT_DIRECTORY = None -NOFLATTEN = [] +NOFLATTEN: list[str] = [] DELETE_ORIGINAL = None TORRENT_CHMOD_DIRECTORY = None TORRENT_DEFAULT_DIRECTORY = None @@ -292,17 +292,17 @@ PLEX_SSL = None PLEX_HOST = None PLEX_PORT = None PLEX_TOKEN = None -PLEX_SECTION = [] +PLEX_SECTION: list[str] = [] -EXT_CONTAINER = [] +EXT_CONTAINER: list[str] = [] COMPRESSED_CONTAINER = [] MEDIA_CONTAINER = [] AUDIO_CONTAINER = [] META_CONTAINER = [] -SECTIONS = [] -CATEGORIES = [] -FORK_SET = [] +SECTIONS: list[str] = [] +CATEGORIES: list[str] = [] +FORK_SET: list[str] = [] MOUNTED = None GETSUBS = False From fc3d6a574415fbfe343600a591c1ff97bde69382 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 03:56:01 -0500 Subject: [PATCH 14/17] Fix pidfile access --- core/utils/processes.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/core/utils/processes.py b/core/utils/processes.py index 59fe1c8e..8b01155a 100644 --- a/core/utils/processes.py +++ b/core/utils/processes.py @@ -21,9 +21,9 @@ if os.name == 'nt': class WindowsProcess: def __init__(self): self.mutex = None - self.mutexname = 'nzbtomedia_{pid}'.format( - pid=core.PID_FILE.replace('\\', '/'), - ) # {D0E858DF-985E-4907-B7FB-8D732C3FC3B9}' + # {D0E858DF-985E-4907-B7FB-8D732C3FC3B9} + _path_str = os.fspath(core.PID_FILE).replace('\\', '/') + self.mutexname = f'nzbtomedia_{_path_str}' self.CreateMutex = CreateMutex self.CloseHandle = CloseHandle self.GetLastError = GetLastError @@ -80,21 +80,15 @@ class PosixProcess: if not self.lasterror: # Write my pid into pidFile to keep multiple copies of program from running - try: - fp = open(self.pidpath, 'w') - fp.write(str(os.getpid())) - fp.close() - except Exception: - pass - + with self.pidpath.open(mode='w') as fp: + fp.write(os.getpid()) return self.lasterror def __del__(self): if not self.lasterror: if self.lock_socket: self.lock_socket.close() - if os.path.isfile(self.pidpath): - os.unlink(self.pidpath) + self.pidpath.unlink(missing_ok=True) ProcessType = typing.Type[typing.Union[PosixProcess, WindowsProcess]] From b907d76bbaee40217a12582dcceee7099c9c29dc Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 04:10:46 -0500 Subject: [PATCH 15/17] Use pathlib.Path for is_video_good --- core/transcoder.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/transcoder.py b/core/transcoder.py index f754e61b..e5a5d3d0 100644 --- a/core/transcoder.py +++ b/core/transcoder.py @@ -3,6 +3,7 @@ from __future__ import annotations import errno import json import os +import pathlib import platform import re import shutil @@ -19,9 +20,8 @@ from core.utils.paths import make_dir __author__ = 'Justin' -def is_video_good(videofile, status, require_lan=None): - file_name_ext = os.path.basename(videofile) - file_name, file_ext = os.path.splitext(file_name_ext) +def is_video_good(video: pathlib.Path, status, require_lan=None): + file_ext = video.suffix disable = False if ( file_ext not in core.MEDIA_CONTAINER @@ -65,18 +65,18 @@ def is_video_good(videofile, status, require_lan=None): return True logger.info( - f'Checking [{file_name_ext}] for corruption, please stand by ...', + f'Checking [{video.name}] for corruption, please stand by ...', 'TRANSCODER', ) - video_details, result = get_video_details(videofile) + video_details, result = get_video_details(video) if result != 0: - logger.error(f'FAILED: [{file_name_ext}] is corrupted!', 'TRANSCODER') + logger.error(f'FAILED: [{video.name}] is corrupted!', 'TRANSCODER') return False if video_details.get('error'): error_details = video_details.get('error') logger.info( - f'FAILED: [{file_name_ext}] returned error [{error_details}].', + f'FAILED: [{video.name}] returned error [{error_details}].', 'TRANSCODER', ) return False @@ -103,12 +103,12 @@ def is_video_good(videofile, status, require_lan=None): valid_audio = audio_streams if len(video_streams) > 0 and len(valid_audio) > 0: logger.info( - f'SUCCESS: [{file_name_ext}] has no corruption.', 'TRANSCODER', + f'SUCCESS: [{video.name}] has no corruption.', 'TRANSCODER', ) return True else: logger.info( - f'FAILED: [{file_name_ext}] has {len(video_streams)} video streams and {len(audio_streams)} audio streams. Assume corruption.', + f'FAILED: [{video.name}] has {len(video_streams)} video streams and {len(audio_streams)} audio streams. Assume corruption.', 'TRANSCODER', ) return False From e8f7f5cecefe2592144f68030388d886189d0744 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 04:12:37 -0500 Subject: [PATCH 16/17] Fix pidfile access --- core/utils/processes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/utils/processes.py b/core/utils/processes.py index 8b01155a..a1ac0898 100644 --- a/core/utils/processes.py +++ b/core/utils/processes.py @@ -88,7 +88,8 @@ class PosixProcess: if not self.lasterror: if self.lock_socket: self.lock_socket.close() - self.pidpath.unlink(missing_ok=True) + if self.pidpath.is_file(): + self.pidpath.unlink() ProcessType = typing.Type[typing.Union[PosixProcess, WindowsProcess]] From d889cbdfe3ece3ca216591ba46e57a20571e14af Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 14 Dec 2022 04:37:31 -0500 Subject: [PATCH 17/17] Fix configfile for pathlib.Path as infile --- core/configuration.py | 12 ++++++------ core/transcoder.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/configuration.py b/core/configuration.py index 2f709f05..66a1562c 100644 --- a/core/configuration.py +++ b/core/configuration.py @@ -90,10 +90,10 @@ class Section(configobj.Section): class ConfigObj(configobj.ConfigObj, Section): - def __init__(self, *args, **kw): - if len(args) == 0: - args = (core.CONFIG_FILE,) - super().__init__(*args, **kw) + def __init__(self, infile=None, *args, **kw): + if infile is None: + infile = core.CONFIG_FILE + super().__init__(os.fspath(infile), *args, **kw) self.interpolation = False @staticmethod @@ -115,7 +115,7 @@ class ConfigObj(configobj.ConfigObj, Section): try: # check for autoProcessMedia.cfg and create if it does not exist - if not os.path.isfile(core.CONFIG_FILE): + if not core.CONFIG_FILE.is_file(): shutil.copyfile(core.CONFIG_SPEC_FILE, core.CONFIG_FILE) CFG_OLD = config(core.CONFIG_FILE) except Exception as error: @@ -123,7 +123,7 @@ class ConfigObj(configobj.ConfigObj, Section): try: # check for autoProcessMedia.cfg.spec and create if it does not exist - if not os.path.isfile(core.CONFIG_SPEC_FILE): + if not core.CONFIG_SPEC_FILE.is_file(): shutil.copyfile(core.CONFIG_FILE, core.CONFIG_SPEC_FILE) CFG_NEW = config(core.CONFIG_SPEC_FILE) except Exception as error: diff --git a/core/transcoder.py b/core/transcoder.py index e5a5d3d0..660148e9 100644 --- a/core/transcoder.py +++ b/core/transcoder.py @@ -57,9 +57,9 @@ def is_video_good(video: pathlib.Path, status, require_lan=None): 'TRANSCODER', ) if disable: - if ( - status - ): # if the download was 'failed', assume bad. If it was successful, assume good. + if status: + # if the download was 'failed', assume bad. + # If it was successful, assume good. return False else: return True