conduit r1245 - in trunk: . conduit conduit/dataproviders conduit/modules scripts test/python-tests



Author: jstowers
Date: Thu Jan 17 23:09:29 2008
New Revision: 1245
URL: http://svn.gnome.org/viewvc/conduit?rev=1245&view=rev

Log:
2008-01-18  John Stowers  <john stowers gmail com>

	* conduit/Main.py:
	* conduit/Utils.py:
	* conduit/dataproviders/VolumeFactory.py:
	* conduit/modules/TomboyModule.py: Change Utils.dbus_service_available 
	so that the bus parameter is optional

	* scripts/continuous-tester.sh:
	* test/python-tests/TestDataProviderTomboy.py:
	* test/python-tests/TestSyncTomboyFolder.py:
	* test/python-tests/TestSyncTomboyiPod.py: Skip tomboy tests if tomboy
	is not running

	* test/python-tests/common.py: Run the sync tests by default



Modified:
   trunk/ChangeLog
   trunk/conduit/Main.py
   trunk/conduit/Utils.py
   trunk/conduit/dataproviders/VolumeFactory.py
   trunk/conduit/modules/TomboyModule.py
   trunk/scripts/continuous-tester.sh
   trunk/test/python-tests/TestDataProviderTomboy.py
   trunk/test/python-tests/TestSyncTomboyFolder.py
   trunk/test/python-tests/TestSyncTomboyiPod.py
   trunk/test/python-tests/common.py

Modified: trunk/conduit/Main.py
==============================================================================
--- trunk/conduit/Main.py	(original)
+++ trunk/conduit/Main.py	Thu Jan 17 23:09:29 2008
@@ -79,7 +79,7 @@
         #Make conduit single instance. If conduit is already running then
         #make the original process build or show the gui
         sessionBus = dbus.SessionBus()
-        if Utils.dbus_service_available(sessionBus, APPLICATION_DBUS_IFACE):
+        if Utils.dbus_service_available(APPLICATION_DBUS_IFACE, sessionBus):
             log.info("Conduit is already running")
             obj = sessionBus.get_object(APPLICATION_DBUS_IFACE, "/activate")
             conduitApp = dbus.Interface(obj, APPLICATION_DBUS_IFACE)

Modified: trunk/conduit/Utils.py
==============================================================================
--- trunk/conduit/Utils.py	(original)
+++ trunk/conduit/Utils.py	Thu Jan 17 23:09:29 2008
@@ -167,14 +167,20 @@
         data = md5.md5(data).hexdigest()
         return data
 
-def dbus_service_available(bus,interface):
+def dbus_service_available(interface, bus=None):
     """
     Checks if a dbus service is available on the given bus
+    @param interface: The interface to look for
+    @param bus: The bus to look on (optional)
     """
     try: 
         import dbus
     except: 
         return False
+        
+    if bus == None:        
+        bus = dbus.SessionBus()
+        
     obj = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus') 
     dbus_iface = dbus.Interface(obj, 'org.freedesktop.DBus') 
     avail = dbus_iface.ListNames()

Modified: trunk/conduit/dataproviders/VolumeFactory.py
==============================================================================
--- trunk/conduit/dataproviders/VolumeFactory.py	(original)
+++ trunk/conduit/dataproviders/VolumeFactory.py	Thu Jan 17 23:09:29 2008
@@ -21,7 +21,7 @@
         self.vol_monitor = Vfs.VolumeMonitor()
         self.bus = dbus.SystemBus()
 
-        if Utils.dbus_service_available(self.bus,'org.freedesktop.Hal'):
+        if Utils.dbus_service_available('org.freedesktop.Hal', self.bus):
             log.info("HAL Initialized")
             self.vol_monitor.connect("volume-mounted",self._volume_mounted_cb)
             self.vol_monitor.connect("volume-unmounted",self._volume_unmounted_cb)

Modified: trunk/conduit/modules/TomboyModule.py
==============================================================================
--- trunk/conduit/modules/TomboyModule.py	(original)
+++ trunk/conduit/modules/TomboyModule.py	Thu Jan 17 23:09:29 2008
@@ -11,10 +11,6 @@
 import conduit.datatypes.File as File
 import conduit.Utils as Utils
 
