conduit r1472 - in trunk: . conduit conduit/hildonui conduit/modules/GoogleModule scripts test/python-tests



Author: jstowers
Date: Sat May 24 12:51:46 2008
New Revision: 1472
URL: http://svn.gnome.org/viewvc/conduit?rev=1472&view=rev

Log:
2008-05-25  John Stowers  <john stowers gmail com>

	* conduit/Main.py:
	* conduit/Settings.py:
	* conduit/hildonui/Canvas.py:
	* test/python-tests/common.py: Add the ability to override conduit
	settings for the session. Use this where appropriate.
	
	* conduit/modules/GoogleModule/GoogleModule.py: Make some classes private



Modified:
   trunk/ChangeLog
   trunk/conduit/Main.py
   trunk/conduit/Settings.py
   trunk/conduit/hildonui/Canvas.py
   trunk/conduit/modules/GoogleModule/GoogleModule.py
   trunk/scripts/ChangeLog
   trunk/scripts/run-tests.sh
   trunk/test/python-tests/common.py

Modified: trunk/conduit/Main.py
==============================================================================
--- trunk/conduit/Main.py	(original)
+++ trunk/conduit/Main.py	Sat May 24 12:51:46 2008
@@ -49,8 +49,12 @@
         blacklist = None
         self.ui = "gtk"
         try:
-            opts, args = getopt.getopt(sys.argv[1:], "hvs:ciu:w:x:", 
-                ["help", "version", "settings=", "console", "iconify", "ui=", "with-modules=", "without-modules="])
+            opts, args = getopt.getopt(
+                            sys.argv[1:],
+                            "hvf:ciu:w:x:s:",
+                                ("help", "version", "config-file=",
+                                 "console", "iconify", "ui=", "with-modules=",
+                                 "without-modules=", "settings="))
             #parse args
             for o, a in opts:
                 if o in ("-h", "--help"):
@@ -59,7 +63,7 @@
                 if o in ("-v", "--version"):
                     print "Conduit %s" % conduit.VERSION
                     sys.exit(0)
-                if o in ("-s", "--settings"):
+                if o in ("-f", "--config-file"):
                      self.settingsFile = os.path.join(os.getcwd(), a)
                 if o in ("-c", "--console"):
                    buildGUI = False
@@ -71,6 +75,14 @@
                     whitelist = a.split(",")
                 if o in ("-x", "--without-modules"):
                     blacklist = a.split(",")
+                if o in ("-s", "--settings"):
+                    settings = {}
+                    try:
+                        for i in a.split(','):
+                            k,v = i.split('=')
+                            settings[k] = v
+                    except: pass
+                    conduit.GLOBALS.settings.set_overrides(**settings)
 
         except getopt.GetoptError:
             log.warn("Unknown command line option")
@@ -168,20 +180,22 @@
     def _usage(self):
         print """Usage: conduit [OPTIONS] - Synchronize things
 OPTIONS:
-    -h, --help              Show this message.
-    -c, --console           Launch with no GUI.
-                            (default=no)
-    -s, --settings=FILE     Save settings to FILE.
-                            (default=$XDG_CONFIG_DIR/.conduit/settings.xml)
-    -i, --iconify           Iconify on startup.
-                            (default=no)
-    -u, --ui=NAME           Run with the specified UI
-                            (default=gtk)
-    -w, --with-modules      Only load modules in the named files
-                            (default=load all modules)
-    -x, --without-modules   Do not load modules in the named files
-                            (default=load all modules)
-    -v, --version           Show version information"""
+    -h, --help                  Show this message.
+    -c, --console               Launch with no GUI.
+                                (default=no)
+    -f, --config-file=FILE      Save dataprovider configuration to FILE.
+                                (default=$XDG_CONFIG_DIR/.conduit/settings.xml)
+    -i, --iconify               Iconify on startup.
+                                (default=no)
+    -u, --ui=NAME               Run with the specified UI.
+                                (default=gtk)
+    -w, --with-modules          Only load modules in the named files.
+                                (default=load all modules)
+    -x, --without-modules       Do not load modules in the named files.
+                                (default=load all modules)
+    -s, --settings=key=val,..   Explicitly set internal Conduit settings (keys)
+                                to the given values for this session.
+    -v, --version               Show version information."""
 
     @dbus.service.method(APPLICATION_DBUS_IFACE, in_signature='', out_signature='b')
     def HasGUI(self):

Modified: trunk/conduit/Settings.py
==============================================================================
--- trunk/conduit/Settings.py	(original)
+++ trunk/conduit/Settings.py	Sat May 24 12:51:46 2008
@@ -103,9 +103,12 @@
         """
         gobject.GObject.__init__(self)
         self.client = gconf.client_get_default()
-        # Preload gconf directories
+        #Preload gconf directories
         self.client.add_dir(self.CONDUIT_GCONF_DIR[:-1], gconf.CLIENT_PRELOAD_RECURSIVE)  
         self.notifications = []
+        #also keep an internal dict of settings which have been overridden
+        #for this session
+        self.overrides = {}
 
     def _fix_key(self, key):
         """
@@ -128,12 +131,23 @@
         key = self._fix_key(entry.key)
         detailed_signal = 'changed::%s' % key
         self.emit(detailed_signal)
+        
+    def set_overrides(self, **overrides):
+        self.overrides = overrides
 
     def get(self, key, vtype=None, default=None):
         """
         Returns the value of the key or the default value if the key is 
         not yet in gconf
         """
+        #check if the setting has been overridden for this session
+        if key in self.overrides:
+            try:
+                #try and cast to correct type
+                return type(self.DEFAULTS[key])(self.overrides[key])
+            except:
+                return self.overrides[key]
+
         if key in self.DEFAULTS:
             #function arguments override defaults
             if default is None:
@@ -173,6 +187,11 @@
         Sets the key value in gconf and connects adds a signal 
         which is fired if the key changes
         """
