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
86fe9706
Commit
86fe9706
authored
Dec 14, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More fixes for googledrive
parent
e308a74d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
admin.py
cps/admin.py
+6
-1
gdrive.py
cps/gdrive.py
+5
-1
gdriveutils.py
cps/gdriveutils.py
+4
-0
No files found.
cps/admin.py
View file @
86fe9706
...
...
@@ -170,6 +170,9 @@ def update_view_configuration():
_config_int
(
"config_books_per_page"
)
_config_int
(
"config_authors_max"
)
if
config
.
config_google_drive_watch_changes_response
:
config
.
config_google_drive_watch_changes_response
=
json
.
dumps
(
config
.
config_google_drive_watch_changes_response
)
config
.
config_default_role
=
constants
.
selected_roles
(
to_save
)
config
.
config_default_role
&=
~
constants
.
ROLE_ANONYMOUS
...
...
@@ -258,6 +261,7 @@ def _configuration_update_helper():
db_change
=
False
to_save
=
request
.
form
.
to_dict
()
# _config_dict = lambda x: config.set_from_dictionary(to_save, x, lambda y: y['id'])
_config_string
=
lambda
x
:
config
.
set_from_dictionary
(
to_save
,
x
,
lambda
y
:
y
.
strip
()
if
y
else
y
)
_config_int
=
lambda
x
:
config
.
set_from_dictionary
(
to_save
,
x
,
int
)
_config_checkbox
=
lambda
x
:
config
.
set_from_dictionary
(
to_save
,
x
,
lambda
y
:
y
==
"on"
,
False
)
...
...
@@ -415,7 +419,8 @@ def _configuration_result(error_flash=None, gdriveError=None):
if
gdriveError
:
gdriveError
=
_
(
gdriveError
)
else
:
if
config
.
config_use_google_drive
and
not
gdrive_authenticate
:
# if config.config_use_google_drive and\
if
not
gdrive_authenticate
:
gdrivefolders
=
gdriveutils
.
listRootFolders
()
show_back_button
=
current_user
.
is_authenticated
...
...
cps/gdrive.py
View file @
86fe9706
...
...
@@ -23,6 +23,7 @@
from
__future__
import
division
,
print_function
,
unicode_literals
import
os
import
sys
import
hashlib
import
json
import
tempfile
...
...
@@ -141,7 +142,10 @@ def on_received_watch_confirmation():
response
=
gdriveutils
.
getChangeById
(
gdriveutils
.
Gdrive
.
Instance
()
.
drive
,
j
[
'id'
])
log
.
debug
(
'
%
r'
,
response
)
if
response
:
dbpath
=
os
.
path
.
join
(
config
.
config_calibre_dir
,
"metadata.db"
)
if
sys
.
version_info
<
(
3
,
0
):
dbpath
=
os
.
path
.
join
(
config
.
config_calibre_dir
,
"metadata.db"
)
else
:
dbpath
=
os
.
path
.
join
(
config
.
config_calibre_dir
,
"metadata.db"
)
.
encode
()
if
not
response
[
'deleted'
]
and
response
[
'file'
][
'title'
]
==
'metadata.db'
and
response
[
'file'
][
'md5Checksum'
]
!=
hashlib
.
md5
(
dbpath
):
tmpDir
=
tempfile
.
gettempdir
()
log
.
info
(
'Database file updated'
)
...
...
cps/gdriveutils.py
View file @
86fe9706
...
...
@@ -47,6 +47,10 @@ CREDENTIALS = os.path.join(_CONFIG_DIR, 'gdrive_credentials')
CLIENT_SECRETS
=
os
.
path
.
join
(
_CONFIG_DIR
,
'client_secrets.json'
)
log
=
logger
.
create
()
if
gdrive_support
:
logger
.
get
(
'googleapiclient.discovery_cache'
)
.
setLevel
(
logger
.
logging
.
ERROR
)
if
not
logger
.
is_debug_enabled
():
logger
.
get
(
'googleapiclient.discovery'
)
.
setLevel
(
logger
.
logging
.
ERROR
)
class
Singleton
:
...
...
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