Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
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
parentd543dbd3c1a761876efda2220345117e1aefd624 (diff)
fix several issues with sound: workaround for import sugar3.activity error; don't load sound examples if tamtam suite is not installed
-rw-r--r--NEWS8
-rw-r--r--activity/activity.info2
-rw-r--r--library/pippy/sound.py53
-rw-r--r--pippy_app.py15
-rw-r--r--sound_check.py51
5 files changed, 100 insertions, 29 deletions
diff --git a/NEWS b/NEWS
index d538ca2..41339e7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+56
+
+ENHANCEMENT:
+* Don't offer up sound examples if TamTam is not installed
+
+BUG FIX:
+* Work around problem importing sugar3.actitity to generate bundle_path
+
55
ENHANCEMENTS:
diff --git a/activity/activity.info b/activity/activity.info
index bef40a4..6ddad48 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -3,7 +3,7 @@ name = Pippy
bundle_id = org.laptop.Pippy
exec = sugar-activity pippy_app.PippyActivity
icon = activity-icon
-activity_version = 55
+activity_version = 56
mime_types = text/x-python;pickle/groupthink-pippy
show_launcher = yes
license = GPLv2+
diff --git a/library/pippy/sound.py b/library/pippy/sound.py
index b758a2a..0e3cf03 100644
--- a/library/pippy/sound.py
+++ b/library/pippy/sound.py
@@ -1,6 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2007,2008 One Laptop per Child Association, Inc.
+# 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
@@ -20,29 +21,6 @@ import os
from gettext import gettext as _
from sugar3 import env
-from sugar3.activity import activity
-
-path = activity.get_bundle_path()
-path = path.split('/')[0:-1]
-path = '/'.join(path)
-
-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
- ]
- orchlines = []
- scorelines = []
- instrlist = []
- fnum = [100]
- else:
- sound_candidates_dir = None
'''XXX: This function seems to be broken. (CSA)
def quit(self):
@@ -52,6 +30,11 @@ cs.Reset()
cs = None
'''
+orchlines = []
+scorelines = []
+instrlist = []
+fnum = [100]
+
class SoundLibraryNotFoundError(Exception):
def __init__(self):
@@ -60,9 +43,27 @@ class SoundLibraryNotFoundError(Exception):
def finddir():
- for directory in sound_candidate_dirs:
- if os.path.isdir(directory):
- return directory
+ 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()
diff --git a/pippy_app.py b/pippy_app.py
index 4ceb6a1..a35b175 100644
--- a/pippy_app.py
+++ b/pippy_app.py
@@ -75,6 +75,7 @@ import groupthink.gtk_tools
from filedialog import FileDialog
from icondialog import IconDialog
+import sound_check
text_buffer = None
# magic prefix to use utf-8 source encoding
@@ -265,13 +266,19 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
stop = StopButton(self)
self.get_toolbar_box().toolbar.insert(stop, -1)
- self.paths = []
-
vpane = Gtk.Paned.new(orientation=Gtk.Orientation.VERTICAL)
vpane.set_position(400) # setting initial position
self.paths = []
+ try:
+ if sound_check.finddir():
+ TAMTAM_AVAILABLE = True
+ else:
+ TAMTAM_AVAILABLE = False
+ except sound_check.SoundLibraryNotFoundError:
+ TAMTAM_AVAILABLE = False
+
data_path = os.path.join(get_bundle_path(), 'data')
# get default language from locale
@@ -300,6 +307,10 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
self.all_folders.append(d)
for folder in self.all_folders:
+ # Skip sound folders if TAMTAM is not installed
+ if folder == 'sound' and not TAMTAM_AVAILABLE:
+ continue
+
direntry = {}
# check if dir exists in pref language, if exists, add it
if os.path.exists(os.path.join(lang_path, folder)):
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()