[conduit] Only load FF3 module if /Users/andy/.mozilla/firefox exists



commit 03bcf91b125da4f73e33feece50bc5ba366da6b7
Author: Andrew Stormont <andy andrew-stormonts-power-mac-g4 local>
Date:   Thu Jul 16 15:31:25 2009 +0200

    Only load FF3 module if /Users/andy/.mozilla/firefox exists

 ChangeLog                                        |    5 +++++
 conduit/modules/Firefox3Module/Firefox3Module.py |   16 ++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2bc2c27..fc1d571 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-16  Andrew Stormont  <astormont svn gnome org>
+
+	* conduit/modules/Firefox3Module/Firefox3Module.py:
+	Only load FF3 module if $HOME/.mozilla/firefox exists	
+
 2009-07-15  Andrew Stormont  <astormont svn gnome org>
 
 	* conduit/conduit.real:
diff --git a/conduit/modules/Firefox3Module/Firefox3Module.py b/conduit/modules/Firefox3Module/Firefox3Module.py
index 48d5515..51aa8e1 100644
--- a/conduit/modules/Firefox3Module/Firefox3Module.py
+++ b/conduit/modules/Firefox3Module/Firefox3Module.py
@@ -14,9 +14,14 @@ import conduit.utils as Utils
 import conduit.datatypes.Bookmark as Bookmark
 import conduit.Exceptions as Exceptions
 
-MODULES = {
-    "Firefox3DataProviderSource" : { "type" : "dataprovider" },
-}
+FFDIR = os.path.expanduser(os.path.join("~",".mozilla","firefox"))
+
+if os.path.exists(FFDIR): 
+    MODULES = {
+        "Firefox3DataProviderSource" : { "type" : "dataprovider" },
+    }
+else: 
+    MODULES = {}
 
 class Firefox3DataProviderSource(DataProvider.DataSource):
     """ 
@@ -37,9 +42,8 @@ class Firefox3DataProviderSource(DataProvider.DataSource):
         DataProvider.DataSource.__init__(self)
 
         self._bookmarks = []
-        self._ffdir = os.path.expanduser(os.path.join("~",".mozilla","firefox"))
         self._cf = ConfigParser.ConfigParser()
-        self._cf.read(os.path.join(self._ffdir,"profiles.ini"))
+        self._cf.read(os.path.join(FFDIR,"profiles.ini"))
 
         self.update_configuration(
             profilepath = self._cf.get("Profile0", "Path") # default
@@ -55,7 +59,7 @@ class Firefox3DataProviderSource(DataProvider.DataSource):
     def refresh(self):
         DataProvider.DataSource.refresh(self)
         # sqlite3 is not thread safe, so we cannot preserve connections in this class
-        con = sqlite3.connect(os.path.join(self._ffdir,self.profilepath,"places.sqlite"))
+        con = sqlite3.connect(os.path.join(FFDIR,self.profilepath,"places.sqlite"))
         try:
             # table structure
             # moz_bookmarks: id|type|fk|parent|position|title|keyword_id|folder_type|dateAdded|lastModified



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