[deskbar-applet/gnome-2-26] Fixed parts of bug #577649. Check if templates directory can be retrieved and exists in initialize.



commit 89492da7662d538b17308fd2c4121356df404bea
Author: Sebastian Pölsterl <sebp k-d-w org>
Date:   Fri May 1 20:02:44 2009 +0200

    Fixed parts of bug #577649. Check if templates directory can be retrieved and exists in initialize.
---
 deskbar/handlers/templates.py |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/deskbar/handlers/templates.py b/deskbar/handlers/templates.py
index 7bc2623..0a9ec59 100644
--- a/deskbar/handlers/templates.py
+++ b/deskbar/handlers/templates.py
@@ -199,17 +199,24 @@ class TemplateHandler(deskbar.interfaces.Module):
                 self._add_template_file(file_path)
  
     def initialize(self):
-        templates_dir = deskbar.core.Utils.get_xdg_user_dir(deskbar.core.Utils.DIRECTORY_TEMPLATES)
-        self._add_templates_dir(templates_dir)
-
-        gfile = gio.File(path=templates_dir)
         try:
-            filemonitor = gfile.monitor_directory()
-            if filemonitor != None:
-                filemonitor.connect ("changed", self._templates_dir_monitor_cb)
-                self.monitors.append(filemonitor)
-        except Exception, e:
+            templates_dir = deskbar.core.Utils.get_xdg_user_dir(deskbar.core.Utils.DIRECTORY_TEMPLATES)
+        except ValueError, e:
             LOGGER.exception(e)
+            templates_dir = None
+            return
+            
+        if os.path.exists(templates_dir):
+            self._add_templates_dir(templates_dir)
+
+            gfile = gio.File(path=templates_dir)
+            try:
+                filemonitor = gfile.monitor_directory()
+                if filemonitor != None:
+                    filemonitor.connect ("changed", self._templates_dir_monitor_cb)
+                    self.monitors.append(filemonitor)
+            except Exception, e:
+                LOGGER.exception(e)
 
     def query(self, query):
         matches = self.indexer.look_up(query)
@@ -219,4 +226,4 @@ class TemplateHandler(deskbar.interfaces.Module):
     def stop(self):
         for filemonitor in self.monitors:
             filemonitor.cancel()
-    
\ No newline at end of file
+



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