aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2013-04-08 11:19:56 +0300
committerAlon Levy <alon@pobox.com>2013-04-17 12:54:54 +0300
commitd0e9f843e23196f790b640327bef3718e74b0347 (patch)
treebe7453ce7e6109328a98d7e5efd7cc4bac1aa8e5
parent519bcfb0e6753f53fb5fc52a5b76d0472fda4ac7 (diff)
downloadmediagoblin-d0e9f843e23196f790b640327bef3718e74b0347.tar.lz
mediagoblin-d0e9f843e23196f790b640327bef3718e74b0347.tar.xz
mediagoblin-d0e9f843e23196f790b640327bef3718e74b0347.zip
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>
-rw-r--r--extlib/freesound/audioprocessing.py2
-rw-r--r--mediagoblin/media_types/ascii/asciitoimage.py11
-rw-r--r--mediagoblin/media_types/ascii/processing.py7
-rw-r--r--mediagoblin/media_types/audio/spectrogram.py5
-rw-r--r--mediagoblin/media_types/audio/transcoders.py5
-rw-r--r--mediagoblin/media_types/image/processing.py5
-rw-r--r--mediagoblin/media_types/video/transcoders.py5
-rw-r--r--mediagoblin/tests/test_exif.py5
8 files changed, 34 insertions, 11 deletions
diff --git a/extlib/freesound/audioprocessing.py b/extlib/freesound/audioprocessing.py
index c1dfe2eb..2c2b35b5 100644
--- a/extlib/freesound/audioprocessing.py
+++ b/extlib/freesound/audioprocessing.py
@@ -20,7 +20,7 @@
# Bram de Jong <bram.dejong at domain.com where domain in gmail>
# 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
import math
import numpy
diff --git a/mediagoblin/media_types/ascii/asciitoimage.py b/mediagoblin/media_types/ascii/asciitoimage.py
index 108de023..786941f6 100644
--- a/mediagoblin/media_types/ascii/asciitoimage.py
+++ b/mediagoblin/media_types/ascii/asciitoimage.py
@@ -14,9 +14,14 @@
# 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/>.
-import Image
-import ImageFont
-import ImageDraw
+try:
+ from PIL import Image
+ from PIL import ImageFont
+ from PIL import ImageDraw
+except ImportError:
+ import Image
+ import ImageFont
+ import ImageDraw
import logging
import pkg_resources
import os
diff --git a/mediagoblin/media_types/ascii/processing.py b/mediagoblin/media_types/ascii/processing.py
index 309aab0a..2f6079be 100644
--- a/mediagoblin/media_types/ascii/processing.py
+++ b/mediagoblin/media_types/ascii/processing.py
@@ -15,7 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import chardet
import os
-import Image
+try:
+ from PIL import Image
+except ImportError:
+ import Image
import logging
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.
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
workbench = proc_state.workbench
diff --git a/mediagoblin/media_types/audio/spectrogram.py b/mediagoblin/media_types/audio/spectrogram.py
index 458855c1..dd4d0299 100644
--- a/mediagoblin/media_types/audio/spectrogram.py
+++ b/mediagoblin/media_types/audio/spectrogram.py
@@ -19,7 +19,10 @@
# Bram de Jong <bram.dejong at domain.com where domain in gmail>
# 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 numpy
diff --git a/mediagoblin/media_types/audio/transcoders.py b/mediagoblin/media_types/audio/transcoders.py
index 3a9a2125..84e6af7e 100644
--- a/mediagoblin/media_types/audio/transcoders.py
+++ b/mediagoblin/media_types/audio/transcoders.py
@@ -15,7 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
-import Image
+try:
+ from PIL import Image
+except ImportError:
+ import Image
from mediagoblin.processing import BadMediaFail
from mediagoblin.media_types.audio import audioprocessing
diff --git a/mediagoblin/media_types/image/processing.py b/mediagoblin/media_types/image/processing.py
index e951ef29..93f9d03e 100644
--- a/mediagoblin/media_types/image/processing.py
+++ b/mediagoblin/media_types/image/processing.py
@@ -14,7 +14,10 @@
# 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/>.
-import Image
+try:
+ from PIL import Image
+except ImportError:
+ import Image
import os
import logging
diff --git a/mediagoblin/media_types/video/transcoders.py b/mediagoblin/media_types/video/transcoders.py
index 58b2c0d4..90a767dd 100644
--- a/mediagoblin/media_types/video/transcoders.py
+++ b/mediagoblin/media_types/video/transcoders.py
@@ -26,7 +26,10 @@ import pygst
pygst.require('0.10')
import gst
import struct
-import Image
+try:
+ from PIL import Image
+except ImportError:
+ import Image
from gst.extend import discoverer
diff --git a/mediagoblin/tests/test_exif.py b/mediagoblin/tests/test_exif.py
index 5eeaa676..824de3c2 100644
--- a/mediagoblin/tests/test_exif.py
+++ b/mediagoblin/tests/test_exif.py
@@ -15,7 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
-import Image
+try:
+ from PIL import Image
+except ImportError:
+ import Image
from mediagoblin.tools.exif import exif_fix_image_orientation, \
extract_exif, clean_exif, get_gps_data, get_useful