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
d9b22fd5
Commit
d9b22fd5
authored
Dec 11, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log exceptions only in debug mode
parent
8b605aea
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
12 deletions
+44
-12
editbooks.py
cps/editbooks.py
+4
-1
gdrive.py
cps/gdrive.py
+4
-1
gdriveutils.py
cps/gdriveutils.py
+4
-1
helper.py
cps/helper.py
+4
-2
oauth_bb.py
cps/oauth_bb.py
+16
-4
worker.py
cps/services/worker.py
+4
-1
web.py
cps/web.py
+8
-2
No files found.
cps/editbooks.py
View file @
d9b22fd5
...
@@ -259,7 +259,10 @@ def delete_book(book_id, book_format, jsonResponse):
...
@@ -259,7 +259,10 @@ def delete_book(book_id, book_format, jsonResponse):
filter
(
db
.
Data
.
format
==
book_format
)
.
delete
()
filter
(
db
.
Data
.
format
==
book_format
)
.
delete
()
calibre_db
.
session
.
commit
()
calibre_db
.
session
.
commit
()
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
e
)
if
config
.
config_log_level
==
logger
.
logging
.
DEBUG
:
log
.
exception
(
e
)
else
:
log
.
error
(
e
)
calibre_db
.
session
.
rollback
()
calibre_db
.
session
.
rollback
()
else
:
else
:
# book not found
# book not found
...
...
cps/gdrive.py
View file @
d9b22fd5
...
@@ -156,5 +156,8 @@ def on_received_watch_confirmation():
...
@@ -156,5 +156,8 @@ def on_received_watch_confirmation():
move
(
os
.
path
.
join
(
tmp_dir
,
"tmp_metadata.db"
),
dbpath
)
move
(
os
.
path
.
join
(
tmp_dir
,
"tmp_metadata.db"
),
dbpath
)
calibre_db
.
reconnect_db
(
config
,
ub
.
app_DB_path
)
calibre_db
.
reconnect_db
(
config
,
ub
.
app_DB_path
)
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
e
)
if
config
.
config_log_level
==
logger
.
logging
.
DEBUG
:
log
.
exception
(
e
)
else
:
log
.
error
(
e
)
return
''
return
''
cps/gdriveutils.py
View file @
d9b22fd5
...
@@ -199,7 +199,10 @@ def getDrive(drive=None, gauth=None):
...
@@ -199,7 +199,10 @@ def getDrive(drive=None, gauth=None):
except
RefreshError
as
e
:
except
RefreshError
as
e
:
log
.
error
(
"Google Drive error:
%
s"
,
e
)
log
.
error
(
"Google Drive error:
%
s"
,
e
)
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
e
)
if
config
.
config_log_level
==
logger
.
logging
.
DEBUG
:
log
.
exception
(
e
)
else
:
log
.
error
(
e
)
else
:
else
:
# Initialize the saved creds
# Initialize the saved creds
gauth
.
Authorize
()
gauth
.
Authorize
()
...
...
cps/helper.py
View file @
d9b22fd5
...
@@ -562,8 +562,10 @@ def get_book_cover_internal(book, use_generic_cover_on_failure):
...
@@ -562,8 +562,10 @@ def get_book_cover_internal(book, use_generic_cover_on_failure):
log
.
error
(
'
%
s/cover.jpg not found on Google Drive'
,
book
.
path
)
log
.
error
(
'
%
s/cover.jpg not found on Google Drive'
,
book
.
path
)
return
get_cover_on_failure
(
use_generic_cover_on_failure
)
return
get_cover_on_failure
(
use_generic_cover_on_failure
)
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
e
)
if
config
.
config_log_level
==
logger
.
logging
.
DEBUG
:
# traceback.print_exc()
log
.
exception
(
e
)
else
:
log
.
error
(
e
)
return
get_cover_on_failure
(
use_generic_cover_on_failure
)
return
get_cover_on_failure
(
use_generic_cover_on_failure
)
else
:
else
:
cover_file_path
=
os
.
path
.
join
(
config
.
config_calibre_dir
,
book
.
path
)
cover_file_path
=
os
.
path
.
join
(
config
.
config_calibre_dir
,
book
.
path
)
...
...
cps/oauth_bb.py
View file @
d9b22fd5
...
@@ -88,7 +88,10 @@ def register_user_with_oauth(user=None):
...
@@ -88,7 +88,10 @@ def register_user_with_oauth(user=None):
try
:
try
:
ub
.
session
.
commit
()
ub
.
session
.
commit
()
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
e
)
if
config
.
config_log_level
==
logger
.
logging
.
DEBUG
:
log
.
exception
(
e
)
else
:
log
.
error
(
e
)
ub
.
session
.
rollback
()
ub
.
session
.
rollback
()
...
@@ -207,7 +210,10 @@ if ub.oauth_support:
...
@@ -207,7 +210,10 @@ if ub.oauth_support:
ub
.
session
.
add
(
oauth_entry
)
ub
.
session
.
add
(
oauth_entry
)
ub
.
session
.
commit
()
ub
.
session
.
commit
()
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
e
)
if
config
.
config_log_level
==
logger
.
logging
.
DEBUG
:
log
.
exception
(
e
)
else
:
log
.
error
(
e
)
ub
.
session
.
rollback
()
ub
.
session
.
rollback
()
# Disable Flask-Dance's default behavior for saving the OAuth token
# Disable Flask-Dance's default behavior for saving the OAuth token
...
@@ -239,7 +245,10 @@ if ub.oauth_support:
...
@@ -239,7 +245,10 @@ if ub.oauth_support:
flash
(
_
(
u"Link to
%(oauth)
s Succeeded"
,
oauth
=
provider_name
),
category
=
"success"
)
flash
(
_
(
u"Link to
%(oauth)
s Succeeded"
,
oauth
=
provider_name
),
category
=
"success"
)
return
redirect
(
url_for
(
'web.profile'
))
return
redirect
(
url_for
(
'web.profile'
))
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
e
)
if
config
.
config_log_level
==
logger
.
logging
.
DEBUG
:
log
.
exception
(
e
)
else
:
log
.
error
(
e
)
ub
.
session
.
rollback
()
ub
.
session
.
rollback
()
else
:
else
:
flash
(
_
(
u"Login failed, No User Linked With OAuth Account"
),
category
=
"error"
)
flash
(
_
(
u"Login failed, No User Linked With OAuth Account"
),
category
=
"error"
)
...
@@ -286,7 +295,10 @@ if ub.oauth_support:
...
@@ -286,7 +295,10 @@ if ub.oauth_support:
logout_oauth_user
()
logout_oauth_user
()
flash
(
_
(
u"Unlink to
%(oauth)
s Succeeded"
,
oauth
=
oauth_check
[
provider
]),
category
=
"success"
)
flash
(
_
(
u"Unlink to
%(oauth)
s Succeeded"
,
oauth
=
oauth_check
[
provider
]),
category
=
"success"
)
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
e
)
if
config
.
config_log_level
==
logger
.
logging
.
DEBUG
:
log
.
exception
(
e
)
else
:
log
.
error
(
e
)
ub
.
session
.
rollback
()
ub
.
session
.
rollback
()
flash
(
_
(
u"Unlink to
%(oauth)
s Failed"
,
oauth
=
oauth_check
[
provider
]),
category
=
"error"
)
flash
(
_
(
u"Unlink to
%(oauth)
s Failed"
,
oauth
=
oauth_check
[
provider
]),
category
=
"error"
)
except
NoResultFound
:
except
NoResultFound
:
...
...
cps/services/worker.py
View file @
d9b22fd5
...
@@ -210,7 +210,10 @@ class CalibreTask:
...
@@ -210,7 +210,10 @@ class CalibreTask:
self
.
_progress
=
x
self
.
_progress
=
x
def
_handleError
(
self
,
error_message
):
def
_handleError
(
self
,
error_message
):
log
.
exception
(
error_message
)
if
logger
.
is_debug_enabled
():
log
.
exception
(
error_message
)
else
:
log
.
error
(
error_message
)
self
.
stat
=
STAT_FAIL
self
.
stat
=
STAT_FAIL
self
.
progress
=
1
self
.
progress
=
1
self
.
error
=
error_message
self
.
error
=
error_message
...
...
cps/web.py
View file @
d9b22fd5
...
@@ -316,7 +316,10 @@ def import_ldap_users():
...
@@ -316,7 +316,10 @@ def import_ldap_users():
try
:
try
:
new_users
=
services
.
ldap
.
get_group_members
(
config
.
config_ldap_group_name
)
new_users
=
services
.
ldap
.
get_group_members
(
config
.
config_ldap_group_name
)
except
(
services
.
ldap
.
LDAPException
,
TypeError
,
AttributeError
,
KeyError
)
as
e
:
except
(
services
.
ldap
.
LDAPException
,
TypeError
,
AttributeError
,
KeyError
)
as
e
:
log
.
exception
(
e
)
if
config
.
config_log_level
==
logger
.
logging
.
DEBUG
:
log
.
exception
(
e
)
else
:
log
.
error
(
e
)
showtext
[
'text'
]
=
_
(
u'Error:
%(ldaperror)
s'
,
ldaperror
=
e
)
showtext
[
'text'
]
=
_
(
u'Error:
%(ldaperror)
s'
,
ldaperror
=
e
)
return
json
.
dumps
(
showtext
)
return
json
.
dumps
(
showtext
)
if
not
new_users
:
if
not
new_users
:
...
@@ -344,7 +347,10 @@ def import_ldap_users():
...
@@ -344,7 +347,10 @@ def import_ldap_users():
try
:
try
:
user_data
=
services
.
ldap
.
get_object_details
(
user
=
user_identifier
,
query_filter
=
query_filter
)
user_data
=
services
.
ldap
.
get_object_details
(
user
=
user_identifier
,
query_filter
=
query_filter
)
except
AttributeError
as
e
:
except
AttributeError
as
e
:
log
.
exception
(
e
)
if
config
.
config_log_level
==
logger
.
logging
.
DEBUG
:
log
.
exception
(
e
)
else
:
log
.
error
(
e
)
continue
continue
if
user_data
:
if
user_data
:
user_login_field
=
extract_dynamic_field_from_filter
(
user
,
config
.
config_ldap_user_object
)
user_login_field
=
extract_dynamic_field_from_filter
(
user
,
config
.
config_ldap_user_object
)
...
...
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