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
b2b092c1
Commit
b2b092c1
authored
Sep 10, 2018
by
Virgil Grigoras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix for not displaying information when there is no update available + simplification
parent
f7872ade
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
75 deletions
+86
-75
helper.py
cps/helper.py
+1
-1
web.py
cps/web.py
+85
-74
No files found.
cps/helper.py
View file @
b2b092c1
...
@@ -568,7 +568,7 @@ def get_current_version_info():
...
@@ -568,7 +568,7 @@ def get_current_version_info():
return
False
return
False
if
is_sha1
(
content
[
0
])
and
len
(
content
[
1
])
>
0
:
if
is_sha1
(
content
[
0
])
and
len
(
content
[
1
])
>
0
:
return
{
'
sha
'
:
content
[
0
],
'datetime'
:
content
[
1
]}
return
{
'
hash
'
:
content
[
0
],
'datetime'
:
content
[
1
]}
except
FileNotFoundError
:
except
FileNotFoundError
:
return
False
return
False
return
False
return
False
cps/web.py
View file @
b2b092c1
...
@@ -1090,6 +1090,8 @@ def get_update_status():
...
@@ -1090,6 +1090,8 @@ def get_update_status():
'message'
:
''
,
'message'
:
''
,
'current_commit_hash'
:
''
'current_commit_hash'
:
''
}
}
parents
=
[]
repository_url
=
'https://api.github.com/repos/janeczku/calibre-web'
repository_url
=
'https://api.github.com/repos/janeczku/calibre-web'
tz
=
datetime
.
timedelta
(
seconds
=
time
.
timezone
if
(
time
.
localtime
()
.
tm_isdst
==
0
)
else
time
.
altzone
)
tz
=
datetime
.
timedelta
(
seconds
=
time
.
timezone
if
(
time
.
localtime
()
.
tm_isdst
==
0
)
else
time
.
altzone
)
...
@@ -1098,7 +1100,7 @@ def get_update_status():
...
@@ -1098,7 +1100,7 @@ def get_update_status():
if
version
is
False
:
if
version
is
False
:
status
[
'current_commit_hash'
]
=
_
(
u'Unknown'
)
status
[
'current_commit_hash'
]
=
_
(
u'Unknown'
)
else
:
else
:
status
[
'current_commit_hash'
]
=
version
[
'
sha
'
]
status
[
'current_commit_hash'
]
=
version
[
'
hash
'
]
try
:
try
:
r
=
requests
.
get
(
repository_url
+
'/git/refs/heads/master'
)
r
=
requests
.
get
(
repository_url
+
'/git/refs/heads/master'
)
...
@@ -1114,11 +1116,23 @@ def get_update_status():
...
@@ -1114,11 +1116,23 @@ def get_update_status():
status
[
'message'
]
=
_
(
u'General error'
)
status
[
'message'
]
=
_
(
u'General error'
)
if
status
[
'message'
]
!=
''
:
if
status
[
'message'
]
!=
''
:
status
[
'success'
]
=
False
return
json
.
dumps
(
status
)
return
json
.
dumps
(
status
)
if
'object'
in
commit
and
commit
[
'object'
][
'sha'
]
!=
status
[
'current_commit_hash'
]:
if
'object'
not
in
commit
:
status
[
'message'
]
=
_
(
u'Unexpected data while reading update information'
)
return
json
.
dumps
(
status
)
if
commit
[
'object'
][
'sha'
]
==
status
[
'current_commit_hash'
]:
status
.
update
({
'update'
:
False
,
'success'
:
True
,
'message'
:
_
(
u'Now update available. You already have the latest version installed'
)
})
return
json
.
dumps
(
status
)
# a new update is available
# a new update is available
status
[
'update'
]
=
True
try
:
try
:
r
=
requests
.
get
(
repository_url
+
'/git/commits/'
+
commit
[
'object'
][
'sha'
])
r
=
requests
.
get
(
repository_url
+
'/git/commits/'
+
commit
[
'object'
][
'sha'
])
r
.
raise_for_status
()
r
.
raise_for_status
()
...
@@ -1133,13 +1147,9 @@ def get_update_status():
...
@@ -1133,13 +1147,9 @@ def get_update_status():
status
[
'error'
]
=
_
(
u'General error'
)
status
[
'error'
]
=
_
(
u'General error'
)
if
status
[
'message'
]
!=
''
:
if
status
[
'message'
]
!=
''
:
status
[
'success'
]
=
False
return
json
.
dumps
(
status
)
return
json
.
dumps
(
status
)
if
'committer'
in
update_data
and
'message'
in
update_data
:
if
'committer'
in
update_data
and
'message'
in
update_data
:
parents
=
[]
status
[
'update'
]
=
True
status
[
'success'
]
=
True
status
[
'success'
]
=
True
status
[
'message'
]
=
_
(
u'A new update is available. Click on the button below update to the latest version.'
)
status
[
'message'
]
=
_
(
u'A new update is available. Click on the button below update to the latest version.'
)
...
@@ -1188,6 +1198,7 @@ def get_update_status():
...
@@ -1188,6 +1198,7 @@ def get_update_status():
else
:
else
:
# parent is our current version
# parent is our current version
break
break
else
:
else
:
status
[
'success'
]
=
False
status
[
'success'
]
=
False
status
[
'message'
]
=
_
(
u'Could not fetch update information'
)
status
[
'message'
]
=
_
(
u'Could not fetch update information'
)
...
...
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