Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sound_check.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2014-02-04 21:06:57 (GMT)
committer Walter Bender <walter@sugarlabs.org>2014-02-04 21:06:57 (GMT)
commitdbd7908aaf2c0ad38dbe4ea9415d720cf8190452 (patch)
tree44b45e4b7c5f1897c3478509c25bc4ae634e7b68 /sound_check.py
parentd543dbd3c1a761876efda2220345117e1aefd624 (diff)
fix several issues with sound: workaround for import sugar3.activity error; don't load sound examples if tamtam suite is not installed
Diffstat (limited to 'sound_check.py')
-rw-r--r--sound_check.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/sound_check.py b/sound_check.py
new file mode 100644
index 0000000..831e9cf
--- /dev/null
+++ b/sound_check.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2013,14 Walter Bender (walter@sugarlabs.org)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import os
+from gettext import gettext as _
+
+class SoundLibraryNotFoundError(Exception):
+ def __init__(self):
+ Exception.__init__(self, _('Cannot find TamTamEdit sound library.'
+ ' Did you install TamTamEdit?'))
+
+def finddir():
+ paths = ['/usr/share/sugar/activities', '/home/olpc/Activities']
+ paths.append(os.path.join(os.path.expanduser('~'), 'Activities'))
+
+ sound_candidate_dirs = None
+
+ for path in paths:
+ for f in os.listdir(path):
+ if f in ['TamTamMini.activity', 'TamTamJam.activity',
+ 'TamTamEdit.activity', 'TamTamSynthLab.activity']:
+ bundle_dir = os.path.join(path, f)
+ tamtam_subdir = str(
+ os.path.join(bundle_dir, 'common', 'Resources', 'Sounds'))
+ sound_candidate_dirs = [
+ os.path.expandvars('$SUGAR_PATH/activities') + \
+ tamtam_subdir,
+ tamtam_subdir
+ ]
+
+ if sound_candidate_dirs is not None:
+ for directory in sound_candidate_dirs:
+ if os.path.isdir(directory):
+ return directory
+
+ raise SoundLibraryNotFoundError()