Do normal shutdown
This commit is contained in:
@@ -18,7 +18,7 @@ log = CPLog(__name__)
|
|||||||
|
|
||||||
class Core(Plugin):
|
class Core(Plugin):
|
||||||
|
|
||||||
ignore_restart = ['Core.crappyRestart', 'Core.crappyShutdown', 'Updater.check']
|
ignore_restart = ['Core.restart', 'Core.shutdown', 'Updater.check']
|
||||||
shutdown_started = False
|
shutdown_started = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -37,8 +37,8 @@ class Core(Plugin):
|
|||||||
'desc': 'Get version.'
|
'desc': 'Get version.'
|
||||||
})
|
})
|
||||||
|
|
||||||
addEvent('app.crappy_shutdown', self.crappyShutdown)
|
addEvent('app.shutdown', self.shutdown)
|
||||||
addEvent('app.crappy_restart', self.crappyRestart)
|
addEvent('app.restart', self.restart)
|
||||||
addEvent('app.load', self.launchBrowser, priority = 1)
|
addEvent('app.load', self.launchBrowser, priority = 1)
|
||||||
addEvent('app.base_url', self.createBaseUrl)
|
addEvent('app.base_url', self.createBaseUrl)
|
||||||
addEvent('app.api_url', self.createApiUrl)
|
addEvent('app.api_url', self.createApiUrl)
|
||||||
@@ -59,21 +59,10 @@ class Core(Plugin):
|
|||||||
'succes': True
|
'succes': True
|
||||||
})
|
})
|
||||||
|
|
||||||
def crappyShutdown(self):
|
|
||||||
if self.shutdown_started:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.initShutdown()
|
|
||||||
return True
|
|
||||||
|
|
||||||
def crappyRestart(self):
|
|
||||||
if self.shutdown_started:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.initShutdown(restart = True)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
if self.shutdown_started:
|
||||||
|
return False
|
||||||
|
|
||||||
def shutdown():
|
def shutdown():
|
||||||
self.initShutdown()
|
self.initShutdown()
|
||||||
IOLoop.instance().add_callback(shutdown)
|
IOLoop.instance().add_callback(shutdown)
|
||||||
@@ -81,6 +70,9 @@ class Core(Plugin):
|
|||||||
return 'shutdown'
|
return 'shutdown'
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
|
if self.shutdown_started:
|
||||||
|
return False
|
||||||
|
|
||||||
def restart():
|
def restart():
|
||||||
self.initShutdown(restart = True)
|
self.initShutdown(restart = True)
|
||||||
IOLoop.instance().add_callback(restart)
|
IOLoop.instance().add_callback(restart)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ if Env.get('desktop'):
|
|||||||
addEvent('app.after_shutdown', desktop.afterShutdown)
|
addEvent('app.after_shutdown', desktop.afterShutdown)
|
||||||
|
|
||||||
def onClose(self, event):
|
def onClose(self, event):
|
||||||
return fireEvent('app.crappy_shutdown', single = True)
|
return fireEvent('app.shutdown', single = True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class Updater(Plugin):
|
|||||||
if self.updater.check():
|
if self.updater.check():
|
||||||
if self.conf('automatic') and not self.updater.update_failed:
|
if self.conf('automatic') and not self.updater.update_failed:
|
||||||
if self.updater.doUpdate():
|
if self.updater.doUpdate():
|
||||||
fireEventAsync('app.crappy_restart')
|
fireEventAsync('app.restart')
|
||||||
else:
|
else:
|
||||||
if self.conf('notification'):
|
if self.conf('notification'):
|
||||||
fireEvent('updater.available', message = 'A new update is available', data = self.updater.info())
|
fireEvent('updater.available', message = 'A new update is available', data = self.updater.info())
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ def getOptions(base_path, args):
|
|||||||
|
|
||||||
|
|
||||||
def cleanup():
|
def cleanup():
|
||||||
fireEvent('app.crappy_shutdown', single = True)
|
fireEvent('app.shutdown', single = True)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
# Tornado monkey patch logging..
|
# Tornado monkey patch logging..
|
||||||
|
|||||||
Reference in New Issue
Block a user