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
0cf1cc55
Commit
0cf1cc55
authored
May 21, 2020
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes from tests
parent
a20a155d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
244 additions
and
799 deletions
+244
-799
admin.py
cps/admin.py
+15
-13
gdrive.py
cps/gdrive.py
+2
-2
helper.py
cps/helper.py
+1
-1
kobo.py
cps/kobo.py
+1
-1
web.py
cps/web.py
+4
-4
worker.py
cps/worker.py
+0
-1
Calibre-Web TestSummary.html
test/Calibre-Web TestSummary.html
+221
-777
No files found.
cps/admin.py
View file @
0cf1cc55
...
...
@@ -522,6 +522,7 @@ def _configuration_gdrive_helper(to_save):
def
_configuration_oauth_helper
(
to_save
):
active_oauths
=
0
reboot_required
=
False
for
element
in
oauthblueprints
:
if
to_save
[
"config_"
+
str
(
element
[
'id'
])
+
"_oauth_client_id"
]
!=
element
[
'oauth_client_id'
]
\
or
to_save
[
"config_"
+
str
(
element
[
'id'
])
+
"_oauth_client_secret"
]
!=
element
[
'oauth_client_secret'
]:
...
...
@@ -538,6 +539,7 @@ def _configuration_oauth_helper(to_save):
{
"oauth_client_id"
:
to_save
[
"config_"
+
str
(
element
[
'id'
])
+
"_oauth_client_id"
],
"oauth_client_secret"
:
to_save
[
"config_"
+
str
(
element
[
'id'
])
+
"_oauth_client_secret"
],
"active"
:
element
[
"active"
]})
return
reboot_required
def
_configuration_logfile_helper
(
to_save
,
gdriveError
):
reboot_required
=
False
...
...
@@ -552,7 +554,7 @@ def _configuration_logfile_helper(to_save, gdriveError):
return
reboot_required
,
_configuration_result
(
_
(
'Access Logfile Location is not Valid, Please Enter Correct Path'
),
gdriveError
)
return
reboot_required
,
None
def
_configuration_ldap_helper
(
gdriveError
,
to_save
):
def
_configuration_ldap_helper
(
to_save
,
gdriveError
):
reboot_required
=
False
reboot_required
|=
_config_string
(
to_save
,
"config_ldap_provider_url"
)
reboot_required
|=
_config_int
(
to_save
,
"config_ldap_port"
)
...
...
@@ -575,36 +577,36 @@ def _configuration_ldap_helper(gdriveError, to_save):
or
not
config
.
config_ldap_port
\
or
not
config
.
config_ldap_dn
\
or
not
config
.
config_ldap_user_object
:
return
_configuration_result
(
_
(
'Please Enter a LDAP Provider, '
return
reboot_required
,
_configuration_result
(
_
(
'Please Enter a LDAP Provider, '
'Port, DN and User Object Identifier'
),
gdriveError
)
if
config
.
config_ldap_authentication
>
constants
.
LDAP_AUTH_ANONYMOUS
:
if
config
.
config_ldap_authentication
>
constants
.
LDAP_AUTH_UNAUTHENTICATE
:
if
not
config
.
config_ldap_serv_username
or
not
bool
(
config
.
config_ldap_serv_password
):
return
_configuration_result
(
'Please Enter a LDAP Service Account and Password'
,
gdriveError
)
return
reboot_required
,
_configuration_result
(
'Please Enter a LDAP Service Account and Password'
,
gdriveError
)
else
:
if
not
config
.
config_ldap_serv_username
:
return
_configuration_result
(
'Please Enter a LDAP Service Account'
,
gdriveError
)
return
reboot_required
,
_configuration_result
(
'Please Enter a LDAP Service Account'
,
gdriveError
)
if
config
.
config_ldap_group_object_filter
:
if
config
.
config_ldap_group_object_filter
.
count
(
"
%
s"
)
!=
1
:
return
_configuration_result
(
_
(
'LDAP Group Object Filter Needs to Have One "
%
s" Format Identifier'
),
return
reboot_required
,
_configuration_result
(
_
(
'LDAP Group Object Filter Needs to Have One "
%
s" Format Identifier'
),
gdriveError
)
if
config
.
config_ldap_group_object_filter
.
count
(
"("
)
!=
config
.
config_ldap_group_object_filter
.
count
(
")"
):
return
_configuration_result
(
_
(
'LDAP Group Object Filter Has Unmatched Parenthesis'
),
return
reboot_required
,
_configuration_result
(
_
(
'LDAP Group Object Filter Has Unmatched Parenthesis'
),
gdriveError
)
if
config
.
config_ldap_user_object
.
count
(
"
%
s"
)
!=
1
:
return
_configuration_result
(
_
(
'LDAP User Object Filter needs to Have One "
%
s" Format Identifier'
),
return
reboot_required
,
_configuration_result
(
_
(
'LDAP User Object Filter needs to Have One "
%
s" Format Identifier'
),
gdriveError
)
if
config
.
config_ldap_user_object
.
count
(
"("
)
!=
config
.
config_ldap_user_object
.
count
(
")"
):
return
_configuration_result
(
_
(
'LDAP User Object Filter Has Unmatched Parenthesis'
),
return
reboot_required
,
_configuration_result
(
_
(
'LDAP User Object Filter Has Unmatched Parenthesis'
),
gdriveError
)
if
config
.
config_ldap_cert_path
and
not
os
.
path
.
isdir
(
config
.
config_ldap_cert_path
):
return
_configuration_result
(
_
(
'LDAP Certificate Location is not Valid, Please Enter Correct Path'
),
return
reboot_required
,
_configuration_result
(
_
(
'LDAP Certificate Location is not Valid, Please Enter Correct Path'
),
gdriveError
)
return
reboot_required
return
reboot_required
,
None
def
_configuration_update_helper
():
...
...
@@ -612,7 +614,7 @@ def _configuration_update_helper():
db_change
=
False
to_save
=
request
.
form
.
to_dict
()
to_save
[
'config_calibre_dir'
]
=
re
.
sub
(
'[
[
\\
/]metadata
\
.db$'
,
''
,
to_save
[
'config_calibre_dir'
],
flags
=
re
.
IGNORECASE
)
to_save
[
'config_calibre_dir'
]
=
re
.
sub
(
'[
\\
/]metadata
\
.db$'
,
''
,
to_save
[
'config_calibre_dir'
],
flags
=
re
.
IGNORECASE
)
db_change
|=
_config_string
(
to_save
,
"config_calibre_dir"
)
# Google drive setup
...
...
@@ -673,7 +675,7 @@ def _configuration_update_helper():
# OAuth configuration
if
config
.
config_login_type
==
constants
.
LOGIN_OAUTH
:
_configuration_oauth_helper
(
to_save
)
reboot_required
|=
_configuration_oauth_helper
(
to_save
)
reboot
,
message
=
_configuration_logfile_helper
(
to_save
,
gdriveError
)
if
message
:
...
...
@@ -694,7 +696,7 @@ def _configuration_update_helper():
return
_configuration_result
(
'
%
s'
%
e
,
gdriveError
)
if
db_change
:
if
not
db
.
setup_db
(
config
,
ub
.
app_DB_path
):
if
not
calibre_
db
.
setup_db
(
config
,
ub
.
app_DB_path
):
return
_configuration_result
(
_
(
'DB Location is not Valid, Please Enter Correct Path'
),
gdriveError
)
if
not
os
.
access
(
os
.
path
.
join
(
config
.
config_calibre_dir
,
"metadata.db"
),
os
.
W_OK
):
flash
(
_
(
u"DB is not Writeable"
),
category
=
"warning"
)
...
...
cps/gdrive.py
View file @
0cf1cc55
...
...
@@ -39,7 +39,7 @@ try:
except
ImportError
:
pass
from
.
import
logger
,
gdriveutils
,
config
,
db
,
u
b
from
.
import
logger
,
gdriveutils
,
config
,
ub
,
calibre_d
b
from
.web
import
admin_required
...
...
@@ -155,7 +155,7 @@ def on_received_watch_confirmation():
log
.
info
(
'Setting up new DB'
)
# prevent error on windows, as os.rename does on exisiting files
move
(
os
.
path
.
join
(
tmpDir
,
"tmp_metadata.db"
),
dbpath
)
db
.
setup_db
(
config
,
ub
.
app_DB_path
)
calibre_
db
.
setup_db
(
config
,
ub
.
app_DB_path
)
except
Exception
as
e
:
log
.
exception
(
e
)
updateMetaData
()
...
...
cps/helper.py
View file @
0cf1cc55
...
...
@@ -879,7 +879,7 @@ def get_cc_columns(filter_config_custom_read=False):
for
col
in
tmpcc
:
if
filter_config_custom_read
and
config
.
config_read_column
and
config
.
config_read_column
==
col
.
id
:
continue
if
r
and
r
.
match
(
col
.
label
):
if
r
and
r
.
match
(
col
.
name
):
continue
cc
.
append
(
col
)
...
...
cps/kobo.py
View file @
0cf1cc55
...
...
@@ -143,7 +143,7 @@ def HandleSyncRequest():
# We reload the book database so that the user get's a fresh view of the library
# in case of external changes (e.g: adding a book through Calibre).
db
.
reconnect_db
(
config
,
ub
.
app_DB_path
)
calibre_
db
.
reconnect_db
(
config
,
ub
.
app_DB_path
)
archived_books
=
(
ub
.
session
.
query
(
ub
.
ArchivedBook
)
...
...
cps/web.py
View file @
0cf1cc55
...
...
@@ -121,9 +121,9 @@ for ex in default_exceptions:
if
feature_support
[
'ldap'
]:
# Only way of catching the LDAPException upon logging in with LDAP server down
@
app
.
errorhandler
(
services
.
ldap
.
LDAPException
)
def
handle_
LDAP_
exception
(
e
):
log
.
debug
(
'LDAP server not acc
ssible while trying to login to opds feed
%
s'
,
e
)
return
error_http
(
e
)
def
handle_exception
(
e
):
log
.
debug
(
'LDAP server not acc
essible while trying to login to opds feed'
)
return
error_http
(
FailedDependency
()
)
# @app.errorhandler(InvalidRequestError)
#@app.errorhandler(OperationalError)
...
...
@@ -889,7 +889,7 @@ def ratings_list():
if
current_user
.
check_visibility
(
constants
.
SIDEBAR_RATING
):
entries
=
calibre_db
.
session
.
query
(
db
.
Ratings
,
func
.
count
(
'books_ratings_link.book'
)
.
label
(
'count'
),
(
db
.
Ratings
.
rating
/
2
)
.
label
(
'name'
))
\
.
join
(
calibre_
db
.
books_ratings_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
join
(
db
.
books_ratings_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
group_by
(
text
(
'books_ratings_link.rating'
))
.
order_by
(
db
.
Ratings
.
rating
)
.
all
()
return
render_title_template
(
'list.html'
,
entries
=
entries
,
folder
=
'web.books_list'
,
charlist
=
list
(),
title
=
_
(
u"Ratings list"
),
page
=
"ratingslist"
,
data
=
"ratings"
)
...
...
cps/worker.py
View file @
0cf1cc55
...
...
@@ -333,7 +333,6 @@ class WorkerThread(threading.Thread):
task
=
{
'task'
:
'add_format'
,
'id'
:
bookid
,
'format'
:
new_format
}
self
.
db_queue
.
put
(
task
)
# To Do how to handle error?
print
(
'finished'
)
'''cur_book.data.append(new_format)
try:
...
...
test/Calibre-Web TestSummary.html
View file @
0cf1cc55
This diff is collapsed.
Click to expand it.
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