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
7b709c15
Commit
7b709c15
authored
Feb 22, 2017
by
Jack Darlington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GitIgnore update + fixes for initial setup
parent
6d30382a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
7 deletions
+15
-7
.gitignore
.gitignore
+3
-0
db.py
cps/db.py
+2
-0
gdriveutils.py
cps/gdriveutils.py
+2
-2
ub.py
cps/ub.py
+1
-1
web.py
cps/web.py
+7
-4
No files found.
.gitignore
View file @
7b709c15
...
...
@@ -23,3 +23,6 @@ cps/static/[0-9]*
*.bak
*.log.*
tags
settings.yaml
gdrive_credentials
\ No newline at end of file
cps/db.py
View file @
7b709c15
...
...
@@ -274,6 +274,8 @@ def setup_db():
return
False
dbpath
=
os
.
path
.
join
(
config
.
config_calibre_dir
,
"metadata.db"
)
if
not
os
.
path
.
exists
(
dbpath
):
return
False
engine
=
create_engine
(
'sqlite:///{0}'
.
format
(
dbpath
.
encode
(
'utf-8'
)),
echo
=
False
)
try
:
conn
=
engine
.
connect
()
...
...
cps/gdriveutils.py
View file @
7b709c15
...
...
@@ -204,9 +204,9 @@ def copyToDrive(drive, uploadFile, createRoot, replaceFiles,
if
os
.
path
.
basename
(
uploadFile
)
not
in
ignoreFiles
:
existingFiles
=
drive
.
ListFile
({
'q'
:
"title = '
%
s' and '
%
s' in parents and trashed = false"
%
(
os
.
path
.
basename
(
uploadFile
),
parent
[
'id'
])})
.
GetList
()
if
len
(
existingFiles
)
>
0
:
driveFile
=
drive
.
CreateFile
({
'title'
:
os
.
path
.
basename
(
uploadFile
),
'parents'
:
[{
"kind"
:
"drive#fileLink"
,
'id'
:
parent
[
'id'
]}],
})
else
:
driveFile
=
existingFiles
[
0
]
else
:
driveFile
=
drive
.
CreateFile
({
'title'
:
os
.
path
.
basename
(
uploadFile
),
'parents'
:
[{
"kind"
:
"drive#fileLink"
,
'id'
:
parent
[
'id'
]}],
})
driveFile
.
SetContentFile
(
os
.
path
.
join
(
prevDir
,
uploadFile
))
driveFile
.
Upload
()
...
...
cps/ub.py
View file @
7b709c15
...
...
@@ -312,7 +312,7 @@ class Config:
else
:
self
.
config_google_drive_watch_changes_response
=
None
if
self
.
config_calibre_dir
is
not
None
:
if
(
self
.
config_calibre_dir
is
not
None
and
not
self
.
config_use_google_drive
)
or
os
.
path
.
exists
(
self
.
config_calibre_dir
+
'/metadata.db'
)
:
self
.
db_configured
=
True
else
:
self
.
db_configured
=
False
...
...
cps/web.py
View file @
7b709c15
...
...
@@ -43,6 +43,7 @@ import re
import
db
from
shutil
import
move
,
copyfile
from
tornado.ioloop
import
IOLoop
import
shutil
import
StringIO
from
shutil
import
move
import
gdriveutils
...
...
@@ -198,6 +199,9 @@ lm.anonymous_user = ub.Anonymous
app
.
secret_key
=
'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
db
.
setup_db
()
def
is_gdrive_ready
():
return
os
.
path
.
exists
(
'settings.yaml'
)
and
os
.
path
.
exists
(
'gdrive_credentials'
)
@
babel
.
localeselector
def
get_locale
():
# if a user is logged in, use the locale from the user settings
...
...
@@ -1889,17 +1893,14 @@ def configuration_helper(origin):
if
content
.
config_google_drive_client_id
!=
to_save
[
"config_google_drive_client_id"
]:
content
.
config_google_drive_client_id
=
to_save
[
"config_google_drive_client_id"
]
create_new_yaml
=
True
db_change
=
True
if
"config_google_drive_client_secret"
in
to_save
:
if
content
.
config_google_drive_client_secret
!=
to_save
[
"config_google_drive_client_secret"
]:
content
.
config_google_drive_client_secret
=
to_save
[
"config_google_drive_client_secret"
]
create_new_yaml
=
True
db_change
=
True
if
"config_google_drive_calibre_url_base"
in
to_save
:
if
content
.
config_google_drive_calibre_url_base
!=
to_save
[
"config_google_drive_calibre_url_base"
]:
content
.
config_google_drive_calibre_url_base
=
to_save
[
"config_google_drive_calibre_url_base"
]
create_new_yaml
=
True
db_change
=
True
if
(
"config_use_google_drive"
in
to_save
and
not
content
.
config_use_google_drive
)
or
(
"config_use_google_drive"
not
in
to_save
and
content
.
config_use_google_drive
):
content
.
config_use_google_drive
=
"config_use_google_drive"
in
to_save
db_change
=
True
...
...
@@ -1953,6 +1954,8 @@ def configuration_helper(origin):
if
"passwd_role"
in
to_save
:
content
.
config_default_role
=
content
.
config_default_role
+
ub
.
ROLE_PASSWD
try
:
if
content
.
config_use_google_drive
and
is_gdrive_ready
()
and
not
os
.
path
.
exists
(
config
.
config_calibre_dir
+
"/metadata.db"
):
gdriveutils
.
downloadFile
(
Gdrive
.
Instance
()
.
drive
,
None
,
"metadata.db"
,
config
.
config_calibre_dir
+
"/metadata.db"
)
if
db_change
:
if
config
.
db_configured
:
db
.
session
.
close
()
...
...
@@ -1984,7 +1987,7 @@ def configuration_helper(origin):
if
origin
:
success
=
True
return
render_title_template
(
"config_edit.html"
,
origin
=
origin
,
success
=
success
,
content
=
config
,
show_authenticate_google_drive
=
not
os
.
path
.
exists
(
'settings.yaml'
)
or
not
os
.
path
.
exists
(
'gdrive_credentials'
),
show_authenticate_google_drive
=
not
is_gdrive_ready
(
),
title
=
_
(
u"Basic Configuration"
))
...
...
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