diff --git a/CHANGES.md b/CHANGES.md index 5902d967..b9ab1428 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -216,6 +216,7 @@ * Change ensure sbdatetime functions return formatted string instead of tuple * Change image cache processing for browse Trakt page * Change logging for newznab response code 910 and add check for empty response data +* Change improve reverse proxy web_root support ### 0.11.16 (2016-10-16 17:30:00 UTC) diff --git a/gui/slick/interfaces/default/config_general.tmpl b/gui/slick/interfaces/default/config_general.tmpl index 505ab314..8d467752 100644 --- a/gui/slick/interfaces/default/config_general.tmpl +++ b/gui/slick/interfaces/default/config_general.tmpl @@ -266,7 +266,7 @@ comma separated names -

group shows to the order of this custom list (add shows to groups with mass edit)

+

group shows to the order of this custom list (add shows to groups with mass edit)

diff --git a/gui/slick/interfaces/default/displayShow.tmpl b/gui/slick/interfaces/default/displayShow.tmpl index d616120a..71779e7f 100644 --- a/gui/slick/interfaces/default/displayShow.tmpl +++ b/gui/slick/interfaces/default/displayShow.tmpl @@ -573,14 +573,14 @@ #if 0 != int($epResult['season']) #if (int($epResult['status']) in $Quality.SNATCHED or int($epResult['status']) in $Quality.DOWNLOADED) and $sickbeard.USE_FAILED_DOWNLOADS - retry + retry #else: - search + search #end if #end if #if $sickbeard.USE_SUBTITLES and $show.subtitles and len(set(str($epResult['subtitles']).split(',')).intersection(set($subtitles.wantedLanguages()))) < len($subtitles.wantedLanguages()) and $epResult['location'] - search subtitles + search subtitles #end if diff --git a/gui/slick/interfaces/default/home.tmpl b/gui/slick/interfaces/default/home.tmpl index f8f91ee5..c42cb7d5 100644 --- a/gui/slick/interfaces/default/home.tmpl +++ b/gui/slick/interfaces/default/home.tmpl @@ -282,7 +282,7 @@ #if None is $curLoadingShow.show Loading... ($curLoadingShow.show_name) #else - $curLoadingShow.show.name + $curLoadingShow.show.name #end if diff --git a/gui/slick/interfaces/default/restart.tmpl b/gui/slick/interfaces/default/restart.tmpl index 7ad6fdfe..3bf84de5 100644 --- a/gui/slick/interfaces/default/restart.tmpl +++ b/gui/slick/interfaces/default/restart.tmpl @@ -1,16 +1,87 @@ -#import sickbeard -#import datetime -#from sickbeard.common import * -#from sickbeard import db -## -#set global $title = 'Home' -#set global $header = 'Restarting SickGear' -#set global $sbPath = '..' -#set global $topmenu = 'home' -## -#import os.path -#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_top.tmpl') + + + + + + -#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/restart_bare.tmpl') +SickGear - Restarting + + + + + + + + + + + + + + + + + + -#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_bottom.tmpl') + + +#try: + #set sgHost = $sbHost + #set sgPort = $sbHttpPort + #set sgUseHttps = $sbHttpsEnabled + #set themeSpinner = $sbThemeName +#except NameMapper.NotFound: + #set sgHost = 'localhost' + #set sgPort = $sickbeard.WEB_PORT + #set sgUseHttps = False + #set themeSpinner = $sickbeard.THEME_NAME +#end try +#set themeSpinner = '-dark' if 'dark' == themeSpinner else '' +## + + + + + + + + + + +
+ +

Performing Restart

+ +
+Waiting for SickGear to shut down: + +
+ +
+Waiting for SickGear to start up: + +
+ +
+Waiting for SickGear home page: + +
+ +
+Error: The restart timed out, perhaps something prevented SickGear from starting ? +
+ + diff --git a/gui/slick/interfaces/default/restart_bare.tmpl b/gui/slick/interfaces/default/restart_bare.tmpl index 36570cbb..6550eaa2 100644 --- a/gui/slick/interfaces/default/restart_bare.tmpl +++ b/gui/slick/interfaces/default/restart_bare.tmpl @@ -1,51 +1,7 @@ - - - - - -#set themeSpinner = '-dark' if 'dark' == themeSpinner else '' -

Performing Restart

-
-
-Waiting for SickGear to shut down: - - -
- - - - - - - +############################################################################################################## +## This file is deprecated (Oct 2016) but services systems in transition to the refactored restart template ## +############################################################################################################## +## +#import sickbeard +#import os.path +#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/restart.tmpl') diff --git a/gui/slick/interfaces/default/testRename.tmpl b/gui/slick/interfaces/default/testRename.tmpl index b90e7388..6e9fa0cf 100644 --- a/gui/slick/interfaces/default/testRename.tmpl +++ b/gui/slick/interfaces/default/testRename.tmpl @@ -11,9 +11,9 @@ #import os.path #include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_top.tmpl') -#if $varExists('header') +#if $varExists('header')

$header

-#else +#else

$title

#end if @@ -36,11 +36,11 @@ #set $curSeason = -1 #set $odd = False
- +
- Cancel Rename + Cancel Rename ## @@ -92,7 +92,7 @@
- Cancel Rename + Cancel Rename
-#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_bottom.tmpl') \ No newline at end of file +#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_bottom.tmpl') diff --git a/gui/slick/js/manageSubtitleMissed.js b/gui/slick/js/manageSubtitleMissed.js index 18d08448..9ae82de0 100644 --- a/gui/slick/js/manageSubtitleMissed.js +++ b/gui/slick/js/manageSubtitleMissed.js @@ -15,7 +15,7 @@ $(document).ready(function() { subtitles = subtitles.split(',') for (i in subtitles) { - row += ' '+subtitles[i]+' '; + row += ' '+subtitles[i]+' '; } row += ' '; row += ' ' diff --git a/gui/slick/js/massUpdate.js b/gui/slick/js/massUpdate.js index 57abf9a0..22315537 100644 --- a/gui/slick/js/massUpdate.js +++ b/gui/slick/js/massUpdate.js @@ -14,7 +14,7 @@ $(document).ready(function() { if (0 == editArr.length) return !1; - window.location.href = $.SickGear.Root + 'massEdit?toEdit=' + editArr.join('|'); + window.location.href = $.SickGear.Root + '/manage/massEdit?toEdit=' + editArr.join('|'); }); diff --git a/gui/slick/js/restart.js b/gui/slick/js/restart.js index 017beff8..ddbddee5 100644 --- a/gui/slick/js/restart.js +++ b/gui/slick/js/restart.js @@ -1,79 +1,85 @@ -if (sbHttpsEnabled != "False" && sbHttpsEnabled != 0) { - var sb_base_url = 'https://' + sbHost + ':' + sbHttpPort + sbRoot; -} else { - var sb_base_url = 'http://' + sbHost + ':' + sbHttpPort + sbRoot; -} +/** @namespace $.SickGear.Root */ +/** @namespace $.SickGear.Host */ +/** @namespace $.SickGear.Port */ +/** @namespace $.SickGear.UseHttps */ +/** @namespace data.msg */ -var base_url = window.location.protocol + '//' + window.location.host + sbRoot; -var is_alive_url = sbRoot + '/home/is_alive/'; -var timeout_id; -var current_pid = ''; -var num_restart_waits = 0; +var sgRoot = $.SickGear.Root, + browserUrl = window.location.protocol + '//' + window.location.host + sgRoot, + baseUrl = 'http' + ($.SickGear.UseHttps ? 's' : '') + '://' + $.SickGear.Host + ':' + + (('' == sgRoot) ? $.SickGear.Port : location.port) + sgRoot, + isAliveUrl = sgRoot + '/home/is_alive/', + timeoutId; +$.SickGear.currentPid = ''; +$.SickGear.numRestartWaits = 0; function is_alive() { - timeout_id = 0; - $.get(is_alive_url, function(data) { + timeoutId = 0; + $.get(isAliveUrl, function(data) { - // if it's still initalizing then just wait and try again - if (data.msg == 'nope') { - $('#shut_down_loading').hide(); - $('#shut_down_success').show(); - $('#restart_message').show(); - setTimeout('is_alive()', 1000); - } else { - // if this is before we've even shut down then just try again later - if (current_pid == '' || data.msg == current_pid) { - current_pid = data.msg; - setTimeout(is_alive, 1000); + if ('nope' == data.msg.toString()) { + // if initialising then just wait and try again - // if we're ready to go then redirect to new url - } else { - $('#restart_loading').hide(); - $('#restart_success').show(); - $('#refresh_message').show(); - window.location = sb_base_url + '/home/'; - } - } - }, 'jsonp'); + $('#shut_down_message').find('.spinner,.hide-yes').removeClass(); + $('#restart_message').removeClass(); + setTimeout(is_alive, 250); + + } else if ('' == $.SickGear.currentPid || $.SickGear.currentPid == data.msg) { + // if this is before we've even shut down then just try again later + + $.SickGear.currentPid = data.msg; + setTimeout(is_alive, 250); + + } else { + // if we're ready to go then redirect to new url + + $('#restart_message').find('.spinner,.hide-yes').removeClass(); + $('#refresh_message').removeClass(); + window.location = baseUrl + '/home/'; + } + }, 'jsonp'); } $(document).ready(function() { - is_alive(); + is_alive(); - $('#shut_down_message').ajaxError(function(e, jqxhr, settings, exception) { - num_restart_waits += 1; + //noinspection JSUnusedLocalSymbols + $('#shut_down_message').ajaxError(function(e, jqxhr, settings, exception) { + $.SickGear.numRestartWaits += 1; - $('#shut_down_loading').hide(); - $('#shut_down_success').show(); - $('#restart_message').show(); - is_alive_url = sb_base_url + '/home/is_alive/'; + $('#shut_down_message').find('.spinner,.hide-yes').removeClass(); + $('#restart_message').removeClass(); + isAliveUrl = baseUrl + '/home/is_alive/'; - // if https is enabled or you are currently on https and the port or protocol changed just wait 5 seconds then redirect. - // This is because the ajax will fail if the cert is untrusted or the the http ajax requst from https will fail because of mixed content error. - if ((sbHttpsEnabled != "False" && sbHttpsEnabled != 0) || window.location.protocol == "https:") { - if (base_url != sb_base_url) { - timeout_id = 1; - setTimeout(function(){ - $('#restart_loading').hide(); - $('#restart_success').show(); - $('#refresh_message').show(); - }, 3000); - setTimeout("window.location = sb_base_url + '/home/'", 5000); - } - } + // if https is enabled or you are currently on https and the port or protocol changed just wait 5 seconds then redirect. + // This is because the ajax will fail if the cert is untrusted or the the http ajax request from https will fail because of mixed content error. + if ($.SickGear.UseHttps || 'https:' == window.location.protocol) { + if (browserUrl != baseUrl) { - // if it is taking forever just give up - if (num_restart_waits > 90) { - $('#restart_loading').hide(); - $('#restart_failure').show(); - $('#restart_fail_message').show(); - return; - } + timeoutId = 1; + setTimeout(function() { + $('#restart_message').find('.spinner,.hide-yes').removeClass(); + $('#refresh_message').removeClass(); + }, 3000); + setTimeout(function() { + window.location = baseUrl + '/home/' + }, 5000); + } + } - if (timeout_id == 0) { - timeout_id = setTimeout('is_alive()', 1000); - } - }); + // if it is taking forever just give up + if (90 < $.SickGear.numRestartWaits) { -}); \ No newline at end of file + $('#restart_message').find('.spinner,.yes,.hide-no').removeClass(); + $('#restart_fail_message').removeClass(); + return; + } + + if (0 == timeoutId) { + + timeoutId = setTimeout(is_alive, 250); + } + }); + +}); diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 04884748..770a8c34 100755 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -1310,11 +1310,7 @@ def start(): def halt(): - global __INITIALIZED__, backlogSearchScheduler, \ - showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \ - properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \ - subtitlesFinderScheduler, traktCheckerScheduler, \ - recentSearchScheduler, events, started + global __INITIALIZED__, started with INIT_LOCK: @@ -1322,54 +1318,30 @@ def halt(): logger.log(u'Aborting all threads') - events.stop.set() - logger.log(u'Waiting for the EVENTS thread to exit') - try: - events.join(10) - except: - pass + schedulers = [ + recentSearchScheduler, + backlogSearchScheduler, + showUpdateScheduler, + versionCheckScheduler, + showQueueScheduler, + searchQueueScheduler, - recentSearchScheduler.stop.set() - logger.log(u'Waiting for the RECENTSEARCH thread to exit') - try: - recentSearchScheduler.join(10) - except: - pass + properFinderScheduler, + autoPostProcesserScheduler, + subtitlesFinderScheduler, - backlogSearchScheduler.stop.set() - logger.log(u'Waiting for the BACKLOG thread to exit') - try: - backlogSearchScheduler.join(10) - except: - pass + events + ] - showUpdateScheduler.stop.set() - logger.log(u'Waiting for the SHOWUPDATER thread to exit') - try: - showUpdateScheduler.join(10) - except: - pass + for thread in schedulers: + thread.stop.set() - versionCheckScheduler.stop.set() - logger.log(u'Waiting for the VERSIONCHECKER thread to exit') - try: - versionCheckScheduler.join(10) - except: - pass - - showQueueScheduler.stop.set() - logger.log(u'Waiting for the SHOWQUEUE thread to exit') - try: - showQueueScheduler.join(10) - except: - pass - - searchQueueScheduler.stop.set() - logger.log(u'Waiting for the SEARCHQUEUE thread to exit') - try: - searchQueueScheduler.join(10) - except: - pass + for thread in schedulers: + logger.log('Waiting for the %s thread to exit' % thread.name) + try: + thread.join(10) + except RuntimeError: + pass if PROCESS_AUTOMATICALLY: autoPostProcesserScheduler.stop.set() @@ -1379,14 +1351,6 @@ def halt(): except: pass - # if USE_TRAKT: - # traktCheckerScheduler.stop.set() - # logger.log(u'Waiting for the TRAKTCHECKER thread to exit') - # try: - # traktCheckerScheduler.join(10) - # except: - # pass - if DOWNLOAD_PROPERS: properFinderScheduler.stop.set() logger.log(u'Waiting for the PROPERFINDER thread to exit') diff --git a/sickbeard/notifiers/plex.py b/sickbeard/notifiers/plex.py index ba6d8548..c6fd6f51 100644 --- a/sickbeard/notifiers/plex.py +++ b/sickbeard/notifiers/plex.py @@ -196,17 +196,18 @@ class PLEXNotifier: if sickbeard.USE_PLEX and sickbeard.PLEX_UPDATE_LIBRARY or test: - if not sickbeard.PLEX_SERVER_HOST and not any([host]): - msg = u'No Plex Media Server host specified, check your settings' - self.log(msg, logger.DEBUG) - return '%sFail: %s' % (('', '
')[test], msg) + if not test: + if not sickbeard.PLEX_SERVER_HOST: + msg = u'No Plex Media Server host specified, check your settings' + self.log(msg, logger.DEBUG) + return '%sFail: %s' % (('', '
')[test], msg) - if not host: - host = sickbeard.PLEX_SERVER_HOST - if not username: - username = sickbeard.PLEX_USERNAME - if not password: - password = sickbeard.PLEX_PASSWORD + if not host: + host = sickbeard.PLEX_SERVER_HOST + if not username: + username = sickbeard.PLEX_USERNAME + if not password: + password = sickbeard.PLEX_PASSWORD # if username and password were provided, fetch the auth token from plex.tv token_arg = None diff --git a/sickbeard/processTV.py b/sickbeard/processTV.py index 21daa31e..8393b926 100644 --- a/sickbeard/processTV.py +++ b/sickbeard/processTV.py @@ -707,7 +707,7 @@ class ProcessTVShow(object): # processed in the past return False - showlink = ('for "%s"' % (parse_result.show.indexerid, parse_result.show.name), + showlink = ('for "%s"' % (sickbeard.WEB_ROOT, parse_result.show.indexerid, parse_result.show.name), parse_result.show.name)[self.any_vid_processed] ep_detail_sql = '' diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index c6619a5a..bd98dab3 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -864,6 +864,8 @@ class Home(MainHandler): password = sickbeard.PLEX_PASSWORD cur_result = notifiers.plex_notifier.test_notify(urllib.unquote_plus(host), username, password, server=True) + if '
' == cur_result: + cur_result += 'Fail: No valid host set to connect with' final_result = (('Test result for', 'Successful test of')['Fail' not in cur_result] + ' Plex server(s) ... %s
\n' % cur_result) @@ -1117,7 +1119,6 @@ class Home(MainHandler): return self.redirect('/home/') t = PageTemplate(headers=self.request.headers, file='restart.tmpl') - t.submenu = self.HomeMenu() # restart sickbeard.events.put(sickbeard.events.SystemEvent.RESTART) @@ -1129,16 +1130,11 @@ class Home(MainHandler): if str(pid) != str(sickbeard.PID): return self.redirect('/home/') - updated = sickbeard.versionCheckScheduler.action.update() # @UndefinedVariable - if updated: - # do a hard restart - sickbeard.events.put(sickbeard.events.SystemEvent.RESTART) + if sickbeard.versionCheckScheduler.action.update(): + return self.restart(pid) - t = PageTemplate(headers=self.request.headers, file='restart_bare.tmpl') - return t.respond() - else: - return self._genericMessage('Update Failed', - "Update wasn't successful, not restarting. Check your log for more information.") + return self._genericMessage('Update Failed', + 'Update wasn\'t successful, not restarting. Check your log for more information.') def branchCheckout(self, branch): sickbeard.BRANCH = branch