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
c45968a1
Commit
c45968a1
authored
Jan 31, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix Updater
parent
296d2615
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
16 deletions
+23
-16
.gitattributes
.gitattributes
+1
-1
helper.py
cps/helper.py
+20
-13
web.py
cps/web.py
+2
-2
No files found.
.gitattributes
View file @
c45968a1
* ident
\ No newline at end of file
web.py ident export-subst
cps/helper.py
View file @
c45968a1
...
...
@@ -292,32 +292,40 @@ def reduce_files(remove_items, exclude_items):
def
moveallfiles
(
root_src_dir
,
root_dst_dir
):
change_permissions
=
True
if
sys
.
platform
==
"win32"
or
sys
.
platform
==
"darwin"
:
change_permissions
=
False
change_permissions
=
False
else
:
app
.
logger
.
debug
(
'OS-System : '
+
sys
.
platform
)
new_permissions
=
os
.
stat
(
root_dst_dir
)
app
.
logger
.
debug
(
'Update on OS-System : '
+
sys
.
platform
)
#print('OS-System: '+sys.platform )
new_permissions
=
os
.
stat
(
root_dst_dir
)
#print new_permissions
for
src_dir
,
dirs
,
files
in
os
.
walk
(
root_src_dir
):
dst_dir
=
src_dir
.
replace
(
root_src_dir
,
root_dst_dir
,
1
)
if
not
os
.
path
.
exists
(
dst_dir
):
os
.
makedirs
(
dst_dir
)
#print('Create-Dir: '+dst_dir)
if
change_permissions
:
os
.
chown
(
dst_dir
,
new_permissions
.
ST_UID
,
new_permissions
.
ST_GID
)
#print('Permissions: User '+str(new_permissions.st_uid)+' Group '+str(new_permissions.st_uid))
os
.
chown
(
dst_dir
,
new_permissions
.
st_uid
,
new_permissions
.
st_gid
)
for
file_
in
files
:
src_file
=
os
.
path
.
join
(
src_dir
,
file_
)
dst_file
=
os
.
path
.
join
(
dst_dir
,
file_
)
if
os
.
path
.
exists
(
dst_file
):
if
change_permissions
:
permission
=
os
.
stat
(
dst_file
)
#print('Remove file before copy: '+dst_file)
os
.
remove
(
dst_file
)
else
:
if
change_permissions
:
permission
=
new_permissions
shutil
.
move
(
src_file
,
dst_dir
)
#print('Move File '+src_file+' to '+dst_dir)
if
change_permissions
:
try
:
os
.
chown
(
dst_file
,
permission
.
ST_UID
,
permission
.
ST_GID
)
os
.
chown
(
dst_file
,
permission
.
st_uid
,
permission
.
st_uid
)
#print('Permissions: User '+str(new_permissions.st_uid)+' Group '+str(new_permissions.st_uid))
except
:
pass
e
=
sys
.
exc_info
()
#print('Fail '+str(dst_file)+' error: '+str(e))
return
...
...
@@ -339,26 +347,25 @@ def update_source(source,destination):
new_list
.
append
(
os
.
path
.
join
(
root
,
name
)
.
replace
(
source
,
''
))
delete_files
=
one_minus_two
(
old_list
,
new_list
)
print
(
'raw delete list'
,
delete_files
)
#
print('raw delete list', delete_files)
rf
=
reduce_files
(
delete_files
,
exclude
)
print
(
'reduced delete list'
,
rf
)
#
print('reduced delete list', rf)
remove_items
=
reduce_dirs
(
rf
,
new_list
)
print
(
'delete files'
,
remove_items
)
#
print('delete files', remove_items)
moveallfiles
(
source
,
destination
)
for
item
in
remove_items
:
item_path
=
os
.
path
.
join
(
destination
,
item
[
1
:])
if
os
.
path
.
isdir
(
item_path
):
# app.logger.info("Delete dir "+ item_path)
print
(
"Delete dir "
+
item_path
)
#
shutil.rmtree(item_path)
shutil
.
rmtree
(
item_path
)
else
:
try
:
print
(
"Delete file "
+
item_path
)
#
os.remove(item_path)
os
.
remove
(
item_path
)
except
:
print
(
"Could not remove:"
+
item_path
)
shutil
.
rmtree
(
source
,
ignore_errors
=
True
)
\ No newline at end of file
#shutil.rmtree(source, ignore_errors=True)
cps/web.py
View file @
c45968a1
...
...
@@ -713,9 +713,9 @@ def get_update_status():
status
=
{}
if
request
.
method
==
"GET"
:
# should be automatically replaced by git with current commit hash
commit_id
=
'$
Id
$'
commit_id
=
'$
Format:
%
H
$'
commit
=
requests
.
get
(
'https://api.github.com/repos/janeczku/calibre-web/git/refs/heads/master'
)
.
json
()
if
"object"
in
commit
and
commit
[
'object'
][
'sha'
]
!=
commit_id
[
5
:
-
2
]
:
if
"object"
in
commit
and
commit
[
'object'
][
'sha'
]
!=
commit_id
:
status
[
'status'
]
=
True
else
:
status
[
'status'
]
=
False
...
...
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