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
fc4dc36c
Commit
fc4dc36c
authored
Jul 23, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #969 (duplicate code "init" in epub reader)
Fix for #890
parent
97a0dccd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
33 deletions
+18
-33
read.html
cps/templates/read.html
+0
-9
worker.py
cps/worker.py
+18
-24
No files found.
cps/templates/read.html
View file @
fc4dc36c
...
...
@@ -79,15 +79,6 @@
</div>
<div
class=
"overlay"
></div>
<script
type=
"text/javascript"
>
window
.
calibre
=
{
filePath
:
"{{ url_for('static', filename='js/libs/') }}"
,
cssPath
:
"{{ url_for('static', filename='css/') }}"
,
bookmarkUrl
:
"{{ url_for('bookmark', book_id=bookid, book_format='EPUB') }}"
,
bookUrl
:
"{{ url_for('get_download_link_ext', book_id=bookid, book_format="
epub
", anyname='file.epub') }}"
,
bookmark
:
"{{ bookmark.bookmark_key if bookmark != None }}"
,
useBookmarks
:
{{
g
.
user
.
is_authenticated
|
tojson
}}
};
</script>
<script
src=
"{{ url_for('static', filename='js/libs/jszip.min.js') }}"
>
</script>
<script
src=
"{{ url_for('static', filename='js/libs/epub.min.js') }}"
></script>
<script
type=
"text/javascript"
>
...
...
cps/worker.py
View file @
fc4dc36c
...
...
@@ -187,16 +187,16 @@ class WorkerThread(threading.Thread):
self
.
UIqueue
=
list
()
self
.
asyncSMTP
=
None
self
.
id
=
0
self
.
doLock
=
threading
.
Lock
()
# Main thread loop starting the different tasks
def
run
(
self
):
main_thread
=
_get_main_thread
()
while
main_thread
.
is_alive
():
doLock
=
threading
.
Lock
()
doLock
.
acquire
()
self
.
doLock
.
acquire
()
if
self
.
current
!=
self
.
last
:
index
=
self
.
current
doLock
.
release
()
self
.
doLock
.
release
()
if
self
.
queue
[
index
][
'taskType'
]
==
TASK_EMAIL
:
self
.
_send_raw_email
()
if
self
.
queue
[
index
][
'taskType'
]
==
TASK_CONVERT
:
...
...
@@ -204,11 +204,11 @@ class WorkerThread(threading.Thread):
if
self
.
queue
[
index
][
'taskType'
]
==
TASK_CONVERT_ANY
:
self
.
_convert_any_format
()
# TASK_UPLOAD is handled implicitly
doLock
.
acquire
()
self
.
doLock
.
acquire
()
self
.
current
+=
1
doLock
.
release
()
self
.
doLock
.
release
()
else
:
doLock
.
release
()
self
.
doLock
.
release
()
if
main_thread
.
is_alive
():
time
.
sleep
(
1
)
...
...
@@ -229,8 +229,7 @@ class WorkerThread(threading.Thread):
self
.
last
=
len
(
self
.
queue
)
def
get_taskstatus
(
self
):
doLock
=
threading
.
Lock
()
doLock
.
acquire
()
self
.
doLock
.
acquire
()
if
self
.
current
<
len
(
self
.
queue
):
if
self
.
UIqueue
[
self
.
current
][
'stat'
]
==
STAT_STARTED
:
if
self
.
queue
[
self
.
current
][
'taskType'
]
==
TASK_EMAIL
:
...
...
@@ -239,15 +238,14 @@ class WorkerThread(threading.Thread):
self
.
UIqueue
[
self
.
current
][
'rt'
]
=
self
.
UIqueue
[
self
.
current
][
'formRuntime'
]
.
days
*
24
*
60
\
+
self
.
UIqueue
[
self
.
current
][
'formRuntime'
]
.
seconds
\
+
self
.
UIqueue
[
self
.
current
][
'formRuntime'
]
.
microseconds
doLock
.
release
()
self
.
doLock
.
release
()
return
self
.
UIqueue
def
_convert_any_format
(
self
):
# convert book, and upload in case of google drive
doLock
=
threading
.
Lock
()
doLock
.
acquire
()
self
.
doLock
.
acquire
()
index
=
self
.
current
doLock
.
release
()
self
.
doLock
.
release
()
self
.
UIqueue
[
index
][
'stat'
]
=
STAT_STARTED
self
.
queue
[
index
][
'starttime'
]
=
datetime
.
now
()
self
.
UIqueue
[
index
][
'formStarttime'
]
=
self
.
queue
[
self
.
current
][
'starttime'
]
...
...
@@ -264,10 +262,9 @@ class WorkerThread(threading.Thread):
def
_convert_ebook_format
(
self
):
error_message
=
None
doLock
=
threading
.
Lock
()
doLock
.
acquire
()
self
.
doLock
.
acquire
()
index
=
self
.
current
doLock
.
release
()
self
.
doLock
.
release
()
file_path
=
self
.
queue
[
index
][
'file_path'
]
bookid
=
self
.
queue
[
index
][
'bookid'
]
format_old_ext
=
u'.'
+
self
.
queue
[
index
][
'settings'
][
'old_book_format'
]
.
lower
()
...
...
@@ -444,10 +441,9 @@ class WorkerThread(threading.Thread):
def
_send_raw_email
(
self
):
doLock
=
threading
.
Lock
()
doLock
.
acquire
()
self
.
doLock
.
acquire
()
index
=
self
.
current
doLock
.
release
()
self
.
doLock
.
release
()
self
.
queue
[
index
][
'starttime'
]
=
datetime
.
now
()
self
.
UIqueue
[
index
][
'formStarttime'
]
=
self
.
queue
[
index
][
'starttime'
]
self
.
UIqueue
[
index
][
'stat'
]
=
STAT_STARTED
...
...
@@ -524,20 +520,18 @@ class WorkerThread(threading.Thread):
def
_handleError
(
self
,
error_message
):
log
.
error
(
error_message
)
doLock
=
threading
.
Lock
()
doLock
.
acquire
()
self
.
doLock
.
acquire
()
index
=
self
.
current
doLock
.
release
()
self
.
doLock
.
release
()
self
.
UIqueue
[
index
][
'stat'
]
=
STAT_FAIL
self
.
UIqueue
[
index
][
'progress'
]
=
"100
%
"
self
.
UIqueue
[
index
][
'formRuntime'
]
=
datetime
.
now
()
-
self
.
queue
[
self
.
current
][
'starttime'
]
self
.
UIqueue
[
index
][
'message'
]
=
error_message
def
_handleSuccess
(
self
):
doLock
=
threading
.
Lock
()
doLock
.
acquire
()
self
.
doLock
.
acquire
()
index
=
self
.
current
doLock
.
release
()
self
.
doLock
.
release
()
self
.
UIqueue
[
index
][
'stat'
]
=
STAT_FINISH_SUCCESS
self
.
UIqueue
[
index
][
'progress'
]
=
"100
%
"
self
.
UIqueue
[
index
][
'formRuntime'
]
=
datetime
.
now
()
-
self
.
queue
[
self
.
current
][
'starttime'
]
...
...
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