Refactor updates configuration

This commit is contained in:
Labrys of Knossos 2019-01-19 03:29:58 -05:00
commit c9e9d9748b

View file

@ -343,7 +343,6 @@ def configure_logging_part_2():
def configure_general():
global VERSION_NOTIFY
global AUTO_UPDATE
global GIT_REPO
global GIT_PATH
global GIT_USER
@ -356,7 +355,6 @@ def configure_general():
# Set Version and GIT variables
VERSION_NOTIFY = int(CFG['General']['version_notify'])
AUTO_UPDATE = int(CFG['General']['auto_update'])
GIT_REPO = 'nzbToMedia'
GIT_PATH = CFG['General']['git_path']
GIT_USER = CFG['General']['git_user'] or 'clinton-hall'
@ -368,6 +366,32 @@ def configure_general():
NOEXTRACTFAILED = int(CFG['General']['no_extract_failed'])
def configure_updates():
global AUTO_UPDATE
AUTO_UPDATE = int(CFG['General']['auto_update'])
# Check for updates via GitHUB
if version_check.CheckVersion().check_for_new_version():
if AUTO_UPDATE == 1:
logger.info('Auto-Updating nzbToMedia, Please wait ...')
updated = version_check.CheckVersion().update()
if updated:
# restart nzbToMedia
try:
del MYAPP
except Exception:
pass
restart()
else:
logger.error('Update wasn\'t successful, not restarting. Check your log for more information.')
# Set Current Version
logger.info('nzbToMedia Version:{version} Branch:{branch} ({system} {release})'.format
(version=NZBTOMEDIA_VERSION, branch=GIT_BRANCH,
system=platform.system(), release=platform.release()))
def initialize(section=None):
global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \
NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \
@ -405,26 +429,7 @@ def initialize(section=None):
main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema)
configure_general()
# Check for updates via GitHUB
if version_check.CheckVersion().check_for_new_version():
if AUTO_UPDATE == 1:
logger.info('Auto-Updating nzbToMedia, Please wait ...')
updated = version_check.CheckVersion().update()
if updated:
# restart nzbToMedia
try:
del MYAPP
except Exception:
pass
restart()
else:
logger.error('Update wasn\'t successful, not restarting. Check your log for more information.')
# Set Current Version
logger.info('nzbToMedia Version:{version} Branch:{branch} ({system} {release})'.format
(version=NZBTOMEDIA_VERSION, branch=GIT_BRANCH,
system=platform.system(), release=platform.release()))
configure_updates()
if int(CFG['WakeOnLan']['wake']) == 1:
wake_up()