Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorent Pigout <florent.pigout@gmail.com>2011-10-17 18:24:38 (GMT)
committer Florent Pigout <florent.pigout@gmail.com>2011-10-17 18:24:38 (GMT)
commit5b626df3de717641b1ac11d26a342ecfb659b907 (patch)
treefdf1f42e712d074dfcdbdbe84b271caff09cd25c
parent425966641affcc8916c787c98b08e6eead399110 (diff)
hide sugar or gtk specific imports for unit tests
-rw-r--r--atoidejouer/tools/image.py9
-rw-r--r--atoidejouer/tools/storage.py10
2 files changed, 13 insertions, 6 deletions
diff --git a/atoidejouer/tools/image.py b/atoidejouer/tools/image.py
index c2d966c..89314dd 100644
--- a/atoidejouer/tools/image.py
+++ b/atoidejouer/tools/image.py
@@ -1,6 +1,11 @@
# python import
-import gtk, logging, os, struct, StringIO
+import logging, os, struct, StringIO
+
+try:
+ import gtk
+except Exception, e:
+ gtk = None
# atoidejouer import
from atoidejouer.tools import registry, storage
@@ -10,6 +15,8 @@ logger = logging.getLogger('atoidejouer')
def get_pixbuf(file_path, max_width, max_height, use_max=False):
+ if gtk is None:
+ return None
# little check
_pixbuf = registry.PixRegistry().get_pix(file_path, max_width, max_height)
# already exist
diff --git a/atoidejouer/tools/storage.py b/atoidejouer/tools/storage.py
index 4c44289..520c146 100644
--- a/atoidejouer/tools/storage.py
+++ b/atoidejouer/tools/storage.py
@@ -1,7 +1,6 @@
# python import
-import dbus, logging, os, shutil, tarfile, time
-# ..
+import logging, os, shutil, tarfile, time
from gettext import gettext as _
# png import from pypng
@@ -11,12 +10,11 @@ from lib import png
try:
from sugar.activity import activity
from sugar.datastore import datastore
- import gtk
+ import dbus, gtk
ROOT = activity.get_activity_root()
BUND = activity.get_bundle_path()
except Exception, e:
- datastore = None
- gtk = None
+ datastore, dbus, gtk = None, None, None
ROOT = os.path.join(os.path.dirname(__file__), '..', '..',
'..', 'atdj_root')
BUND = os.path.join(os.path.dirname(__file__), '..', '..')
@@ -368,6 +366,8 @@ def __get_preview(file_path):
"""Creates preview from file path for ds metadata.
cf.: http://en.flossmanuals.net/make-your-own-sugar-activities/fun-with-the-journal
"""
+ if dbus is None:
+ return None
# avoid inter-dependance loop
from atoidejouer.tools import image
# prepare pixbuf