|
|
@ -381,25 +381,40 @@ class Updater(threading.Thread):
|
|
|
|
self.status = 0
|
|
|
|
self.status = 0
|
|
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
def run(self):
|
|
|
|
self.status = 1
|
|
|
|
try:
|
|
|
|
r = requests.get('https://api.github.com/repos/janeczku/calibre-web/zipball/master', stream=True)
|
|
|
|
self.status = 1
|
|
|
|
fname = re.findall("filename=(.+)", r.headers['content-disposition'])[0]
|
|
|
|
r = requests.get('https://api.github.com/repos/janeczku/calibre-web/zipball/master', stream=True)
|
|
|
|
self.status = 2
|
|
|
|
r.raise_for_status()
|
|
|
|
z = zipfile.ZipFile(BytesIO(r.content))
|
|
|
|
|
|
|
|
self.status = 3
|
|
|
|
fname = re.findall("filename=(.+)", r.headers['content-disposition'])[0]
|
|
|
|
tmp_dir = gettempdir()
|
|
|
|
self.status = 2
|
|
|
|
z.extractall(tmp_dir)
|
|
|
|
z = zipfile.ZipFile(BytesIO(r.content))
|
|
|
|
self.status = 4
|
|
|
|
self.status = 3
|
|
|
|
self.update_source(os.path.join(tmp_dir, os.path.splitext(fname)[0]), ub.config.get_main_dir)
|
|
|
|
tmp_dir = gettempdir()
|
|
|
|
self.status = 5
|
|
|
|
z.extractall(tmp_dir)
|
|
|
|
db.session.close()
|
|
|
|
self.status = 4
|
|
|
|
db.engine.dispose()
|
|
|
|
self.update_source(os.path.join(tmp_dir, os.path.splitext(fname)[0]), ub.config.get_main_dir)
|
|
|
|
ub.session.close()
|
|
|
|
self.status = 5
|
|
|
|
ub.engine.dispose()
|
|
|
|
db.session.close()
|
|
|
|
self.status = 6
|
|
|
|
db.engine.dispose()
|
|
|
|
server.Server.setRestartTyp(True)
|
|
|
|
ub.session.close()
|
|
|
|
server.Server.stopServer()
|
|
|
|
ub.engine.dispose()
|
|
|
|
self.status = 7
|
|
|
|
self.status = 6
|
|
|
|
|
|
|
|
server.Server.setRestartTyp(True)
|
|
|
|
|
|
|
|
server.Server.stopServer()
|
|
|
|
|
|
|
|
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
|
|
|
|