mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Refactor PROGRAM_DIR -> APP_DIR
This commit is contained in:
parent
9d0097fa68
commit
32e0d7dba2
4 changed files with 18 additions and 18 deletions
|
@ -23,20 +23,20 @@ except ImportError:
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
sys.ext('Please install pywin32')
|
sys.ext('Please install pywin32')
|
||||||
|
|
||||||
PROGRAM_DIR = libs.util.module_path()
|
APP_ROOT = libs.util.module_path()
|
||||||
|
|
||||||
# init preliminaries
|
# init preliminaries
|
||||||
SYS_ARGV = sys.argv[1:]
|
SYS_ARGV = sys.argv[1:]
|
||||||
APP_FILENAME = sys.argv[0]
|
APP_FILENAME = sys.argv[0]
|
||||||
APP_NAME = os.path.basename(APP_FILENAME)
|
APP_NAME = os.path.basename(APP_FILENAME)
|
||||||
LOG_DIR = os.path.join(PROGRAM_DIR, 'logs')
|
LOG_DIR = os.path.join(APP_ROOT, 'logs')
|
||||||
LOG_FILE = os.path.join(LOG_DIR, 'nzbtomedia.log')
|
LOG_FILE = os.path.join(LOG_DIR, 'nzbtomedia.log')
|
||||||
PID_FILE = os.path.join(LOG_DIR, 'nzbtomedia.pid')
|
PID_FILE = os.path.join(LOG_DIR, 'nzbtomedia.pid')
|
||||||
CONFIG_FILE = os.path.join(PROGRAM_DIR, 'autoProcessMedia.cfg')
|
CONFIG_FILE = os.path.join(APP_ROOT, 'autoProcessMedia.cfg')
|
||||||
CONFIG_SPEC_FILE = os.path.join(PROGRAM_DIR, 'autoProcessMedia.cfg.spec')
|
CONFIG_SPEC_FILE = os.path.join(APP_ROOT, 'autoProcessMedia.cfg.spec')
|
||||||
CONFIG_MOVIE_FILE = os.path.join(PROGRAM_DIR, 'autoProcessMovie.cfg')
|
CONFIG_MOVIE_FILE = os.path.join(APP_ROOT, 'autoProcessMovie.cfg')
|
||||||
CONFIG_TV_FILE = os.path.join(PROGRAM_DIR, 'autoProcessTv.cfg')
|
CONFIG_TV_FILE = os.path.join(APP_ROOT, 'autoProcessTv.cfg')
|
||||||
TEST_FILE = os.path.join(PROGRAM_DIR, 'tests', 'test.mp4')
|
TEST_FILE = os.path.join(APP_ROOT, 'tests', 'test.mp4')
|
||||||
MYAPP = None
|
MYAPP = None
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
@ -747,7 +747,7 @@ def initialize(section=None):
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
FFMPEG = os.path.join(FFMPEG_PATH, 'ffmpeg.exe')
|
FFMPEG = os.path.join(FFMPEG_PATH, 'ffmpeg.exe')
|
||||||
FFPROBE = os.path.join(FFMPEG_PATH, 'ffprobe.exe')
|
FFPROBE = os.path.join(FFMPEG_PATH, 'ffprobe.exe')
|
||||||
SEVENZIP = os.path.join(PROGRAM_DIR, 'core', 'extractor', 'bin', platform.machine(), '7z.exe')
|
SEVENZIP = os.path.join(APP_ROOT, 'core', 'extractor', 'bin', platform.machine(), '7z.exe')
|
||||||
SHOWEXTRACT = int(str(CFG["Windows"]["show_extraction"]), 0)
|
SHOWEXTRACT = int(str(CFG["Windows"]["show_extraction"]), 0)
|
||||||
|
|
||||||
if not (os.path.isfile(FFMPEG)): # problem
|
if not (os.path.isfile(FFMPEG)): # problem
|
||||||
|
|
|
@ -19,7 +19,7 @@ def extract(file_path, output_destination):
|
||||||
core.logger.error("EXTRACTOR: Could not find 7-zip, Exiting")
|
core.logger.error("EXTRACTOR: Could not find 7-zip, Exiting")
|
||||||
return False
|
return False
|
||||||
wscriptlocation = os.path.join(os.environ['WINDIR'], 'system32', 'wscript.exe')
|
wscriptlocation = os.path.join(os.environ['WINDIR'], 'system32', 'wscript.exe')
|
||||||
invislocation = os.path.join(core.PROGRAM_DIR, 'core', 'extractor', 'bin', 'invisible.vbs')
|
invislocation = os.path.join(core.APP_ROOT, 'core', 'extractor', 'bin', 'invisible.vbs')
|
||||||
cmd_7zip = [wscriptlocation, invislocation, str(core.SHOWEXTRACT), core.SEVENZIP, "x", "-y"]
|
cmd_7zip = [wscriptlocation, invislocation, str(core.SHOWEXTRACT), core.SEVENZIP, "x", "-y"]
|
||||||
ext_7zip = [".rar", ".zip", ".tar.gz", "tgz", ".tar.bz2", ".tbz", ".tar.lzma", ".tlz", ".7z", ".xz"]
|
ext_7zip = [".rar", ".zip", ".tar.gz", "tgz", ".tar.bz2", ".tbz", ".tar.lzma", ".tlz", ".7z", ".xz"]
|
||||||
extract_commands = dict.fromkeys(ext_7zip, cmd_7zip)
|
extract_commands = dict.fromkeys(ext_7zip, cmd_7zip)
|
||||||
|
|
|
@ -22,7 +22,7 @@ def db_filename(filename="nzbtomedia.db", suffix=None):
|
||||||
"""
|
"""
|
||||||
if suffix:
|
if suffix:
|
||||||
filename = "{0}.{1}".format(filename, suffix)
|
filename = "{0}.{1}".format(filename, suffix)
|
||||||
return core.os.path.join(core.PROGRAM_DIR, filename)
|
return core.os.path.join(core.APP_ROOT, filename)
|
||||||
|
|
||||||
|
|
||||||
class DBConnection(object):
|
class DBConnection(object):
|
||||||
|
|
|
@ -48,7 +48,7 @@ class CheckVersion(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# check if we're a windows build
|
# check if we're a windows build
|
||||||
if os.path.isdir(os.path.join(core.PROGRAM_DIR, u'.git')):
|
if os.path.isdir(os.path.join(core.APP_ROOT, u'.git')):
|
||||||
install_type = 'git'
|
install_type = 'git'
|
||||||
else:
|
else:
|
||||||
install_type = 'source'
|
install_type = 'source'
|
||||||
|
@ -174,9 +174,9 @@ class GitUpdateManager(UpdateManager):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger.log(u"Executing {cmd} with your shell in {directory}".format
|
logger.log(u"Executing {cmd} with your shell in {directory}".format
|
||||||
(cmd=cmd, directory=core.PROGRAM_DIR), logger.DEBUG)
|
(cmd=cmd, directory=core.APP_ROOT), logger.DEBUG)
|
||||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||||
shell=True, cwd=core.PROGRAM_DIR)
|
shell=True, cwd=core.APP_ROOT)
|
||||||
output, err = p.communicate()
|
output, err = p.communicate()
|
||||||
exit_status = p.returncode
|
exit_status = p.returncode
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ class SourceUpdateManager(UpdateManager):
|
||||||
|
|
||||||
def _find_installed_version(self):
|
def _find_installed_version(self):
|
||||||
|
|
||||||
version_file = os.path.join(core.PROGRAM_DIR, u'version.txt')
|
version_file = os.path.join(core.APP_ROOT, u'version.txt')
|
||||||
|
|
||||||
if not os.path.isfile(version_file):
|
if not os.path.isfile(version_file):
|
||||||
self._cur_commit_hash = None
|
self._cur_commit_hash = None
|
||||||
|
@ -437,11 +437,11 @@ class SourceUpdateManager(UpdateManager):
|
||||||
"""
|
"""
|
||||||
tar_download_url = 'https://github.com/{org}/{repo}/tarball/{branch}'.format(
|
tar_download_url = 'https://github.com/{org}/{repo}/tarball/{branch}'.format(
|
||||||
org=self.github_repo_user, repo=self.github_repo, branch=self.branch)
|
org=self.github_repo_user, repo=self.github_repo, branch=self.branch)
|
||||||
version_path = os.path.join(core.PROGRAM_DIR, u'version.txt')
|
version_path = os.path.join(core.APP_ROOT, u'version.txt')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# prepare the update dir
|
# prepare the update dir
|
||||||
sb_update_dir = os.path.join(core.PROGRAM_DIR, u'sb-update')
|
sb_update_dir = os.path.join(core.APP_ROOT, u'sb-update')
|
||||||
|
|
||||||
if os.path.isdir(sb_update_dir):
|
if os.path.isdir(sb_update_dir):
|
||||||
logger.log(u"Clearing out update folder {dir} before extracting".format(dir=sb_update_dir))
|
logger.log(u"Clearing out update folder {dir} before extracting".format(dir=sb_update_dir))
|
||||||
|
@ -485,12 +485,12 @@ class SourceUpdateManager(UpdateManager):
|
||||||
|
|
||||||
# walk temp folder and move files to main folder
|
# walk temp folder and move files to main folder
|
||||||
logger.log(u"Moving files from {source} to {destination}".format
|
logger.log(u"Moving files from {source} to {destination}".format
|
||||||
(source=content_dir, destination=core.PROGRAM_DIR))
|
(source=content_dir, destination=core.APP_ROOT))
|
||||||
for dirname, dirnames, filenames in os.walk(content_dir): # @UnusedVariable
|
for dirname, dirnames, filenames in os.walk(content_dir): # @UnusedVariable
|
||||||
dirname = dirname[len(content_dir) + 1:]
|
dirname = dirname[len(content_dir) + 1:]
|
||||||
for curfile in filenames:
|
for curfile in filenames:
|
||||||
old_path = os.path.join(content_dir, dirname, curfile)
|
old_path = os.path.join(content_dir, dirname, curfile)
|
||||||
new_path = os.path.join(core.PROGRAM_DIR, dirname, curfile)
|
new_path = os.path.join(core.APP_ROOT, dirname, curfile)
|
||||||
|
|
||||||
# Avoid DLL access problem on WIN32/64
|
# Avoid DLL access problem on WIN32/64
|
||||||
# These files needing to be updated manually
|
# These files needing to be updated manually
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue