[pessulus] Use runtime check instead hard dependency on gnome-python-desktop



commit 72b2dbcd6d9ea26ef1ef1f327ae058c8a5308a62
Author: Javier Jardón <jjardon gnome org>
Date:   Thu Jun 17 19:15:44 2010 +0200

    Use runtime check instead hard dependency on gnome-python-desktop
    
    Using runtime checking for Python modules is a better way and a
    lot more distro-friendly.

 Pessulus/main.py |   38 ++++++++++++++++++++++++++++++++++++--
 configure.ac     |   11 ++++++++---
 2 files changed, 44 insertions(+), 5 deletions(-)
---
diff --git a/Pessulus/main.py b/Pessulus/main.py
index 421b43e..123f0f6 100644
--- a/Pessulus/main.py
+++ b/Pessulus/main.py
@@ -20,6 +20,38 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
 #
 
+import gtk
+
+def __try_import__(modulename):
+    """
+    Attempt to load given module.
+    Returns True on success, else False.
+    """
+    try:
+        __import__(modulename)
+        return True
+    except:
+        return False
+
+def initial_checks():
+    if not __try_import__("bugbuddy"):
+        return (_("Could not import the bugbuddy Python bindings"),
+                _("Make sure you have the bugbuddy Python bindings installed"))
+
+def _checkDependencies():
+    missing_deps = initial_checks()
+    if missing_deps:
+        message, detail = missing_deps
+        dialog = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
+                                   buttons=gtk.BUTTONS_OK)
+        dialog.set_markup("<b>"+message+"</b>")
+        dialog.format_secondary_text(detail)
+        dialog.run()
+
+        return False
+    return True
+
+
 def main (args):
     import gettext
     import locale
@@ -27,12 +59,14 @@ def main (args):
 
     import pygtk; pygtk.require('2.0');
     
-    import gtk
-
     import maindialog
     import lockdownappliergconf
     import config
 
+    # check for dependencies
+    if not _checkDependencies():
+        return
+
     try:
         locale.setlocale (locale.LC_ALL, "")
     except locale.Error:
diff --git a/configure.ac b/configure.ac
index cd43f70..a2e539e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,9 +11,14 @@ AM_MAINTAINER_MODE
 dnl make sure we keep ACLOCAL_FLAGS around for maintainer builds to work
 AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS")
 
-PKG_CHECK_MODULES(PESSULUS,
-		  pygtk-2.0 >= 2.13.0		\
-		  gnome-python-desktop-2.0 >= 2.17.2)
+PKG_CHECK_MODULES([PESSULUS], [pygtk-2.0 >= 2.13.0])
+
+dnl Note for packagers
+dnl The following requirements are run-time requirements,
+dnl make sure you don't forget them, even though you're able to
+dnl build pitivi without them.
+#
+# bugbuddy python module
 
 GETTEXT_PACKAGE=pessulus
 AC_SUBST(GETTEXT_PACKAGE)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]