1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

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
from __future__ import with_statement
import functools
import sys
import shutil
@ -311,9 +312,7 @@ def main():
sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)
myDB = db.DBConnection()
CUR_DB_VERSION = myDB.checkDBVersion()
CUR_DB_VERSION = db.DBConnection().checkDBVersion()
if CUR_DB_VERSION > 0:
if CUR_DB_VERSION < MIN_DB_VERSION:
@ -327,16 +326,20 @@ def main():
MAX_DB_VERSION) + ").\n" + \
"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()
# Use this PID for everything
sickbeard.PID = os.getpid()
# Initialize the config and our threads
sickbeard.initialize(consoleLogging=consoleLogging)
sickbeard.showList = []
# Build from the DB to start with
logger.log(u"Loading initial show list")
loadShowsFromDB()
if forcedPort:
logger.log(u"Forcing web server to port " + str(forcedPort))
@ -374,11 +377,14 @@ def main():
}
# init tornado
webserveInit.initWebServer(options)
# Build from the DB to start with
logger.log(u"Loading initial show list")
loadShowsFromDB()
try:
webserveInit.initWebServer(options)
except IOError:
logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
if sickbeard.LAUNCH_BROWSER and not sickbeard.DAEMON:
logger.log(u"Launching browser and exiting", logger.ERROR)
sickbeard.launchBrowser(startPort)
sys.exit()
def startup():
# Fire up all our threads
@ -392,20 +398,15 @@ def main():
if forceUpdate or sickbeard.UPDATE_SHOWS_ON_START:
sickbeard.showUpdateScheduler.action.run(force=True) # @UndefinedVariable
# If we restarted then unset the restarted flag
if sickbeard.restarted:
sickbeard.restarted = False
# create ioloop
io_loop = IOLoop.current()
# init startup tasks
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()
sickbeard.saveAndShutdown()

View File

@ -16,39 +16,7 @@ var timeout_id;
var restarted = '';
var num_restart_waits = 0;
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 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) {
function restartHandler() {
num_restart_waits += 1;
$('#shut_down_loading').hide();
@ -68,6 +36,14 @@ $(document).ready(function()
}, 3000);
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
@ -80,6 +56,32 @@ $(document).ready(function()
if (timeout_id == 0)
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, {})
if data["status"] == "success":
if data and data["status"] == "success":
return True
def _username(self):

View File

@ -57,8 +57,11 @@ class CheckVersion():
if self.check_for_new_version():
if sickbeard.AUTO_UPDATE:
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():
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):
"""

View File

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