1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-28 12:30:00 +00:00
This commit is contained in:
Ozzieisaacs 2018-10-29 20:38:09 +01:00
parent 6ec9bc9e5c
commit 3f83be00fd
2 changed files with 40 additions and 21 deletions

View File

@ -381,8 +381,11 @@ class Updater(threading.Thread):
self.status = 0 self.status = 0
def run(self): def run(self):
try:
self.status = 1 self.status = 1
r = requests.get('https://api.github.com/repos/janeczku/calibre-web/zipball/master', stream=True) r = requests.get('https://api.github.com/repos/janeczku/calibre-web/zipball/master', stream=True)
r.raise_for_status()
fname = re.findall("filename=(.+)", r.headers['content-disposition'])[0] fname = re.findall("filename=(.+)", r.headers['content-disposition'])[0]
self.status = 2 self.status = 2
z = zipfile.ZipFile(BytesIO(r.content)) z = zipfile.ZipFile(BytesIO(r.content))
@ -400,6 +403,18 @@ class Updater(threading.Thread):
server.Server.setRestartTyp(True) server.Server.setRestartTyp(True)
server.Server.stopServer() server.Server.stopServer()
self.status = 7 self.status = 7
except requests.exceptions.HTTPError as ex:
logging.getLogger('cps.web').info( u'HTTP Error' + ' ' + str(ex))
self.status = 8
except requests.exceptions.ConnectionError:
logging.getLogger('cps.web').info(u'Connection error')
self.status = 9
except requests.exceptions.Timeout:
logging.getLogger('cps.web').info(u'Timeout while establishing connection')
self.status = 10
except requests.exceptions.RequestException:
self.status = 11
logging.getLogger('cps.web').info(u'General error')
def get_update_status(self): def get_update_status(self):
return self.status return self.status

View File

@ -1292,7 +1292,11 @@ def get_updater_status():
"4": _(u'Files are replaced'), "4": _(u'Files are replaced'),
"5": _(u'Database connections are closed'), "5": _(u'Database connections are closed'),
"6": _(u'Server is stopped'), "6": _(u'Server is stopped'),
"7": _(u'Update finished, please press okay and reload page') "7": _(u'Update finished, please press okay and reload page'),
"8": _(u'Update failed:') + u' ' + _(u'HTTP Error'),
"9": _(u'Update failed:') + u' ' + _(u'Connection error'),
"10": _(u'Update failed:') + u' ' + _(u'Timeout while establishing connection'),
"11": _(u'Update failed:') + u' ' + _(u'General error')
} }
status['text'] = text status['text'] = text
helper.updater_thread = helper.Updater() helper.updater_thread = helper.Updater()
@ -1302,7 +1306,7 @@ def get_updater_status():
try: try:
status['status'] = helper.updater_thread.get_update_status() status['status'] = helper.updater_thread.get_update_status()
except Exception: except Exception:
status['status'] = 7 status['status'] = 11
return json.dumps(status) return json.dumps(status)