Added in auto-updater feature, this will allow you to optionally have SickBeard run a version check in the background constantly searching for a new version release on GIT and when found it will automatically download and install then restart.

This commit is contained in:
echel0n 2014-04-23 00:12:51 -07:00
parent 94670f7f95
commit 3f67782f38
4 changed files with 49 additions and 6 deletions

View File

@ -71,6 +71,18 @@
</label>
</div>
<div class="field-pair">
<input type="checkbox" name="auto_update" id="auto_update" #if $sickbeard.AUTO_UPDATE then "checked=\"checked\"" else ""#/>
<label class="clearfix" for="auto_update">
<span class="component-title">Automatic Updates</span>
<span class="component-desc">Automatically get and install updates for Sick Beard when available.</span>
</label>
<label class="nocheck clearfix">
<span class="component-title">&nbsp;</span>
<span class="component-desc">Automatic Updates runs on startup and in the background.</span>
</label>
</div>
<div class="field-pair">
<input type="checkbox" name="sort_article" id="sort_article" #if $sickbeard.SORT_ARTICLE then "checked=\"checked\"" else ""#/>
<label class="clearfix" for="sort_article">

View File

@ -77,6 +77,7 @@ backlogSearchScheduler = None
currentSearchScheduler = None
showUpdateScheduler = None
versionCheckScheduler = None
autoUpdateScheduler = None
showQueueScheduler = None
searchQueueScheduler = None
properFinderScheduler = None
@ -95,6 +96,7 @@ metadata_provider_dict = {}
NEWEST_VERSION = None
NEWEST_VERSION_STRING = None
VERSION_NOTIFY = None
AUTO_UPDATE = None
INIT_LOCK = Lock()
__INITIALIZED__ = False
@ -469,7 +471,7 @@ def initialize(consoleLogging=True):
USE_NMA, NMA_NOTIFY_ONSNATCH, NMA_NOTIFY_ONDOWNLOAD, NMA_NOTIFY_ONSUBTITLEDOWNLOAD, NMA_API, NMA_PRIORITY, \
USE_PUSHALOT, PUSHALOT_NOTIFY_ONSNATCH, PUSHALOT_NOTIFY_ONDOWNLOAD, PUSHALOT_NOTIFY_ONSUBTITLEDOWNLOAD, PUSHALOT_AUTHORIZATIONTOKEN, \
USE_PUSHBULLET, PUSHBULLET_NOTIFY_ONSNATCH, PUSHBULLET_NOTIFY_ONDOWNLOAD, PUSHBULLET_NOTIFY_ONSUBTITLEDOWNLOAD, PUSHBULLET_API, PUSHBULLET_DEVICE, \
versionCheckScheduler, VERSION_NOTIFY, PROCESS_AUTOMATICALLY, UNPACK, \
versionCheckScheduler, autoUpdateScheduler, VERSION_NOTIFY, AUTO_UPDATE, PROCESS_AUTOMATICALLY, UNPACK, \
KEEP_PROCESSED_DIR, PROCESS_METHOD, TV_DOWNLOAD_DIR, MIN_SEARCH_FREQUENCY, \
showQueueScheduler, searchQueueScheduler, ROOT_DIRS, CACHE_DIR, ACTUAL_CACHE_DIR, \
NAMING_PATTERN, NAMING_MULTI_EP, NAMING_FORCE_FOLDERS, NAMING_ABD_PATTERN, NAMING_CUSTOM_ABD, NAMING_STRIP_YEAR, \
@ -584,6 +586,7 @@ def initialize(consoleLogging=True):
QUALITY_DEFAULT = check_setting_int(CFG, 'General', 'quality_default', SD)
STATUS_DEFAULT = check_setting_int(CFG, 'General', 'status_default', SKIPPED)
VERSION_NOTIFY = check_setting_int(CFG, 'General', 'version_notify', 1)
AUTO_UPDATE = check_setting_int(CFG, 'General', 'auto_update', 1)
FLATTEN_FOLDERS_DEFAULT = bool(check_setting_int(CFG, 'General', 'flatten_folders_default', 0))
PROVIDER_ORDER = check_setting_str(CFG, 'General', 'provider_order', '').split()
@ -975,6 +978,12 @@ def initialize(consoleLogging=True):
threadName="CHECKVERSION",
runImmediately=True)
autoUpdateScheduler = scheduler.Scheduler(versionChecker.AutoUpdate(),
cycleTime=datetime.timedelta(seconds=3),
threadName="AUTOUPDATER",
runImmediately=True,
silent=True)
showQueueScheduler = scheduler.Scheduler(show_queue.ShowQueue(),
cycleTime=datetime.timedelta(seconds=3),
threadName="SHOWQUEUE",
@ -1032,7 +1041,7 @@ def initialize(consoleLogging=True):
def start():
global __INITIALIZED__, currentSearchScheduler, backlogSearchScheduler, \
showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \
showUpdateScheduler, versionCheckScheduler, autoUpdateScheduler, showQueueScheduler, \
properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \
subtitlesFinderScheduler, started, USE_SUBTITLES, \
traktWatchListCheckerSchedular, started
@ -1053,6 +1062,9 @@ def start():
# start the version checker
versionCheckScheduler.thread.start()
# start the version checker
autoUpdateScheduler.thread.start()
# start the queue checker
showQueueScheduler.thread.start()
@ -1117,6 +1129,13 @@ def halt():
except:
pass
autoUpdateScheduler.abort = True
logger.log(u"Waiting for the AUTOUPDATER thread to exit")
try:
autoUpdateScheduler.thread.join(10)
except:
pass
showQueueScheduler.abort = True
logger.log(u"Waiting for the SHOWQUEUE thread to exit")
try:
@ -1289,6 +1308,7 @@ def save_config():
new_config['General']['flatten_folders_default'] = int(FLATTEN_FOLDERS_DEFAULT)
new_config['General']['provider_order'] = ' '.join(PROVIDER_ORDER)
new_config['General']['version_notify'] = int(VERSION_NOTIFY)
new_config['General']['auto_update'] = int(AUTO_UPDATE)
new_config['General']['naming_strip_year'] = int(NAMING_STRIP_YEAR)
new_config['General']['naming_pattern'] = NAMING_PATTERN
new_config['General']['naming_custom_abd'] = int(NAMING_CUSTOM_ABD)

View File

@ -89,7 +89,7 @@ class CheckVersion():
return install_type
def check_for_new_version(self, force=False):
def check_for_new_version(self, force=False, silent=False):
"""
Checks the internet for a newer version.
@ -102,10 +102,12 @@ class CheckVersion():
logger.log(u"Version checking is disabled, not checking for the newest version")
return False
logger.log(u"Checking if " + self.install_type + " needs an update")
if not silent:
logger.log(u"Checking if " + self.install_type + " needs an update")
if not self.updater.need_update():
sickbeard.NEWEST_VERSION_STRING = None
logger.log(u"No update needed")
if not silent:
logger.log(u"No update needed")
if force:
ui.notifications.message('No update needed')
@ -118,6 +120,14 @@ class CheckVersion():
if self.updater.need_update():
return self.updater.update()
class AutoUpdate():
def run(self):
if CheckVersion().check_for_new_version(silent=True):
logger.log(u"New update found for SickBeard, starting auto-updater ...")
updated = sickbeard.versionCheckScheduler.action.update()
if updated:
logger.log(u"Update was successfull, restarting SickBeard ...")
sickbeard.restart()
class UpdateManager():
def get_github_repo_user(self):

View File

@ -976,7 +976,7 @@ class ConfigGeneral:
def saveGeneral(self, log_dir=None, web_port=None, web_log=None, encryption_version=None, web_ipv6=None,
update_shows_on_start=None, launch_browser=None, web_username=None, use_api=None, api_key=None,
web_password=None, version_notify=None, enable_https=None, https_cert=None, https_key=None,
sort_article=None,
sort_article=None, auto_update=None,
anon_redirect=None, git_path=None, calendar_unprotected=None, date_preset=None, time_preset=None):
results = []
@ -984,6 +984,7 @@ class ConfigGeneral:
# Misc
sickbeard.LAUNCH_BROWSER = config.checkbox_to_value(launch_browser)
config.change_VERSION_NOTIFY(config.checkbox_to_value(version_notify))
sickbeard.AUTO_UPDATE = config.checkbox_to_value(auto_update)
# sickbeard.LOG_DIR is set in config.change_LOG_DIR()
sickbeard.UPDATE_SHOWS_ON_START = config.checkbox_to_value(update_shows_on_start)