libvips logging + raise codec errors

This commit is contained in:
ed 2022-12-15 22:22:04 +00:00
parent 79aa40fdea
commit b070d44de7
2 changed files with 8 additions and 4 deletions

View file

@ -3,6 +3,7 @@ from __future__ import print_function, unicode_literals
import base64 import base64
import hashlib import hashlib
import logging
import os import os
import shutil import shutil
import subprocess as sp import subprocess as sp
@ -61,12 +62,16 @@ try:
HAVE_AVIF = True HAVE_AVIF = True
except: except:
pass pass
logging.getLogger("PIL").setLevel(logging.WARNING)
except: except:
pass pass
try: try:
HAVE_VIPS = True HAVE_VIPS = True
import pyvips import pyvips
logging.getLogger("pyvips").setLevel(logging.WARNING)
except: except:
HAVE_VIPS = False HAVE_VIPS = False
@ -363,7 +368,8 @@ class ThumbSrv(object):
img = pyvips.Image.thumbnail(abspath, w, **kw) img = pyvips.Image.thumbnail(abspath, w, **kw)
break break
except: except:
pass if c == crops[-1]:
raise
img.write_to_file(tpath, Q=40) img.write_to_file(tpath, Q=40)

View file

@ -437,9 +437,7 @@ class HLog(logging.Handler):
else: else:
c = 1 c = 1
if record.name.startswith("PIL") and lv < logging.WARNING: if record.name == "pyftpdlib":
return
elif record.name == "pyftpdlib":
m = self.ptn_ftp.match(msg) m = self.ptn_ftp.match(msg)
if m: if m:
ip = m.group(1) ip = m.group(1)