[Sugar-devel] [Sugar] Show a clean error in log if not libraries needed to do tts - SL #3345
godiard at sugarlabs.org
godiard at sugarlabs.org
Fri Mar 9 13:44:08 EST 2012
From: Gonzalo Odiard <godiard at gmail.com>
Signed-off-by: Gonzalo Odiard <gonzalo at laptop.org>
---
extensions/deviceicon/speech.py | 11 +++++++++--
extensions/globalkey/speech.py | 21 +++++++++++++--------
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/extensions/deviceicon/speech.py b/extensions/deviceicon/speech.py
index 6b8f915..b231f26 100644
--- a/extensions/deviceicon/speech.py
+++ b/extensions/deviceicon/speech.py
@@ -14,6 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+import logging
from gettext import gettext as _
import glib
@@ -29,8 +30,13 @@ from sugar.graphics.menuitem import MenuItem
from sugar.graphics import style
from jarabe.frame.frameinvoker import FrameWidgetInvoker
-from jarabe.model import speech
+tts_available = True
+try:
+ from jarabe.model import speech
+except:
+ logging.error('Text to speech no avalable: error loading dependencies')
+ tts_available = False
_ICON_NAME = 'microphone'
@@ -145,4 +151,5 @@ class SpeechPalette(Palette):
def setup(tray):
- tray.add_device(SpeechDeviceView())
+ if tts_available:
+ tray.add_device(SpeechDeviceView())
diff --git a/extensions/globalkey/speech.py b/extensions/globalkey/speech.py
index 2879b69..d0dd55d 100644
--- a/extensions/globalkey/speech.py
+++ b/extensions/globalkey/speech.py
@@ -14,16 +14,21 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-from jarabe.model import speech
+tts_available = True
+try:
+ from jarabe.model import speech
+except:
+ tts_available = False
BOUND_KEYS = ['<alt><shift>s']
def handle_key_press(key):
- manager = speech.get_speech_manager()
- if manager.is_paused:
- manager.restart()
- elif not manager.is_playing:
- manager.say_selected_text()
- else:
- manager.pause()
+ if tts_available:
+ manager = speech.get_speech_manager()
+ if manager.is_paused:
+ manager.restart()
+ elif not manager.is_playing:
+ manager.say_selected_text()
+ else:
+ manager.pause()
--
1.7.7.6
More information about the Sugar-devel
mailing list