+        #overidden settings only apply for this session, and are
+        #not set
+        if key in self.overrides:
+            return True
+
         log.debug("Settings %s -> %s" % (key, value))
         if key in self.DEFAULTS and not vtype:
             vtype = type(self.DEFAULTS[key])

Modified: trunk/conduit/hildonui/Canvas.py
==============================================================================
--- trunk/conduit/hildonui/Canvas.py	(original)
+++ trunk/conduit/hildonui/Canvas.py	Sat May 24 12:51:46 2008
@@ -43,8 +43,14 @@
         """
         #setup the canvas
         goocanvas.Canvas.__init__(self)
-        self.set_bounds(0, 0, self.CANVAS_WIDTH, self.CANVAS_HEIGHT)
-        self.set_size_request(self.CANVAS_WIDTH, self.CANVAS_HEIGHT)
+        self.set_bounds(0, 0, 
+                conduit.GLOBALS.settings.get("gui_initial_canvas_width"),
+                conduit.GLOBALS.settings.get("gui_initial_canvas_height")
+                )
+        self.set_size_request(
+                conduit.GLOBALS.settings.get("gui_initial_canvas_width"),
+                conduit.GLOBALS.settings.get("gui_initial_canvas_height")
+                )
         self.root = self.get_root_item()
 
         self.sync_manager = syncManager

Modified: trunk/conduit/modules/GoogleModule/GoogleModule.py
==============================================================================
--- trunk/conduit/modules/GoogleModule/GoogleModule.py	(original)
+++ trunk/conduit/modules/GoogleModule/GoogleModule.py	Sat May 24 12:51:46 2008
@@ -109,7 +109,7 @@
     def get_UID(self):
         return self.username
 
-class GoogleCalendar:
+class _GoogleCalendar:
     def __init__(self, name, uri):
         self.uri = uri
         self.name = name
@@ -199,7 +199,7 @@
     if 'vtimezone' in vobjICal.contents:
         args['vtimezone'] = vobjICal.vtimezone
 
-class GoogleEvent:
+class _GoogleEvent:
     def __init__(self, **kwargs):
         self.uid = kwargs.get('uid', None)
         self.mTime = kwargs.get('mTime', None)
@@ -383,13 +383,13 @@
         calQuery = gdata.calendar.service.CalendarEventQuery(user = self.selectedCalendar.get_uri())
         eventFeed = self.service.CalendarQuery(calQuery)
         for event in eventFeed.entry:   
-            yield GoogleEvent.from_google_format(event)
+            yield _GoogleEvent.from_google_format(event)
 
     def _get_all_calendars(self):
         self._login()
         allCalendarsFeed = self.service.GetCalendarListFeed().entry
         for calendarFeed in allCalendarsFeed:
-            yield GoogleCalendar.from_google_format(calendarFeed)
+            yield _GoogleCalendar.from_google_format(calendarFeed)
 
     def _load_calendars(self, widget, tree):
         import gtk, gtk.gdk
@@ -481,11 +481,11 @@
         return conduitEvent          
                    
     def _create_event(self, conduitEvent):
-        googleEvent = GoogleEvent.from_ical_format( conduitEvent.get_ical_string() )
+        googleEvent = _GoogleEvent.from_ical_format( conduitEvent.get_ical_string() )
         newEvent = self.service.InsertEvent(
                                         googleEvent.get_google_format(),
                                         self.selectedCalendar.get_feed_link())
-        newEvent = GoogleEvent.from_google_format(newEvent)
+        newEvent = _GoogleEvent.from_google_format(newEvent)
         return Rid(uid=newEvent.get_uid(), mtime=None, hash=None)
         
     def _delete_event(self, LUID):
@@ -536,7 +536,7 @@
         _GoogleBase.set_configuration(self, config)
         if "selectedCalendarName" in config:
             if "selectedCalendarURI" in config:
-                self.selectedCalendar = GoogleCalendar(
+                self.selectedCalendar = _GoogleCalendar(
                                             config['selectedCalendarName'],
                                             config['selectedCalendarURI']
                                             )

Modified: trunk/scripts/run-tests.sh
==============================================================================
--- trunk/scripts/run-tests.sh	(original)
+++ trunk/scripts/run-tests.sh	Sat May 24 12:51:46 2008
@@ -82,11 +82,6 @@
 touch -t 198308160002 $TEST_DATA_DIR/newer
 touch -t 198308160003 $TEST_DATA_DIR/newest
 
-#Disable save on exit (the test sets are read only)
-gconftool-2 --type bool --set /apps/conduit/save_on_exit false
-#Without a gobject main loop the gtkmozembed browser hangs
-gconftool-2 --type string --set /apps/conduit/web_login_browser system
-
 #Work out which tests to run
 if [ -n "$do_single_test" ] ; then
     tests="$PY_TEST_DIR/$do_single_test"

Modified: trunk/test/python-tests/common.py
==============================================================================
--- trunk/test/python-tests/common.py	(original)
+++ trunk/test/python-tests/common.py	Sat May 24 12:51:46 2008
@@ -35,6 +35,10 @@
 conduit.SHARED_DATA_DIR =           os.path.join(base_path,"data")
 conduit.SHARED_MODULE_DIR =         os.path.join(base_path,"conduit","modules")
 
+# override some conduit settings. 
+# without a gobject main loop the gtkmozembed browser hangs
+conduit.GLOBALS.settings.set_overrides(web_login_browser="system")
+
 def is_online():
     try:    
         return os.environ["CONDUIT_ONLINE"] == "TRUE"



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