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
e6c6c26f
Commit
e6c6c26f
authored
May 25, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No error 500 if kindlegen is not excecutable
parent
0a08a071
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
helper.py
cps/helper.py
+9
-3
web.py
cps/web.py
+10
-7
No files found.
cps/helper.py
View file @
e6c6c26f
...
...
@@ -86,8 +86,14 @@ def make_mobi(book_id, calibrepath):
file_path
=
os
.
path
.
join
(
calibrepath
,
book
.
path
,
data
.
name
)
if
os
.
path
.
exists
(
file_path
+
u".epub"
):
p
=
subprocess
.
Popen
((
kindlegen
+
"
\"
"
+
file_path
+
u".epub
\"
"
)
.
encode
(
sys
.
getfilesystemencoding
()),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
try
:
p
=
subprocess
.
Popen
((
kindlegen
+
"
\"
"
+
file_path
+
u".epub
\"
"
)
.
encode
(
sys
.
getfilesystemencoding
()),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
except
:
error_message
=
_
(
u"kindlegen failed, no excecution permissions"
)
app
.
logger
.
error
(
"make_mobi: "
+
error_message
)
return
error_message
,
RET_FAIL
# Poll process for new output until finished
while
True
:
nextline
=
p
.
stdout
.
readline
()
...
...
@@ -117,7 +123,7 @@ def make_mobi(book_id, calibrepath):
return
file_path
+
".mobi"
,
RET_SUCCESS
else
:
app
.
logger
.
error
(
"make_mobi: kindlegen failed with error while converting book"
)
return
error_messag
e
,
RET_FAIL
return
Non
e
,
RET_FAIL
else
:
app
.
logger
.
error
(
"make_mobi: epub not found:
%
s.epub"
%
file_path
)
return
None
,
RET_FAIL
...
...
cps/web.py
View file @
e6c6c26f
...
...
@@ -1261,13 +1261,16 @@ def stats():
kindlegen
=
os
.
path
.
join
(
vendorpath
,
u"kindlegen"
)
versions
[
'KindlegenVersion'
]
=
_
(
'not installed'
)
if
os
.
path
.
exists
(
kindlegen
):
p
=
subprocess
.
Popen
(
kindlegen
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
p
.
wait
()
for
lines
in
p
.
stdout
.
readlines
():
if
isinstance
(
lines
,
bytes
):
lines
=
lines
.
decode
(
'utf-8'
)
if
re
.
search
(
'Amazon kindlegen
\
('
,
lines
):
versions
[
'KindlegenVersion'
]
=
lines
try
:
p
=
subprocess
.
Popen
(
kindlegen
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
p
.
wait
()
for
lines
in
p
.
stdout
.
readlines
():
if
isinstance
(
lines
,
bytes
):
lines
=
lines
.
decode
(
'utf-8'
)
if
re
.
search
(
'Amazon kindlegen
\
('
,
lines
):
versions
[
'KindlegenVersion'
]
=
lines
except
:
versions
[
'KindlegenVersion'
]
=
_
(
'Excecution permissions missing'
)
versions
[
'PythonVersion'
]
=
sys
.
version
versions
[
'babel'
]
=
babelVersion
versions
[
'sqlalchemy'
]
=
sqlalchemyVersion
...
...
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