[deskbar-applet] Fixed parts of bug #577649. Check if templates directory can be retrieved and exists in has_requirem



commit a619630066e481bd68ea600156ba90d343ee6e05
Author: Sebastian Pölsterl <sebp k-d-w org>
Date:   Fri May 1 19:49:47 2009 +0200

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

diff --git a/deskbar/handlers/templates.py b/deskbar/handlers/templates.py
index 7bc2623..b784382 100644
--- a/deskbar/handlers/templates.py
+++ b/deskbar/handlers/templates.py
@@ -219,4 +219,21 @@ class TemplateHandler(deskbar.interfaces.Module):
     def stop(self):
         for filemonitor in self.monitors:
             filemonitor.cancel()
-    
\ No newline at end of file
+            
+    @staticmethod
+    def has_requirements():
+        # Work around bug #577649
+        try:
+            templates_dir = deskbar.core.Utils.get_xdg_user_dir(deskbar.core.Utils.DIRECTORY_TEMPLATES)
+        except ValueError, e:
+            LOGGER.exception(e)
+            # TODO mark translatable
+            TemplateHandler.INSTRUCTIONS = "Could not retrieve templates directory"
+            return False
+
+        if os.path.exists(templates_dir):
+            return True
+        else:
+           TemplateHandler.INSTRUCTIONS = "Templates directory %s does not exist" % templates_dir
+           return False
+    



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