PIL: Support systems with Pillow and without

Fixes for systems with Pillow, but leaves a "try: except ImportError" to
support anything that doesn't have a PIL top level import.

Signed-off-by: Alon Levy <alon@pobox.com>
This commit is contained in:
Alon Levy 2013-04-08 11:19:56 +03:00
parent 519bcfb0e6
commit d0e9f843e2
8 changed files with 34 additions and 11 deletions

View File

@ -20,7 +20,7 @@
# Bram de Jong <bram.dejong at domain.com where domain in gmail> # Bram de Jong <bram.dejong at domain.com where domain in gmail>
# 2012, Joar Wandborg <first name at last name dot se> # 2012, Joar Wandborg <first name at last name dot se>
import Image, ImageDraw, ImageColor #@UnresolvedImport from PIL import Image, ImageDraw, ImageColor #@UnresolvedImport
from functools import partial from functools import partial
import math import math
import numpy import numpy

View File

@ -14,9 +14,14 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import Image try:
import ImageFont from PIL import Image
import ImageDraw from PIL import ImageFont
from PIL import ImageDraw
except ImportError:
import Image
import ImageFont
import ImageDraw
import logging import logging
import pkg_resources import pkg_resources
import os import os

View File

@ -15,7 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import chardet import chardet
import os import os
import Image try:
from PIL import Image
except ImportError:
import Image
import logging import logging
from mediagoblin import mg_globals as mgg from mediagoblin import mg_globals as mgg
@ -42,7 +45,7 @@ def process_ascii(proc_state):
"""Code to process a txt file. Will be run by celery. """Code to process a txt file. Will be run by celery.
A Workbench() represents a local tempory dir. It is automatically A Workbench() represents a local tempory dir. It is automatically
cleaned up when this function exits. cleaned up when this function exits.
""" """
entry = proc_state.entry entry = proc_state.entry
workbench = proc_state.workbench workbench = proc_state.workbench

View File

@ -19,7 +19,10 @@
# Bram de Jong <bram.dejong at domain.com where domain in gmail> # Bram de Jong <bram.dejong at domain.com where domain in gmail>
# 2012, Joar Wandborg <first name at last name dot se> # 2012, Joar Wandborg <first name at last name dot se>
from PIL import Image try:
from PIL import Image
except ImportError:
import Image
import math import math
import numpy import numpy

View File

@ -15,7 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import Image try:
from PIL import Image
except ImportError:
import Image
from mediagoblin.processing import BadMediaFail from mediagoblin.processing import BadMediaFail
from mediagoblin.media_types.audio import audioprocessing from mediagoblin.media_types.audio import audioprocessing

View File

@ -14,7 +14,10 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import Image try:
from PIL import Image
except ImportError:
import Image
import os import os
import logging import logging

View File

@ -26,7 +26,10 @@ import pygst
pygst.require('0.10') pygst.require('0.10')
import gst import gst
import struct import struct
import Image try:
from PIL import Image
except ImportError:
import Image
from gst.extend import discoverer from gst.extend import discoverer

View File

@ -15,7 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import os import os
import Image try:
from PIL import Image
except ImportError:
import Image
from mediagoblin.tools.exif import exif_fix_image_orientation, \ from mediagoblin.tools.exif import exif_fix_image_orientation, \
extract_exif, clean_exif, get_gps_data, get_useful extract_exif, clean_exif, get_gps_data, get_useful