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
6a9d8efc
Commit
6a9d8efc
authored
Jul 16, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for #233 (detection of permission errors)
parent
bc665fd0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
helper.py
cps/helper.py
+8
-8
No files found.
cps/helper.py
View file @
6a9d8efc
...
@@ -88,12 +88,11 @@ def make_mobi(book_id, calibrepath):
...
@@ -88,12 +88,11 @@ def make_mobi(book_id, calibrepath):
if
os
.
path
.
exists
(
file_path
+
u".epub"
):
if
os
.
path
.
exists
(
file_path
+
u".epub"
):
try
:
try
:
p
=
subprocess
.
Popen
((
kindlegen
+
"
\"
"
+
file_path
+
u".epub
\"
"
)
.
encode
(
sys
.
getfilesystemencoding
()),
p
=
subprocess
.
Popen
((
kindlegen
+
"
\"
"
+
file_path
+
u".epub
\"
"
)
.
encode
(
sys
.
getfilesystemencoding
()),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
except
Exception
:
except
Exception
:
error_message
=
_
(
u"kindlegen failed, no excecution permissions"
)
error_message
=
_
(
u"kindlegen failed, no excecution permissions"
)
app
.
logger
.
error
(
"make_mobi: "
+
error_message
)
app
.
logger
.
error
(
"make_mobi: "
+
error_message
)
return
error_message
,
RET_FAIL
return
error_message
,
RET_FAIL
# Poll process for new output until finished
# Poll process for new output until finished
while
True
:
while
True
:
nextline
=
p
.
stdout
.
readline
()
nextline
=
p
.
stdout
.
readline
()
...
@@ -122,11 +121,13 @@ def make_mobi(book_id, calibrepath):
...
@@ -122,11 +121,13 @@ def make_mobi(book_id, calibrepath):
db
.
session
.
commit
()
db
.
session
.
commit
()
return
file_path
+
".mobi"
,
RET_SUCCESS
return
file_path
+
".mobi"
,
RET_SUCCESS
else
:
else
:
app
.
logger
.
error
(
"make_mobi: kindlegen failed with error while converting book"
)
app
.
logger
.
info
(
"make_mobi: kindlegen failed with error while converting book"
)
return
None
,
RET_FAIL
if
not
error_message
:
error_message
=
'kindlegen failed, no excecution permissions'
return
error_message
,
RET_FAIL
else
:
else
:
app
.
logger
.
error
(
"make_mobi: epub not found:
%
s.epub"
%
file_path
)
error_message
=
"make_mobi: epub not found:
%
s.epub"
%
file_path
return
Non
e
,
RET_FAIL
return
error_messag
e
,
RET_FAIL
class
StderrLogger
(
object
):
class
StderrLogger
(
object
):
...
@@ -226,11 +227,10 @@ def send_mail(book_id, kindle_mail, calibrepath):
...
@@ -226,11 +227,10 @@ def send_mail(book_id, kindle_mail, calibrepath):
msg
.
attach
(
get_attachment
(
formats
[
'mobi'
]))
msg
.
attach
(
get_attachment
(
formats
[
'mobi'
]))
elif
'epub'
in
formats
:
elif
'epub'
in
formats
:
data
,
resultCode
=
make_mobi
(
book
.
id
,
calibrepath
)
data
,
resultCode
=
make_mobi
(
book
.
id
,
calibrepath
)
app
.
logger
.
error
=
(
data
)
if
resultCode
==
RET_SUCCESS
:
if
resultCode
==
RET_SUCCESS
:
msg
.
attach
(
get_attachment
(
data
))
msg
.
attach
(
get_attachment
(
data
))
else
:
else
:
app
.
logger
.
error
=
(
data
)
return
data
#_("Could not convert epub to mobi")
return
data
#_("Could not convert epub to mobi")
elif
'pdf'
in
formats
:
elif
'pdf'
in
formats
:
msg
.
attach
(
get_attachment
(
formats
[
'pdf'
]))
msg
.
attach
(
get_attachment
(
formats
[
'pdf'
]))
...
...
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