Merge remote-tracking branch 'origin/dev'

This commit is contained in:
echel0n 2014-06-25 21:06:51 -07:00
commit b6e7455666
5 changed files with 61 additions and 58 deletions

View file

@ -19,6 +19,7 @@
# Check needed software dependencies to nudge users to fix their setup # Check needed software dependencies to nudge users to fix their setup
from __future__ import with_statement from __future__ import with_statement
import functools
import sys import sys
import shutil import shutil
@ -311,9 +312,7 @@ def main():
sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE) sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)
myDB = db.DBConnection() CUR_DB_VERSION = db.DBConnection().checkDBVersion()
CUR_DB_VERSION = myDB.checkDBVersion()
if CUR_DB_VERSION > 0: if CUR_DB_VERSION > 0:
if CUR_DB_VERSION < MIN_DB_VERSION: if CUR_DB_VERSION < MIN_DB_VERSION:
@ -327,16 +326,20 @@ def main():
MAX_DB_VERSION) + ").\n" + \ MAX_DB_VERSION) + ").\n" + \
"If you have used other forks of SB, your database may be unusable due to their modifications.") "If you have used other forks of SB, your database may be unusable due to their modifications.")
if sickbeard.DAEMON: # Initialize the config and our threads
sickbeard.initialize(consoleLogging=consoleLogging)
sickbeard.showList = []
if sickbeard.DAEMON and not sickbeard.restarted:
daemonize() daemonize()
# Use this PID for everything # Use this PID for everything
sickbeard.PID = os.getpid() sickbeard.PID = os.getpid()
# Initialize the config and our threads # Build from the DB to start with
sickbeard.initialize(consoleLogging=consoleLogging) logger.log(u"Loading initial show list")
loadShowsFromDB()
sickbeard.showList = []
if forcedPort: if forcedPort:
logger.log(u"Forcing web server to port " + str(forcedPort)) logger.log(u"Forcing web server to port " + str(forcedPort))
@ -374,11 +377,14 @@ def main():
} }
# init tornado # init tornado
webserveInit.initWebServer(options) try:
webserveInit.initWebServer(options)
# Build from the DB to start with except IOError:
logger.log(u"Loading initial show list") logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
loadShowsFromDB() if sickbeard.LAUNCH_BROWSER and not sickbeard.DAEMON:
logger.log(u"Launching browser and exiting", logger.ERROR)
sickbeard.launchBrowser(startPort)
sys.exit()
def startup(): def startup():
# Fire up all our threads # Fire up all our threads
@ -392,20 +398,15 @@ def main():
if forceUpdate or sickbeard.UPDATE_SHOWS_ON_START: if forceUpdate or sickbeard.UPDATE_SHOWS_ON_START:
sickbeard.showUpdateScheduler.action.run(force=True) # @UndefinedVariable sickbeard.showUpdateScheduler.action.run(force=True) # @UndefinedVariable
# If we restarted then unset the restarted flag
if sickbeard.restarted: if sickbeard.restarted:
sickbeard.restarted = False sickbeard.restarted = False
# create ioloop # create ioloop
io_loop = IOLoop.current() io_loop = IOLoop.current()
# init startup tasks
io_loop.add_timeout(datetime.timedelta(seconds=5), startup) io_loop.add_timeout(datetime.timedelta(seconds=5), startup)
# autoreload.
tornado.autoreload.add_reload_hook(autoreload_shutdown)
if sickbeard.AUTO_UPDATE:
tornado.autoreload.start(io_loop)
io_loop.start() io_loop.start()
sickbeard.saveAndShutdown() sickbeard.saveAndShutdown()

View file

@ -16,39 +16,7 @@ var timeout_id;
var restarted = ''; var restarted = '';
var num_restart_waits = 0; var num_restart_waits = 0;
function is_alive() { function restartHandler() {
timeout_id = 0;
$.get(is_alive_url, 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 (restarted == '' || data.restarted == restarted) {
restarted = data.restarted;
setTimeout('is_alive()', 1000);
// 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');
}
$(document).ready(function()
{
is_alive();
$(document).ajaxError(function(e, jqxhr, settings, exception) {
num_restart_waits += 1; num_restart_waits += 1;
$('#shut_down_loading').hide(); $('#shut_down_loading').hide();
@ -68,6 +36,14 @@ $(document).ready(function()
}, 3000); }, 3000);
setTimeout("window.location = sb_base_url+'/home/'", 5000); setTimeout("window.location = sb_base_url+'/home/'", 5000);
} }
} else {
timeout_id = 1;
setTimeout(function(){
$('#restart_loading').hide();
$('#restart_success').show();
$('#refresh_message').show();
}, 3000);
setTimeout("window.location = sb_base_url+'/home/'", 5000);
} }
// if it is taking forever just give up // if it is taking forever just give up
@ -80,6 +56,32 @@ $(document).ready(function()
if (timeout_id == 0) if (timeout_id == 0)
timeout_id = setTimeout('is_alive()', 1000); timeout_id = setTimeout('is_alive()', 1000);
}); }
function is_alive() {
timeout_id = 0;
$.get(is_alive_url, 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 (data.restarted == 'True') {
restartHandler();
} else {
// if this is before we've even shut down then just try again later
if (restarted == '' || data.restarted == restarted) {
restarted = data.restarted;
setTimeout(is_alive, 1000);
}
}
}, 'jsonp');
}
$(document).ready(function()
{
is_alive();
}); });

View file

@ -73,7 +73,7 @@ class TraktNotifier:
""" """
data = TraktCall("account/test/%API%", api, username, password, {}) data = TraktCall("account/test/%API%", api, username, password, {})
if data["status"] == "success": if data and data["status"] == "success":
return True return True
def _username(self): def _username(self):

View file

@ -57,8 +57,11 @@ class CheckVersion():
if self.check_for_new_version(): if self.check_for_new_version():
if sickbeard.AUTO_UPDATE: if sickbeard.AUTO_UPDATE:
logger.log(u"New update found for SickRage, starting auto-updater ...") logger.log(u"New update found for SickRage, starting auto-updater ...")
ui.notifications.message('New update found for SickRage, starting auto-updater')
if sickbeard.versionCheckScheduler.action.update(): if sickbeard.versionCheckScheduler.action.update():
logger.log(u"Update was successful!") logger.log(u"Update was successful!")
ui.notifications.message('Update was successful')
threading.Timer(2, sickbeard.invoke_restart, [False]).start()
def find_install_type(self): def find_install_type(self):
""" """

View file

@ -106,11 +106,8 @@ def initWebServer(options={}):
logger.log(u"Starting SickRage on " + protocol + "://" + str(options['host']) + ":" + str( logger.log(u"Starting SickRage on " + protocol + "://" + str(options['host']) + ":" + str(
options['port']) + "/") options['port']) + "/")
try: if not sickbeard.restarted:
server.listen(options['port'], options['host']) server.listen(options['port'], options['host'])
except:
pass
def shutdown(): def shutdown():
global server global server