[conduit/gsoc09_alexandre: 16/24] Added GConf backend for SyncSet saving/restoring.
- From: Alexandre Rosenfeld <arosenfeld src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [conduit/gsoc09_alexandre: 16/24] Added GConf backend for SyncSet saving/restoring.
- Date: Thu, 13 Aug 2009 04:11:58 +0000 (UTC)
commit 3fb3abc63f64390c72e9fc4a677b2476895619bb
Author: Alexandre Rosenfeld <airmind gmail com>
Date: Thu Jul 30 17:28:04 2009 -0300
Added GConf backend for SyncSet saving/restoring.
conduit/Main.py | 68 ++++++++--------
conduit/Module.py | 1 +
conduit/ModuleWrapper.py | 2 +-
conduit/SyncSet.py | 163 +++++---------------------------------
conduit/SyncSetGConf.py | 132 ++++++++++++++++++++++++++++++
conduit/SyncSetXML.py | 150 +++++++++++++++++++++++++++++++++++
conduit/conduit.real | 4 +-
conduit/gtkui/ConfigContainer.py | 4 +-
conduit/gtkui/Tree.py | 2 +-
conduit/gtkui/UI.py | 2 +-
10 files changed, 343 insertions(+), 185 deletions(-)
---
diff --git a/conduit/Main.py b/conduit/Main.py
index a87a224..89b78b9 100644
--- a/conduit/Main.py
+++ b/conduit/Main.py
@@ -183,11 +183,13 @@ class Application(dbus.service.Object):
#Build both syncsets and put on the bus as early as possible
self.guiSyncSet = SyncSet(
+ 'gui',
moduleManager=conduit.GLOBALS.moduleManager,
syncManager=conduit.GLOBALS.syncManager,
xmlSettingFilePath=self.settingsFile
)
self.dbusSyncSet = SyncSet(
+ 'dbus',
moduleManager=conduit.GLOBALS.moduleManager,
syncManager=conduit.GLOBALS.syncManager
)
@@ -233,7 +235,7 @@ class Application(dbus.service.Object):
)
#reload the saved sync set
- self.guiSyncSet.restore_from_xml()
+ self.guiSyncSet.restore()
self.gui.set_model(self.guiSyncSet)
if self.statusIcon:
@@ -272,40 +274,36 @@ class Application(dbus.service.Object):
@dbus.service.method(APPLICATION_DBUS_IFACE, in_signature='', out_signature='')
def Quit(self):
- try:
- #Hide the GUI first, so we feel responsive
- log.info("Closing application")
- if self.gui != None:
- self.gui.mainWindow.hide()
- if conduit.GLOBALS.settings.get("save_on_exit") == True:
- self.gui.save_settings(None)
-
- #Cancel all syncs
- self.Cancel()
-
- #give the dataprovider factories time to shut down
- log.info("Closing dataprovider factories")
- conduit.GLOBALS.moduleManager.quit()
-
- #unitialize all dataproviders
- log.info("Unitializing dataproviders")
- self.guiSyncSet.quit()
- log.info("GUI Quit")
- self.dbusSyncSet.quit()
- log.info("DBus Quit")
-
- #Save the mapping DB
- conduit.GLOBALS.mappingDB.save()
- conduit.GLOBALS.mappingDB.close()
-
- #Save the application settings
- conduit.GLOBALS.settings.save()
-
- log.info("Main Loop Quitting")
- conduit.GLOBALS.mainloop.quit()
- except:
- log.error("Error quiting, forcing close. %s" % traceback.format_exc())
- sys.exit(-1)
+ #Hide the GUI first, so we feel responsive
+ log.info("Closing application")
+ if self.gui != None:
+ self.gui.mainWindow.hide()
+ if conduit.GLOBALS.settings.get("save_on_exit") == True:
+ self.gui.save_settings(None)
+
+ #Cancel all syncs
+ self.Cancel()
+
+ #give the dataprovider factories time to shut down
+ log.info("Closing dataprovider factories")
+ conduit.GLOBALS.moduleManager.quit()
+
+ #unitialize all dataproviders
+ log.info("Unitializing dataproviders")
+ self.guiSyncSet.quit()
+ log.info("GUI Quit")
+ self.dbusSyncSet.quit()
+ log.info("DBus Quit")
+
+ #Save the mapping DB
+ conduit.GLOBALS.mappingDB.save()
+ conduit.GLOBALS.mappingDB.close()
+
+ #Save the application settings
+ conduit.GLOBALS.settings.save()
+
+ log.info("Main Loop Quitting")
+ conduit.GLOBALS.mainloop.quit()
@dbus.service.method(APPLICATION_DBUS_IFACE, in_signature='', out_signature='')
def Synchronize(self):
diff --git a/conduit/Module.py b/conduit/Module.py
index 9299087..7275a50 100644
--- a/conduit/Module.py
+++ b/conduit/Module.py
@@ -286,6 +286,7 @@ class ModuleManager(gobject.GObject):
else:
self._load_modules_in_file(f, f_data)
+ # Save the modules cache if it's different then the file contents
if self.modules_cache != self.filelist:
log.critical("Saving cache")
self.modules_cache = self.filelist
diff --git a/conduit/ModuleWrapper.py b/conduit/ModuleWrapper.py
index 0fe696a..f346693 100644
--- a/conduit/ModuleWrapper.py
+++ b/conduit/ModuleWrapper.py
@@ -93,7 +93,7 @@ class ModuleWrapper:
'out_type': self.out_type,
'configurable': self.configurable,
'classname': self.classname,
- 'category': self.category}
+ 'category': self.category.name}
def __str__(self):
return "Wrapper: %s %s (UID: %s)" % (self.get_name(), self.module_type, self.get_UID())
diff --git a/conduit/SyncSet.py b/conduit/SyncSet.py
index aa2d290..4878bfb 100644
--- a/conduit/SyncSet.py
+++ b/conduit/SyncSet.py
@@ -15,9 +15,6 @@ import conduit
import conduit.Conduit as Conduit
import conduit.Settings as Settings
-#Increment this number when the xml settings file
-#changes format
-SETTINGS_VERSION = "2"
class SyncSet(gobject.GObject):
"""
@@ -32,9 +29,10 @@ class SyncSet(gobject.GObject):
gobject.TYPE_PYOBJECT]), # The ConduitModel that was removed
}
- def __init__(self, moduleManager, syncManager, xmlSettingFilePath="settings.xml"):
+ def __init__(self, name, moduleManager, syncManager, xmlSettingFilePath="settings.xml"):
gobject.GObject.__init__(self)
+ self.name = name
self.moduleManager = moduleManager
self.syncManager = syncManager
self.xmlSettingFilePath = xmlSettingFilePath
@@ -55,7 +53,7 @@ class SyncSet(gobject.GObject):
except Exception:
log.warn("Could not uninitialize %s" % dp, exc_info=True)
- def _restore_dataprovider(self, cond, wrapperKey, dpName="", dpxml="", xml_version=SETTINGS_VERSION, trySourceFirst=True):
+ def _restore_dataprovider(self, cond, wrapperKey, dpName="", dpxml="", xml_version="2", trySourceFirst=True):
"""
Adds the dataprovider back onto the canvas at the specifed
location and configures it with the given settings
@@ -65,7 +63,9 @@ class SyncSet(gobject.GObject):
if dpName:
wrapper.set_name(dpName)
if wrapper is not None:
- if dpxml:
+ if dpxml and isinstance(dpxml, basestring):
+ wrapper.set_configuration_xml(xmltext=dpxml, xmlversion=xml_version)
+ elif dpxml:
for i in dpxml.childNodes:
if i.nodeType == i.ELEMENT_NODE and i.localName == "configuration":
wrapper.set_configuration_xml(xmltext=i.toxml(), xmlversion=xml_version)
@@ -126,147 +126,24 @@ class SyncSet(gobject.GObject):
def clear(self):
for c in self.conduits[:]:
self.remove_conduit(c)
-
- def save_to_xml(self, xmlSettingFilePath=None):
- """
- Saves the synchronisation settings (icluding all dataproviders and how
- they are connected) to an xml file so that the 'sync set' can
- be restored later
- """
- if xmlSettingFilePath == None:
- xmlSettingFilePath = self.xmlSettingFilePath
- log.info("Saving Sync Set to %s" % self.xmlSettingFilePath)
-
- #Build the application settings xml document
- doc = xml.dom.minidom.Document()
- rootxml = doc.createElement("conduit-application")
- rootxml.setAttribute("application-version", conduit.VERSION)
- rootxml.setAttribute("settings-version", SETTINGS_VERSION)
- doc.appendChild(rootxml)
-
- #Store the conduits
- for cond in self.conduits:
- conduitxml = doc.createElement("conduit")
- conduitxml.setAttribute("uid",cond.uid)
- conduitxml.setAttribute("twoway",str(cond.is_two_way()))
- conduitxml.setAttribute("autosync",str(cond.do_auto_sync()))
- for policyName in Conduit.CONFLICT_POLICY_NAMES:
- conduitxml.setAttribute(
- "%s_policy" % policyName,
- cond.get_policy(policyName)
- )
- rootxml.appendChild(conduitxml)
-
- #Store the source
- source = cond.datasource
- if source is not None:
- sourcexml = doc.createElement("datasource")
- sourcexml.setAttribute("key", source.get_key())
- sourcexml.setAttribute("name", source.get_name())
- conduitxml.appendChild(sourcexml)
- #Store source settings
- configxml = xml.dom.minidom.parseString(source.get_configuration_xml())
- sourcexml.appendChild(configxml.documentElement)
- #Store all sinks
- sinksxml = doc.createElement("datasinks")
- for sink in cond.datasinks:
- sinkxml = doc.createElement("datasink")
- sinkxml.setAttribute("key", sink.get_key())
- sinkxml.setAttribute("name", sink.get_name())
- sinksxml.appendChild(sinkxml)
- #Store sink settings
- configxml = xml.dom.minidom.parseString(sink.get_configuration_xml())
- sinkxml.appendChild(configxml.documentElement)
- conduitxml.appendChild(sinksxml)
-
- #Save to disk
- try:
- file_object = open(xmlSettingFilePath, "w")
- file_object.write(doc.toxml())
- #file_object.write(doc.toprettyxml())
- file_object.close()
- except IOError, err:
- log.warn("Could not save settings to %s (Error: %s)" % (xmlSettingFilePath, err.strerror))
-
- def restore_from_xml(self, xmlSettingFilePath=None):
- """
- Restores sync settings from the xml file
- """
+ def restore(self, xmlSettingFilePath=None):
+ from SyncSetXML import SyncSetXML
if xmlSettingFilePath == None:
xmlSettingFilePath = self.xmlSettingFilePath
log.info("Restoring Sync Set from %s" % xmlSettingFilePath)
-
- #Check the file exists
- if not os.path.isfile(xmlSettingFilePath):
- log.info("%s not present" % xmlSettingFilePath)
- return
-
- try:
- #Open
- doc = xml.dom.minidom.parse(xmlSettingFilePath)
-
- #check the xml file is in a version we can read.
- if doc.documentElement.hasAttribute("settings-version"):
- xml_version = doc.documentElement.getAttribute("settings-version")
- try:
- xml_version = int(xml_version)
- except ValueError, TypeError:
- log.error("%s xml file version is not valid" % xmlSettingFilePath)
- os.remove(xmlSettingFilePath)
- return
- if int(SETTINGS_VERSION) < xml_version:
- log.warning("%s xml file is incorrect version" % xmlSettingFilePath)
- os.remove(xmlSettingFilePath)
- return
- else:
- log.info("%s xml file version not found, assuming version 1" % xmlSettingFilePath)
- xml_version = 1
-
- #Parse...
- for conds in doc.getElementsByTagName("conduit"):
- #create a new conduit
- cond = Conduit.Conduit(self.syncManager, conds.getAttribute("uid"))
- self.add_conduit(cond)
-
- #restore conduit specific settings
- twoway = Settings.string_to_bool(conds.getAttribute("twoway"))
- if twoway == True:
- cond.enable_two_way_sync()
- auto = Settings.string_to_bool(conds.getAttribute("autosync"))
- if auto == True:
- cond.enable_auto_sync()
- for policyName in Conduit.CONFLICT_POLICY_NAMES:
- cond.set_policy(
- policyName,
- conds.getAttribute("%s_policy" % policyName)
- )
-
- #each dataprovider
- for i in conds.childNodes:
- #keep a ref to the dataproider was added to so that we
- #can apply settings to it at the end
- #one datasource
- if i.nodeType == i.ELEMENT_NODE and i.localName == "datasource":
- key = i.getAttribute("key")
- name = i.getAttribute("name")
- #add to canvas
- if len(key) > 0:
- self._restore_dataprovider(cond, key, name, i, xml_version, True)
- #many datasinks
- elif i.nodeType == i.ELEMENT_NODE and i.localName == "datasinks":
- #each datasink
- for sink in i.childNodes:
- if sink.nodeType == sink.ELEMENT_NODE and sink.localName == "datasink":
- key = sink.getAttribute("key")
- name = sink.getAttribute("name")
- #add to canvas
- if len(key) > 0:
- self._restore_dataprovider(cond, key, name, sink, xml_version, False)
-
- except Exception:
- log.warn("Error parsing %s. Exception:\n%s" % (xmlSettingFilePath, traceback.format_exc()))
- os.remove(xmlSettingFilePath)
+ #SyncSetXML().restore_from_xml(self, xmlSettingFilePath)
+ from SyncSetGConf import SyncSetGConf
+ SyncSetGConf().restore(self)
+
+ def save(self, xmlSettingFilePath=None):
+ if xmlSettingFilePath == None:
+ xmlSettingFilePath = self.xmlSettingFilePath
+ log.info("Saving Sync Set to %s" % self.xmlSettingFilePath)
+ #from SyncSetXML import SyncSetXML
+ #SyncSetXML().save_to_xml(self, xmlSettingFilePath)
+ from SyncSetGConf import SyncSetGConf
+ SyncSetGConf().save(self)
def quit(self):
"""
diff --git a/conduit/SyncSetGConf.py b/conduit/SyncSetGConf.py
new file mode 100644
index 0000000..108d5cb
--- /dev/null
+++ b/conduit/SyncSetGConf.py
@@ -0,0 +1,132 @@
+
+import xml.dom.minidom
+import os
+import logging
+log = logging.getLogger("SyncSetGConf")
+import traceback
+import gconf
+client = gconf.client_get_default()
+
+
+import conduit
+import conduit.Conduit as Conduit
+import conduit.Settings as Settings
+
+SYNCSET_PATH = "/apps/conduit/SyncSet"
+
+class Error(Exception):
+ pass
+
+class SyncSetGConf(object):
+ def get_value(self, value):
+ #value = client.get(path)
+ if value.type == gconf.VALUE_PAIR:
+ log.critical(value.to_string)
+ return {gconf.VALUE_BOOL: value.get_bool,
+ gconf.VALUE_FLOAT: value.get_float,
+ gconf.VALUE_INT: value.get_int,
+ gconf.VALUE_LIST: value.get_list,
+ gconf.VALUE_PAIR: value.to_string,
+ gconf.VALUE_STRING: value.get_string
+ }[value.type]()
+
+ def set_value(self, path, value):
+ vtype = type(value)
+ if vtype is bool:
+ client.set_bool(path, value)
+ elif vtype is str:
+ client.set_string(path, value)
+ elif vtype is int:
+ client.set_int(path, value)
+ elif vtype in (list, tuple):
+ #FIXME We should support more then string lists
+ client.set_list(path, gconf.VALUE_STRING, [str(i) for i in value])
+
+ def restore(self, syncset):
+ for path in client.all_dirs(SYNCSET_PATH + "/" + syncset.name):
+ cond_name = path.split("/")[-1]
+ cond_path = path + "/"
+ try:
+ #create a new conduit
+ cond = Conduit.Conduit(syncset.syncManager, client.get_string(cond_path + "uid"))
+
+ #restore conduit specific settings
+ twoway = client.get_bool(cond_path + "twoway")
+ if twoway == True:
+ cond.enable_two_way_sync()
+ #auto = Settings.string_to_bool(conds.getAttribute("autosync"))
+ autosync = client.get_bool(cond_path + "autosync")
+ if autosync == True:
+ cond.enable_auto_sync()
+ for policyName in Conduit.CONFLICT_POLICY_NAMES:
+ policy = client.get_string(cond_path + "%s_policy" % policyName)
+ if policy:
+ cond.set_policy(policyName, policy)
+
+ num_sinks = client.get_int(cond_path + "sinks")
+
+ if client.dir_exists(cond_path + "source"):
+ source_path = cond_path + "source/"
+ source_key = client.get_string(source_path + "key")
+ source_name = client.get_string(source_path + "name")
+ source_config = client.get_string(source_path + "configxml")
+ #FIXME Use config values instead of XML
+ config = {}
+ for entry in client.all_entries(source_path + "config"):
+ config[entry.key] = self.get_value(entry.value)
+ #print config
+ syncset._restore_dataprovider(cond, source_key, source_name, source_config, "2")
+
+ for i in range(num_sinks):
+ sink_path = cond_path + "sink%d/" % i
+ if not client.dir_exists(cond_path + "sink%d" % i):
+ raise Error("Sink not found")
+ sink_key = client.get_string(sink_path + "key")
+ sink_name = client.get_string(sink_path + "name")
+ sink_config = client.get_string(sink_path + "configxml")
+ syncset._restore_dataprovider(cond, sink_key, sink_name, sink_config, "2")
+
+ syncset.add_conduit(cond)
+ except Exception:
+ #log.warning("Unable to restore conduit %s from %s. %s" % (cond_name, syncset.name, traceback.format_exc()))
+ raise
+
+ def save(self, syncset):
+ syncset_path = SYNCSET_PATH + "/" + syncset.name + "/"
+
+ client.recursive_unset(SYNCSET_PATH + "/" + syncset.name, 0)
+
+ #Store the conduits
+ for cond in syncset.conduits:
+ conduit_path = syncset_path + cond.uid + "/"
+ client.set_string(conduit_path + "uid", cond.uid)
+ client.set_bool(conduit_path + "twoway", cond.is_two_way())
+ client.set_bool(conduit_path + "autosync", cond.do_auto_sync())
+ for policyName in Conduit.CONFLICT_POLICY_NAMES:
+ client.set_string(conduit_path + ("%s_policy" % policyName),
+ cond.get_policy(policyName)
+ )
+
+ #Store the source
+ source = cond.datasource
+ if source is not None:
+ source_path = conduit_path + "source/"
+ client.set_string(source_path + "key", source.get_key())
+ client.set_string(source_path + "name", source.get_name())
+ #Store source settings
+ #configxml = xml.dom.minidom.parseString(source.get_configuration_xml())
+ client.set_string(source_path + "configxml", source.get_configuration_xml())
+ for key, value in source.module.get_configuration().iteritems():
+ self.set_value(source_path + "config/" + key, value)
+
+ #Store all sinks
+ #sinksxml = doc.createElement("datasinks")
+ for i, sink in enumerate(cond.datasinks):
+ sink_path = conduit_path + "sink%s/" % i
+ client.set_string(sink_path + "key", sink.get_key())
+ client.set_string(sink_path + "name", sink.get_name())
+ #configxml = xml.dom.minidom.parseString(sink.get_configuration_xml())
+ client.set_string(sink_path + "configxml", sink.get_configuration_xml())
+ for key, value in sink.module.get_configuration().iteritems():
+ self.set_value(sink_path + "config/" + key, value)
+ client.set_int(conduit_path + "sinks", len(cond.datasinks))
diff --git a/conduit/SyncSetXML.py b/conduit/SyncSetXML.py
new file mode 100644
index 0000000..a7afdc4
--- /dev/null
+++ b/conduit/SyncSetXML.py
@@ -0,0 +1,150 @@
+import xml.dom.minidom
+import os
+import logging
+log = logging.getLogger("SyncSetXML")
+import traceback
+
+import conduit
+import conduit.Conduit as Conduit
+import conduit.Settings as Settings
+
+#Increment this number when the xml settings file
+#changes format
+SETTINGS_VERSION = "2"
+
+class SyncSetXML(object):
+ def save_to_xml(self, syncset, xmlSettingFilePath=None):
+ """
+ Saves the synchronisation settings (icluding all dataproviders and how
+ they are connected) to an xml file so that the 'sync set' can
+ be restored later
+ """
+
+ #Build the application settings xml document
+ doc = xml.dom.minidom.Document()
+ rootxml = doc.createElement("conduit-application")
+ rootxml.setAttribute("application-version", conduit.VERSION)
+ rootxml.setAttribute("settings-version", SETTINGS_VERSION)
+ doc.appendChild(rootxml)
+
+ #Store the conduits
+ for cond in syncset.conduits:
+ conduitxml = doc.createElement("conduit")
+ conduitxml.setAttribute("uid",cond.uid)
+ conduitxml.setAttribute("twoway",str(cond.is_two_way()))
+ conduitxml.setAttribute("autosync",str(cond.do_auto_sync()))
+ for policyName in Conduit.CONFLICT_POLICY_NAMES:
+ conduitxml.setAttribute(
+ "%s_policy" % policyName,
+ cond.get_policy(policyName)
+ )
+ rootxml.appendChild(conduitxml)
+
+ #Store the source
+ source = cond.datasource
+ if source is not None:
+ sourcexml = doc.createElement("datasource")
+ sourcexml.setAttribute("key", source.get_key())
+ sourcexml.setAttribute("name", source.get_name())
+ conduitxml.appendChild(sourcexml)
+ #Store source settings
+ configxml = xml.dom.minidom.parseString(source.get_configuration_xml())
+ sourcexml.appendChild(configxml.documentElement)
+
+ #Store all sinks
+ sinksxml = doc.createElement("datasinks")
+ for sink in cond.datasinks:
+ sinkxml = doc.createElement("datasink")
+ sinkxml.setAttribute("key", sink.get_key())
+ sinkxml.setAttribute("name", sink.get_name())
+ sinksxml.appendChild(sinkxml)
+ #Store sink settings
+ configxml = xml.dom.minidom.parseString(sink.get_configuration_xml())
+ sinkxml.appendChild(configxml.documentElement)
+ conduitxml.appendChild(sinksxml)
+
+ #Save to disk
+ try:
+ file_object = open(xmlSettingFilePath, "w")
+ file_object.write(doc.toxml())
+ #file_object.write(doc.toprettyxml())
+ file_object.close()
+ except IOError, err:
+ log.warn("Could not save settings to %s (Error: %s)" % (xmlSettingFilePath, err.strerror))
+
+ def restore_from_xml(self, syncset, xmlSettingFilePath=None):
+ """
+ Restores sync settings from the xml file
+ """
+
+
+ #Check the file exists
+ if not os.path.isfile(xmlSettingFilePath):
+ log.info("%s not present" % xmlSettingFilePath)
+ return
+
+ try:
+ #Open
+ doc = xml.dom.minidom.parse(xmlSettingFilePath)
+
+ #check the xml file is in a version we can read.
+ if doc.documentElement.hasAttribute("settings-version"):
+ xml_version = doc.documentElement.getAttribute("settings-version")
+ try:
+ xml_version = int(xml_version)
+ except ValueError, TypeError:
+ log.error("%s xml file version is not valid" % xmlSettingFilePath)
+ os.remove(xmlSettingFilePath)
+ return
+ if int(SETTINGS_VERSION) < xml_version:
+ log.warning("%s xml file is incorrect version" % xmlSettingFilePath)
+ os.remove(xmlSettingFilePath)
+ return
+ else:
+ log.info("%s xml file version not found, assuming version 1" % xmlSettingFilePath)
+ xml_version = 1
+
+ #Parse...
+ for conds in doc.getElementsByTagName("conduit"):
+ #create a new conduit
+ cond = Conduit.Conduit(syncset.syncManager, conds.getAttribute("uid"))
+ syncset.add_conduit(cond)
+
+ #restore conduit specific settings
+ twoway = Settings.string_to_bool(conds.getAttribute("twoway"))
+ if twoway == True:
+ cond.enable_two_way_sync()
+ auto = Settings.string_to_bool(conds.getAttribute("autosync"))
+ if auto == True:
+ cond.enable_auto_sync()
+ for policyName in Conduit.CONFLICT_POLICY_NAMES:
+ cond.set_policy(
+ policyName,
+ conds.getAttribute("%s_policy" % policyName)
+ )
+
+ #each dataprovider
+ for i in conds.childNodes:
+ #keep a ref to the dataproider was added to so that we
+ #can apply settings to it at the end
+ #one datasource
+ if i.nodeType == i.ELEMENT_NODE and i.localName == "datasource":
+ key = i.getAttribute("key")
+ name = i.getAttribute("name")
+ #add to canvas
+ if len(key) > 0:
+ syncset._restore_dataprovider(cond, key, name, i, xml_version, True)
+ #many datasinks
+ elif i.nodeType == i.ELEMENT_NODE and i.localName == "datasinks":
+ #each datasink
+ for sink in i.childNodes:
+ if sink.nodeType == sink.ELEMENT_NODE and sink.localName == "datasink":
+ key = sink.getAttribute("key")
+ name = sink.getAttribute("name")
+ #add to canvas
+ if len(key) > 0:
+ syncset._restore_dataprovider(cond, key, name, sink, xml_version, False)
+
+ except Exception:
+ log.warn("Error parsing %s. Exception:\n%s" % (xmlSettingFilePath, traceback.format_exc()))
+ os.remove(xmlSettingFilePath)
diff --git a/conduit/conduit.real b/conduit/conduit.real
index 189fe26..6724878 100755
--- a/conduit/conduit.real
+++ b/conduit/conduit.real
@@ -32,6 +32,6 @@ log = logging.getLogger("Conduit")
try:
app = conduit.Main.Application()
except:
- log.error("Fatal error, exiting. %s" % traceback.format_exc())
- exit(-1)
+ log.error("Error, exiting. %s" % traceback.format_exc())
+ sys.exit(-1)
diff --git a/conduit/gtkui/ConfigContainer.py b/conduit/gtkui/ConfigContainer.py
index a92f75f..a675133 100644
--- a/conduit/gtkui/ConfigContainer.py
+++ b/conduit/gtkui/ConfigContainer.py
@@ -18,8 +18,8 @@ import conduit.gtkui.ConfigItems as ConfigItems
import conduit.Configurator as Configurator
class Error(Exception):
- """Base exception for all exceptions raised in this module."""
- pass
+ """Base exception for all exceptions raised in this module."""
+ pass
class ConfigContainer(Configurator.BaseConfigContainer):
"""
diff --git a/conduit/gtkui/Tree.py b/conduit/gtkui/Tree.py
index d8c9785..9390b35 100644
--- a/conduit/gtkui/Tree.py
+++ b/conduit/gtkui/Tree.py
@@ -76,7 +76,7 @@ class DataProviderTreeModel(gtk.GenericTreeModel):
def _get_category_index_by_name(self, category_name):
i = 0
for j in self.cats:
- if j.category == category_name:
+ if j.category.key == category_name.key:
return i
i += 1
return None
diff --git a/conduit/gtkui/UI.py b/conduit/gtkui/UI.py
index 5de004d..be86e69 100644
--- a/conduit/gtkui/UI.py
+++ b/conduit/gtkui/UI.py
@@ -563,7 +563,7 @@ class MainWindow:
Saves the GUI settings (window state, position, etc to gconf)
"""
#save the canvas
- self.syncSet.save_to_xml()
+ self.syncSet.save()
#GUI settings
conduit.GLOBALS.settings.set(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]