Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
3f83be00
Commit
3f83be00
authored
Oct 29, 2018
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #687
parent
6ec9bc9e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
21 deletions
+40
-21
helper.py
cps/helper.py
+34
-19
web.py
cps/web.py
+6
-2
No files found.
cps/helper.py
View file @
3f83be00
...
...
@@ -381,25 +381,40 @@ class Updater(threading.Thread):
self
.
status
=
0
def
run
(
self
):
self
.
status
=
1
r
=
requests
.
get
(
'https://api.github.com/repos/janeczku/calibre-web/zipball/master'
,
stream
=
True
)
fname
=
re
.
findall
(
"filename=(.+)"
,
r
.
headers
[
'content-disposition'
])[
0
]
self
.
status
=
2
z
=
zipfile
.
ZipFile
(
BytesIO
(
r
.
content
))
self
.
status
=
3
tmp_dir
=
gettempdir
()
z
.
extractall
(
tmp_dir
)
self
.
status
=
4
self
.
update_source
(
os
.
path
.
join
(
tmp_dir
,
os
.
path
.
splitext
(
fname
)[
0
]),
ub
.
config
.
get_main_dir
)
self
.
status
=
5
db
.
session
.
close
()
db
.
engine
.
dispose
()
ub
.
session
.
close
()
ub
.
engine
.
dispose
()
self
.
status
=
6
server
.
Server
.
setRestartTyp
(
True
)
server
.
Server
.
stopServer
()
self
.
status
=
7
try
:
self
.
status
=
1
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
]
self
.
status
=
2
z
=
zipfile
.
ZipFile
(
BytesIO
(
r
.
content
))
self
.
status
=
3
tmp_dir
=
gettempdir
()
z
.
extractall
(
tmp_dir
)
self
.
status
=
4
self
.
update_source
(
os
.
path
.
join
(
tmp_dir
,
os
.
path
.
splitext
(
fname
)[
0
]),
ub
.
config
.
get_main_dir
)
self
.
status
=
5
db
.
session
.
close
()
db
.
engine
.
dispose
()
ub
.
session
.
close
()
ub
.
engine
.
dispose
()
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
):
return
self
.
status
...
...
cps/web.py
View file @
3f83be00
...
...
@@ -1292,7 +1292,11 @@ def get_updater_status():
"4"
:
_
(
u'Files are replaced'
),
"5"
:
_
(
u'Database connections are closed'
),
"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
helper
.
updater_thread
=
helper
.
Updater
()
...
...
@@ -1302,7 +1306,7 @@ def get_updater_status():
try
:
status
[
'status'
]
=
helper
.
updater_thread
.
get_update_status
()
except
Exception
:
status
[
'status'
]
=
7
status
[
'status'
]
=
11
return
json
.
dumps
(
status
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment