conduit r1219 - in trunk: . conduit conduit/modules/FacebookModule conduit/modules/GConfModule conduit/modules/NetworkModule scripts test/python-tests



Author: jstowers
Date: Tue Jan 15 00:09:40 2008
New Revision: 1219
URL: http://svn.gnome.org/viewvc/conduit?rev=1219&view=rev

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

	* conduit/MappingDB.py: Add debugging prints
	
	* conduit/Web.py:
	* conduit/modules/FacebookModule/FacebookModule.py: When using the system
	web browser (i.e. when under test) add a configurable sleep	delay
	and sleep before the fist try_login call (because if you dont, facebook
	invalidates your login credentials)
	
	* conduit/modules/GConfModule/GConfModule.py: Add ability to specify the
	gconf paths to watch. No gui for this yet

	* conduit/modules/NetworkModule/Peers.py:
	* conduit/modules/NetworkModule/Server.py: Error checking when starting
	the peer announcer to prevent hang on shutdown
	
	* scripts/continuous-tester.sh: Update before running tests
	
	* test/python-tests/TestCoreSyncLogic.py:
	* test/python-tests/TestDataProviderFacebook.py: Add photo upload test

	* test/python-tests/common.py: Explicitly set IS_DEVELOPMENT_VERSION



Added:
   trunk/test/python-tests/TestDataProviderFacebook.py
Modified:
   trunk/ChangeLog
   trunk/conduit/MappingDB.py
   trunk/conduit/Web.py
   trunk/conduit/modules/FacebookModule/FacebookModule.py
   trunk/conduit/modules/GConfModule/GConfModule.py
   trunk/conduit/modules/NetworkModule/Peers.py
   trunk/conduit/modules/NetworkModule/Server.py
   trunk/scripts/continuous-tester.sh
   trunk/test/python-tests/TestCoreSyncLogic.py
   trunk/test/python-tests/common.py

Modified: trunk/conduit/MappingDB.py
==============================================================================
--- trunk/conduit/MappingDB.py	(original)
+++ trunk/conduit/MappingDB.py	Tue Jan 15 00:09:40 2008
@@ -157,11 +157,13 @@
         Saves a mapping between the dataproviders
         """
         if mapping.oid == None:
+            #log.debug("New Mapping: %s" % mapping)
             self._db.insert(
                         table="mappings",
                         values=mapping.values()
                         )
         else:
+            #log.debug("Update Mapping: %s" % mapping)
             self._db.update(
                         table="mappings",
                         oid=mapping.oid,

Modified: trunk/conduit/Web.py
==============================================================================
--- trunk/conduit/Web.py	(original)
+++ trunk/conduit/Web.py	Tue Jan 15 00:09:40 2008
@@ -152,14 +152,12 @@
 
         start_time = time.time()
         while not self._is_timed_out(start_time):
+            time.sleep(kwargs.get("sleep_time",2))        
             try:
                 if self.testFunc():
                     return
             except Exception, e:
-                log.debug("testFunc threw an error: %s" % e)
-                pass
-
-            time.sleep(2)
+                log.debug("Login function threw an error: %s" % e)
 
         raise Exception("Login timed out")
 

Modified: trunk/conduit/modules/FacebookModule/FacebookModule.py
==============================================================================
--- trunk/conduit/modules/FacebookModule/FacebookModule.py	(original)
+++ trunk/conduit/modules/FacebookModule/FacebookModule.py	Tue Jan 15 00:09:40 2008
@@ -37,6 +37,7 @@
     def __init__(self, *args):
         Image.ImageSink.__init__(self)
         self.fapi = Facebook(FacebookSink.API_KEY, FacebookSink.SECRET)
+        self.browser = "gtkmozembed"
 
     def _upload_photo (self, uploadInfo):
         """
@@ -56,7 +57,10 @@
         url = self.fapi.get_login_url()
 
         #wait for log in
-        Web.LoginMagic("Log into Facebook", url, login_function=self._try_login, browser="gtkmozembed")
+        Web.LoginMagic("Log into Facebook", url, login_function=self._try_login, 
+                browser=self.browser,       #instance var so tests can set it to system
+                sleep_time=45,              #long sleep time to give time to login if using system browser
+                )
 
     def _try_login(self):
         """

Modified: trunk/conduit/modules/GConfModule/GConfModule.py
==============================================================================
--- trunk/conduit/modules/GConfModule/GConfModule.py	(original)
+++ trunk/conduit/modules/GConfModule/GConfModule.py	Tue Jan 15 00:09:40 2008
@@ -25,12 +25,8 @@
     _in_type_ = "setting"
     _out_type_ = "setting"
     _icon_ = "preferences-desktop"
-
-    def __init__(self, *args):
-        DataProvider.TwoWay.__init__(self)
-        AutoSync.AutoSync.__init__(self)
-
-        self.whitelist = [
+    
+    DEFAULT_WHITELIST = [
             '/apps/metacity/*',
             '/desktop/gnome/applications/*',
             '/desktop/gnome/background/*',
@@ -38,6 +34,12 @@
             '/desktop/gnome/url-handlers/*'
         ]
 
+    def __init__(self, *args):
+        DataProvider.TwoWay.__init__(self)
+        AutoSync.AutoSync.__init__(self)
+
+        self.whitelist = self.DEFAULT_WHITELIST
+
         self.gconf = gconf.client_get_default()
         self.gconf.add_dir('/', gconf.CLIENT_PRELOAD_NONE)
         self.gconf.notify_add('/', self.on_change)
@@ -126,6 +128,13 @@
                         )
         s.set_UID(uid)
         return s
+        
+    def get_configuration(self):
+        return {"whitelist" : self.whitelist}
+        
+    def set_configuration(self, config):
+        self.whitelist = config.get("whitelist",self.DEFAULT_WHITELIST)
+        log.debug("%s" % self.whitelist)
 
     def put(self, setting, overwrite, uid=None):
         log.debug("%s: %s" % (setting.key, setting.value))

Modified: trunk/conduit/modules/NetworkModule/Peers.py
==============================================================================
--- trunk/conduit/modules/NetworkModule/Peers.py	(original)
+++ trunk/conduit/modules/NetworkModule/Peers.py	Tue Jan 15 00:09:40 2008
@@ -215,8 +215,10 @@
         """
         DBus callback when a new service is detected
         """
-        #if flags & LOOKUP_RESULT_OUR_OWN:
-        #    return
+        #Dont show networked dataproviders on localhost unless we are
+        #a development release
+        if not conduit.IS_DEVELOPMENT_VERSION and flags & LOOKUP_RESULT_OUR_OWN:
+            return
 
         service = self.server.ResolveService(
                                         interface, 

Modified: trunk/conduit/modules/NetworkModule/Server.py
==============================================================================
--- trunk/conduit/modules/NetworkModule/Server.py	(original)
+++ trunk/conduit/modules/NetworkModule/Server.py	Tue Jan 15 00:09:40 2008
@@ -29,43 +29,53 @@
 
         self.shared = {}
         self.DP_PORT = 3401
+        
+        # Initiate Avahi stuff & announce our presence
+        try:
+            log.debug("Starting AvahiAdvertiser server")
+            self.advertiser = Peers.AvahiAdvertiser("_conduit.tcp", SERVER_PORT)
+            self.advertiser.announce()
+
+            #Start the server which anounces other shared servers
+            self.peerAnnouncer = XMLRPCUtils.StoppableXMLRPCServer('',SERVER_PORT)
+            self.peerAnnouncer.register_function(self.list_shared_dataproviders)
+            self.peerAnnouncer.start()
+            
+            #FIXME: Only show the endpoint if the server was started.
+            #self.emit_added(
+            #        klass=NetworkEndpoint,
+            #        initargs=(), 
+            #        category=conduit.dataproviders.CATEGORY_MISC
+            #        )
+        except Exception, e:
+            self.peerAnnouncer = None
+            log.warn("Error starting AvahiAdvertiser server: %s" % e)
 
         #watch the modulemanager for added conduits and syncsets
         if conduit.GLOBALS.moduleManager != None:
             conduit.GLOBALS.moduleManager.connect('syncset-added', self._syncset_added)
-            # Initiate Avahi stuff & announce our presence
-            try:
-                self.advertiser = Peers.AvahiAdvertiser("_conduit.tcp", SERVER_PORT)
-                self.advertiser.announce()
-    
-                # start the server which anounces other shared servers
-                self.peerAnnouncer = XMLRPCUtils.StoppableXMLRPCServer('',SERVER_PORT)
-                self.peerAnnouncer.register_function(self.list_shared_dataproviders)
-                self.peerAnnouncer.start()
-            except:
-                log.warn("Error starting server")
-            
         else:
-            log.warn("Could not start server, moduleManager not created yet")
+            log.warn("Could not start AvahiAdvertiser server, moduleManager not created yet")
 
     def _syncset_added(self, mgr, syncset):
         syncset.connect("conduit-added", self._conduit_added)
         syncset.connect("conduit-removed", self._conduit_removed)
 
-    def _conduit_added(self, syncset, conduit):
-        conduit.connect("dataprovider-added", self._dataprovider_added)
-        conduit.connect("dataprovider-removed", self._dataprovider_removed)
-
-    def _conduit_removed(self, syncset, conduit):
-        pass
+    def _conduit_added(self, syncset, cond):
+        cond.connect("dataprovider-added", self._dataprovider_added)
+        cond.connect("dataprovider-removed", self._dataprovider_removed)
+
+    def _conduit_removed(self, syncset, cond):
+        for dpw in cond.get_all_dataproviders():
+            self._dataprovider_removed(cond, dpw)
 
-    def _get_shared_dps(self, conduit):
+    def _get_shared_dps(self, cond):
         """
         This is a cludgy evil function to determine if a conduit is shared or not
           If it is, the dp to share is returned
           If it is not, None is returned
         """
-        dps = conduit.get_all_dataproviders()
+        dps = cond.get_all_dataproviders()
         ne = None
         tg = None
         if len(dps) == 2:
@@ -104,7 +114,9 @@
 
     def quit(self):
         #stop all the xmlrpc servers
-        self.peerAnnouncer.stop()
+        if self.peerAnnouncer != None:
+            self.peerAnnouncer.stop()
+    
         for server in self.shared.values():
             server.stop()           
 
@@ -133,10 +145,10 @@
     another dataprovider to this one, symbolising a network sync
     """
     _name_ = _("Network")
-    _description_ = _("Network your desktop")
+    _description_ = _("Enable synchronization via network")
     _category_ = conduit.dataproviders.CATEGORY_MISC
     _module_type_ = "twoway"
-    _icon_ = "gnome-nettool"
+    _icon_ = "network-idle"
 
     def __init__(self):
         DataProvider.TwoWay.__init__(self)

Modified: trunk/scripts/continuous-tester.sh
==============================================================================
--- trunk/scripts/continuous-tester.sh	(original)
+++ trunk/scripts/continuous-tester.sh	Tue Jan 15 00:09:40 2008
@@ -56,10 +56,10 @@
     RVERSION=`svn info http://svn.gnome.org/svn/conduit/trunk | sed -n 's/^Revision: \([0-9][0-9]*\).*/\1/p'`
 
     if [ "$LVERSION" != "$RVERSION" -o "$FORCE" = "yes" ]; then
-        echo "`date` Running Test (Revision $LVERSION)" | tee -a $LOGFILE
         #Run tests (dbus-launch sets a private session bus incase we are
         #being run from a VT
         svn up . 
+        echo "`date` Running Test (Revision $RVERSION)" | tee -a $LOGFILE
         dbus-launch $TEST_DIR/scripts/run-tests.sh -$TEST_OPTIONS 
         
         #Build packages

Modified: trunk/test/python-tests/TestCoreSyncLogic.py
==============================================================================
--- trunk/test/python-tests/TestCoreSyncLogic.py	(original)
+++ trunk/test/python-tests/TestCoreSyncLogic.py	Tue Jan 15 00:09:40 2008
@@ -7,7 +7,7 @@
 
 import datetime
 
-class TestDataType(conduit.datatypes.DataType.DataType):
+class TestDataType(DataType.DataType):
     _name_ = "test"
     def __init__(self, data, **kwargs):
         """

Added: trunk/test/python-tests/TestDataProviderFacebook.py
==============================================================================
--- (empty file)
+++ trunk/test/python-tests/TestDataProviderFacebook.py	Tue Jan 15 00:09:40 2008
@@ -0,0 +1,29 @@
+#common sets up the conduit environment
+from common import *
+
+if not is_online() or not is_interactive():
+    skip()
+
+#setup the test
+test = SimpleTest(sinkName="FacebookSink")
+#Hack Facebook to use the system browser (it really needs to use the gtkmozembed one)
+facebook = test.get_dataprovider("FacebookSink").module
+facebook.browser = "system"
+
+#Log in
+try:
+    facebook.refresh()
+    ok("Logged in", True)
+except Exception, err:
+    ok("Logged in (%s)" % err, False)  
+
+#Send a remote file
+f = File.File("http://files.conduit-project.org/screenshot.png";)
+try:
+    uid = facebook.put(f, True)
+    ok("Upload a photo (UID:%s) " % uid, True)
+except Exception, err:
+    ok("Upload a photo (%s)" % err, False)
+
+finished()
+

Modified: trunk/test/python-tests/common.py
==============================================================================
--- trunk/test/python-tests/common.py	(original)
+++ trunk/test/python-tests/common.py	Tue Jan 15 00:09:40 2008
@@ -25,9 +25,10 @@
 from conduit.modules import TestModule
 
 # set up expected paths & variables 
-conduit.IS_INSTALLED =          False
-conduit.SHARED_DATA_DIR =       os.path.join(base_path,"data")
-conduit.SHARED_MODULE_DIR =     os.path.join(base_path,"conduit","modules")
+conduit.IS_INSTALLED =              False
+conduit.IS_DEVELOPMENT_VERSION =    True
+conduit.SHARED_DATA_DIR =           os.path.join(base_path,"data")
+conduit.SHARED_MODULE_DIR =         os.path.join(base_path,"conduit","modules")
 
 def ok(message, code, die=True):
     if type(code) == int:



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