mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 05:43:16 -07:00
Fix circular imports
This commit is contained in:
parent
2bf7c64da9
commit
11ad3e9674
4 changed files with 9 additions and 15 deletions
|
@ -11,12 +11,10 @@ from typing import Any
|
||||||
|
|
||||||
import setuptools_scm
|
import setuptools_scm
|
||||||
|
|
||||||
import nzb2media.databases
|
|
||||||
import nzb2media.fork.medusa
|
import nzb2media.fork.medusa
|
||||||
import nzb2media.fork.sickbeard
|
import nzb2media.fork.sickbeard
|
||||||
import nzb2media.fork.sickchill
|
import nzb2media.fork.sickchill
|
||||||
import nzb2media.fork.sickgear
|
import nzb2media.fork.sickgear
|
||||||
import nzb2media.tool
|
|
||||||
from nzb2media.configuration import Config
|
from nzb2media.configuration import Config
|
||||||
from nzb2media.transcoder import configure_transcoder
|
from nzb2media.transcoder import configure_transcoder
|
||||||
from nzb2media.utils.network import wake_up
|
from nzb2media.utils.network import wake_up
|
||||||
|
@ -107,7 +105,6 @@ def configure_general():
|
||||||
global SAFE_MODE
|
global SAFE_MODE
|
||||||
global NOEXTRACTFAILED
|
global NOEXTRACTFAILED
|
||||||
FORCE_CLEAN = int(CFG['General']['force_clean'])
|
FORCE_CLEAN = int(CFG['General']['force_clean'])
|
||||||
nzb2media.tool.FFMPEG_PATH = pathlib.Path(CFG['General']['ffmpeg_path'])
|
|
||||||
SYS_PATH = CFG['General']['sys_path']
|
SYS_PATH = CFG['General']['sys_path']
|
||||||
CHECK_MEDIA = int(CFG['General']['check_media'])
|
CHECK_MEDIA = int(CFG['General']['check_media'])
|
||||||
REQUIRE_LAN = None if not CFG['General']['require_lan'] else CFG['General']['require_lan'].split(',')
|
REQUIRE_LAN = None if not CFG['General']['require_lan'] else CFG['General']['require_lan'].split(',')
|
||||||
|
@ -186,11 +183,9 @@ def initialize(section=None):
|
||||||
configure_general()
|
configure_general()
|
||||||
configure_wake_on_lan()
|
configure_wake_on_lan()
|
||||||
configure_remote_paths()
|
configure_remote_paths()
|
||||||
nzb2media.tool.configure_niceness()
|
|
||||||
configure_containers()
|
configure_containers()
|
||||||
configure_transcoder()
|
configure_transcoder()
|
||||||
configure_passwords_file()
|
configure_passwords_file()
|
||||||
nzb2media.tool.configure_utility_locations()
|
|
||||||
configure_sections(section)
|
configure_sections(section)
|
||||||
__INITIALIZED__ = True
|
__INITIALIZED__ = True
|
||||||
# finished initializing
|
# finished initializing
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import nzb2media
|
|
||||||
from nzb2media.utils.files import backup_versioned_file
|
from nzb2media.utils.files import backup_versioned_file
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -115,17 +115,18 @@ class InitialSchema(SchemaUpgrade):
|
||||||
self.connection.action(query)
|
self.connection.action(query)
|
||||||
|
|
||||||
|
|
||||||
def db_filename(filename: str = 'nzbtomedia.db', suffix: str | None = None):
|
def db_filename(filename: str = 'nzbtomedia.db', suffix: str | None = None, root: os.PathLike | None = None):
|
||||||
"""Return the correct location of the database file.
|
"""Return the correct location of the database file.
|
||||||
|
|
||||||
@param filename: The sqlite database filename to use. If not specified, will be made to be nzbtomedia.db
|
@param filename: The sqlite database filename to use. If not specified, will be made to be nzbtomedia.db
|
||||||
@param suffix: The suffix to append to the filename. A '.' will be added
|
@param suffix: The suffix to append to the filename. A '.' will be added
|
||||||
automatically, i.e. suffix='v0' will make dbfile.db.v0
|
automatically, i.e. suffix='v0' will make dbfile.db.v0
|
||||||
|
@param root: The root path for the database.
|
||||||
@return: the correct location of the database file.
|
@return: the correct location of the database file.
|
||||||
"""
|
"""
|
||||||
if suffix:
|
if suffix:
|
||||||
filename = f'{filename}.{suffix}'
|
filename = f'{filename}.{suffix}'
|
||||||
return nzb2media.os.path.join(nzb2media.APP_ROOT, filename)
|
return os.path.join(root or '', filename)
|
||||||
|
|
||||||
|
|
||||||
class DBConnection:
|
class DBConnection:
|
||||||
|
@ -308,4 +309,4 @@ def _process_upgrade(connection, upgrade_class):
|
||||||
_process_upgrade(connection, upgrade_sub_class)
|
_process_upgrade(connection, upgrade_sub_class)
|
||||||
|
|
||||||
|
|
||||||
upgrade_database(nzb2media.databases.DBConnection(), nzb2media.databases.InitialSchema)
|
upgrade_database(DBConnection(), InitialSchema)
|
||||||
|
|
|
@ -136,11 +136,7 @@ def configure_utility_locations():
|
||||||
FFMPEG = find_transcoder(FFMPEG_PATH)
|
FFMPEG = find_transcoder(FFMPEG_PATH)
|
||||||
FFPROBE = find_video_corruption_detector(FFMPEG_PATH)
|
FFPROBE = find_video_corruption_detector(FFMPEG_PATH)
|
||||||
PAR2CMD = find_archive_repairer()
|
PAR2CMD = find_archive_repairer()
|
||||||
if platform.system() == 'Windows':
|
SEVENZIP = find_unzip()
|
||||||
path = nzb2media.APP_ROOT / f'nzb2media/extractor/bin/{platform.machine()}'
|
|
||||||
else:
|
|
||||||
path = None
|
|
||||||
SEVENZIP = find_unzip(path)
|
|
||||||
|
|
||||||
|
|
||||||
def extract(file_path, output_destination):
|
def extract(file_path, output_destination):
|
||||||
|
@ -318,3 +314,6 @@ def configure_niceness():
|
||||||
|
|
||||||
NICENESS: list[str] = []
|
NICENESS: list[str] = []
|
||||||
FFMPEG_PATH: pathlib.Path | None = None
|
FFMPEG_PATH: pathlib.Path | None = None
|
||||||
|
|
||||||
|
configure_niceness()
|
||||||
|
configure_utility_locations()
|
||||||
|
|
|
@ -18,7 +18,6 @@ from subprocess import PIPE
|
||||||
from babelfish import Language
|
from babelfish import Language
|
||||||
|
|
||||||
import nzb2media
|
import nzb2media
|
||||||
import nzb2media.tool
|
|
||||||
from nzb2media.utils.files import list_media_files
|
from nzb2media.utils.files import list_media_files
|
||||||
from nzb2media.utils.paths import make_dir
|
from nzb2media.utils.paths import make_dir
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue