[gnome-clocks] Handle lack of canberra gracefully



commit 0b288bf52e461710175298b1d8232041d221a4d7
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Aug 25 15:56:50 2012 +0200

    Handle lack of canberra gracefully

 gnomeclocks/utils.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gnomeclocks/utils.py b/gnomeclocks/utils.py
index 3542ea0..037cc60 100644
--- a/gnomeclocks/utils.py
+++ b/gnomeclocks/utils.py
@@ -63,7 +63,12 @@ class SystemSettings:
 
 class Alert:
     def __init__(self, soundid, msg, callback):
-        self.canberra = pycanberra.Canberra()
+        try:
+            self.canberra = pycanberra.Canberra()
+        except Exception, e:
+            print "Sound will not be available: ", e
+            self.canberra = None
+
         self.soundid = soundid
 
         self.notification = None
@@ -75,6 +80,7 @@ class Alert:
             print "Error: Could not trigger Alert"
 
     def show(self):
-        self.canberra.play(1, pycanberra.CA_PROP_EVENT_ID, self.soundid, None)
+        if self.canberra:
+            self.canberra.play(1, pycanberra.CA_PROP_EVENT_ID, self.soundid, None)
         if self.notification:
             self.notification.show()



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