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
7d08cde8
Commit
7d08cde8
authored
5 years ago
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update error handling cover upload
parent
d3c2bf7d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
helper.py
cps/helper.py
+6
-3
No files found.
cps/helper.py
View file @
7d08cde8
...
...
@@ -31,8 +31,6 @@ from datetime import datetime, timedelta
from
tempfile
import
gettempdir
import
requests
from
babel
import
Locale
as
LC
from
babel.core
import
UnknownLocaleError
from
babel.dates
import
format_datetime
from
babel.units
import
format_unit
from
flask
import
send_from_directory
,
make_response
,
redirect
,
abort
...
...
@@ -56,6 +54,7 @@ except ImportError:
try
:
from
PIL
import
Image
as
PILImage
from
PIL
import
UnidentifiedImageError
use_PIL
=
True
except
ImportError
:
use_PIL
=
False
...
...
@@ -535,12 +534,16 @@ def save_cover_from_url(url, book_path):
try
:
img
=
requests
.
get
(
url
,
timeout
=
(
10
,
200
))
# ToDo: Error Handling
img
.
raise_for_status
()
return
save_cover
(
img
,
book_path
)
except
(
requests
.
exceptions
.
HTTPError
,
requests
.
exceptions
.
ConnectionError
,
requests
.
exceptions
.
Timeout
)
as
ex
:
log
.
info
(
u'Cover Download Error
%
s'
,
ex
)
return
False
,
_
(
"Error Downloading Cover"
)
return
save_cover
(
img
,
book_path
)
except
UnidentifiedImageError
as
ex
:
log
.
info
(
u'File Format Error
%
s'
,
ex
)
return
False
,
_
(
"Cover Format Error"
)
def
save_cover_from_filestorage
(
filepath
,
saved_filename
,
img
):
...
...
This diff is collapsed.
Click to expand it.
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