-TOMBOY_DBUS_PATH = "/org/gnome/Tomboy/RemoteControl"
-TOMBOY_DBUS_IFACE = "org.gnome.Tomboy"
-TOMBOY_MIN_VERSION = "0.5.10"
-
 MODULES = {
 	"TomboyNoteTwoWay" :        { "type": "dataprovider"    },
 	"TomboyNoteConverter" :     { "type": "converter"       }
@@ -90,6 +86,11 @@
     _in_type_ = "note/tomboy"
     _out_type_ = "note/tomboy"
     _icon_ = "tomboy"
+    
+    TOMBOY_DBUS_PATH = "/org/gnome/Tomboy/RemoteControl"
+    TOMBOY_DBUS_IFACE = "org.gnome.Tomboy"
+    TOMBOY_MIN_VERSION = "0.5.10"
+    
     def __init__(self, *args):
         DataProvider.TwoWay.__init__(self)
         AutoSync.AutoSync.__init__(self)
@@ -101,11 +102,11 @@
             self.remoteTomboy.connect_to_signal("NoteDeleted", lambda uid, x: self.handle_deleted(str(uid)))
 
     def _check_tomboy_version(self):
-        if Utils.dbus_service_available(self.bus,TOMBOY_DBUS_IFACE):
-            obj = self.bus.get_object(TOMBOY_DBUS_IFACE, TOMBOY_DBUS_PATH)
+        if Utils.dbus_service_available(TomboyNoteTwoWay.TOMBOY_DBUS_IFACE, self.bus):
+            obj = self.bus.get_object(TomboyNoteTwoWay.TOMBOY_DBUS_IFACE, TomboyNoteTwoWay.TOMBOY_DBUS_PATH)
             self.remoteTomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")
             version = str(self.remoteTomboy.Version())
-            if version >= TOMBOY_MIN_VERSION:
+            if version >= TomboyNoteTwoWay.TOMBOY_MIN_VERSION:
                 log.info("Using Tomboy Version %s" % version)
                 return True
             else:

Modified: trunk/scripts/continuous-tester.sh
==============================================================================
--- trunk/scripts/continuous-tester.sh	(original)
+++ trunk/scripts/continuous-tester.sh	Thu Jan 17 23:09:29 2008
@@ -3,7 +3,7 @@
 TEST_DIR='/home/john/testing/conduit'
 LOGFILE='/home/john/testing/conduit-test.log'
 SVN_REPO='http://svn.gnome.org/svn/conduit/trunk'
-TEST_OPTIONS='cuDN'
+TEST_OPTIONS='cuDSN'
 SLEEP_TIME='1h'
 
 ME=`basename $0`

Modified: trunk/test/python-tests/TestDataProviderTomboy.py
==============================================================================
--- trunk/test/python-tests/TestDataProviderTomboy.py	(original)
+++ trunk/test/python-tests/TestDataProviderTomboy.py	Thu Jan 17 23:09:29 2008
@@ -15,6 +15,10 @@
 test = SimpleTest(sinkName="TomboyNoteTwoWay")
 tomboy = test.get_sink().module
 
+#check if tomboy running
+if not Utils.dbus_service_available(tomboy.TOMBOY_DBUS_IFACE):
+    skip("tomboy not running")
+
 try:
     tomboy.refresh()
     ok("Refresh Tomboy", True)

Modified: trunk/test/python-tests/TestSyncTomboyFolder.py
==============================================================================
--- trunk/test/python-tests/TestSyncTomboyFolder.py	(original)
+++ trunk/test/python-tests/TestSyncTomboyFolder.py	Thu Jan 17 23:09:29 2008
@@ -12,6 +12,11 @@
 sinkW = test.get_dataprovider("FolderTwoWay")
 test.prepare(sourceW, sinkW)
 
+#check if tomboy running
+tomboy = sourceW.module
+if not Utils.dbus_service_available(tomboy.TOMBOY_DBUS_IFACE):
+    skip("tomboy not running")
+
 #configure the source and sink
 config = {}
 config["folder"] = "file://"+Utils.new_tempdir()

Modified: trunk/test/python-tests/TestSyncTomboyiPod.py
==============================================================================
--- trunk/test/python-tests/TestSyncTomboyiPod.py	(original)
+++ trunk/test/python-tests/TestSyncTomboyiPod.py	Thu Jan 17 23:09:29 2008
@@ -23,9 +23,14 @@
 klass = iPodModule.IPodNoteTwoWay(fakeIpodDir,"")
 
 #setup the conduit
-tomboy = test.get_dataprovider("TomboyNoteTwoWay")
-ipod = test.wrap_dataprovider(klass)
-test.prepare(tomboy, ipod)
+sourceW = test.get_dataprovider("TomboyNoteTwoWay")
+sinkW = test.wrap_dataprovider(klass)
+test.prepare(sourceW, sinkW)
+
+#check if tomboy running
+tomboy = sourceW.module
+if not Utils.dbus_service_available(tomboy.TOMBOY_DBUS_IFACE):
+    skip("tomboy not running")
 
 #check they refresh ok
 a,b = test.refresh()

Modified: trunk/test/python-tests/common.py
==============================================================================
--- trunk/test/python-tests/common.py	(original)
+++ trunk/test/python-tests/common.py	Thu Jan 17 23:09:29 2008
@@ -32,6 +32,18 @@
 conduit.SHARED_DATA_DIR =           os.path.join(base_path,"data")
 conduit.SHARED_MODULE_DIR =         os.path.join(base_path,"conduit","modules")
 
+def is_online():
+    try:    
+        return os.environ["CONDUIT_ONLINE"] == "TRUE"
+    except KeyError:
+        return False
+        
+def is_interactive():
+    try:    
+        return os.environ["CONDUIT_INTERACTIVE"] == "TRUE"
+    except KeyError:
+        return False
+
 def ok(message, code, die=True):
     if type(code) == int:
         if code == -1:
@@ -52,8 +64,13 @@
             print "[PASS] %s" % message
             return True
 
-def skip():
-    print "[SKIPPED]"
+def skip(msg="no reason given"):
+    if msg == "no reason given":
+        if not is_online():
+            msg = "not online"
+        elif not is_interactive():
+            msg = "interactive tests disabled"
+    print "[SKIPPED] (%s)" % msg
     sys.exit()
 
 def finished():
@@ -90,18 +107,6 @@
     path = os.path.join(os.path.dirname(__file__),"data",filename)
     return read_data_file(path)
 
-def is_online():
-    try:    
-        return os.environ["CONDUIT_ONLINE"] == "TRUE"
-    except KeyError:
-        return False
-        
-def is_interactive():
-    try:    
-        return os.environ["CONDUIT_INTERACTIVE"] == "TRUE"
-    except KeyError:
-        return False
-        
 def init_gnomevfs_authentication():
     import gnome.ui
     gnome.init(conduit.APPNAME, conduit.APPVERSION)



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