From 2fa8060b7fd790b3260e65d225a4eca5080683a7 Mon Sep 17 00:00:00 2001 From: Oli Date: Thu, 10 Apr 2008 03:30:59 +0000 Subject: On the way to respect security policy --- (limited to 'TamTamSynthLab.activity') diff --git a/TamTamSynthLab.activity/SynthLab/SynthLabMain.py b/TamTamSynthLab.activity/SynthLab/SynthLabMain.py index 69d8340..86ee199 100644 --- a/TamTamSynthLab.activity/SynthLab/SynthLabMain.py +++ b/TamTamSynthLab.activity/SynthLab/SynthLabMain.py @@ -299,7 +299,7 @@ class SynthLabMain(gtk.EventBox): self.drawingBox.pack_start(self.drawingArea, False, False, 0) tempFile = 'synthTemp' - if tempFile in os.listdir(Config.PREF_DIR): + if tempFile in os.listdir(Config.TMP_DIR): self.handleLoadTemp() else: self.presetCallback(None,1) @@ -529,7 +529,7 @@ class SynthLabMain(gtk.EventBox): def playNote( self, midiPitch, table ): cpsPitch = 261.626*pow(1.0594633, midiPitch-36) self.recCount += 1 - mess = "i5203." + str(self.recCount) + " 0 " + str(self.duration) + " " + str(cpsPitch) + " " + str(table) + " " + " " .join([str(n) for n in self.synthObjectsParameters.getOutputParameters()]) + mess = "i5203." + str(self.recCount) + " 0 " + str(self.duration) + " " + str(cpsPitch) + " " + str(table) + " " + " ".join([str(n) for n in self.synthObjectsParameters.getOutputParameters()]) + ' "%s"' % Config.DATA_DIR self.csnd.inputMessage( mess ) if self.recCount >= 9: self.recCount = 0 @@ -633,11 +633,12 @@ class SynthLabMain(gtk.EventBox): if self.synthObjectsParameters.types[i] == 9: snd = i - 3 dur = self.synthObjectsParameters.sourcesParameters[(i % 4) * 4] - os.system('rm ' + Config.SNDS_DIR + '/labmic' + str(snd)) - (s1,o1) = commands.getstatusoutput("arecord -f S16_LE -t wav -r 16000 -d " + str(dur) + " " + Config.SNDS_DIR + '/tempMic.wav') - (s2, o2) = commands.getstatusoutput("csound " + Config.FILES_DIR + "/cropSynthLab.csd") - (s3, o3) = commands.getstatusoutput("mv " + Config.SNDS_DIR + "/micTemp " + Config.SNDS_DIR + "/" + 'labmic' + str(snd)) - (s4, o4) = commands.getstatusoutput("rm " + Config.SNDS_DIR + "/tempMic.wav") + if os.path.isfile(Config.DATA_DIR + '/labmic' + str(snd)): + os.system('rm ' + Config.DATA_DIR + '/labmic' + str(snd)) + (s1,o1) = commands.getstatusoutput("arecord -f S16_LE -t wav -r 16000 -d " + str(dur) + " " + Config.DATA_DIR + '/tempMic.wav') + (s2, o2) = commands.getstatusoutput("csound " + "--strset999=" + Config.DATA_DIR + " " + Config.FILES_DIR + "/cropSynthLab.csd") + (s3, o3) = commands.getstatusoutput("mv " + Config.DATA_DIR + "/micTemp.wav " + Config.DATA_DIR + "/" + 'labmic' + str(snd)) + (s4, o4) = commands.getstatusoutput("rm " + Config.DATA_DIR + "/tempMic.wav") return def handleMotion( self, widget, event ): @@ -1174,7 +1175,8 @@ class SynthLabMain(gtk.EventBox): if widget.get_active() == True: self.recordButton = widget self.recordWait = 1 - os.system('rm ' + Config.SNDS_DIR + '/lab' + str(data)) + if os.path.isfile(Config.DATA_DIR + '/lab' + str(data)): + os.system('rm ' + Config.DATA_DIR + '/lab' + str(data)) self.table = 85 + data else: self.recordWait = 0 @@ -1304,7 +1306,7 @@ class SynthLabMain(gtk.EventBox): filter = gtk.FileFilter() filter.add_pattern('*.syn') chooser.set_filter(filter) - chooser.set_current_folder(Config.SYNTH_DIR) + chooser.set_current_folder(Config.DATA_DIR) for f in chooser.list_shortcut_folder_uris(): chooser.remove_shortcut_folder_uri(f) @@ -1334,7 +1336,7 @@ class SynthLabMain(gtk.EventBox): filter = gtk.FileFilter() filter.add_pattern('*.syn') chooser.set_filter(filter) - chooser.set_current_folder(Config.SYNTH_DIR) + chooser.set_current_folder(Config.DATA_DIR) for f in chooser.list_shortcut_folder_uris(): chooser.remove_shortcut_folder_uri(f) @@ -1356,13 +1358,13 @@ class SynthLabMain(gtk.EventBox): f.close() def handleSaveTemp( self ): - file = Config.PREF_DIR + '/synthTemp' + file = Config.TMP_DIR + '/synthTemp' f = shelve.open(file, 'n') self.saveState(f) f.close() def handleLoadTemp( self ): - file = Config.PREF_DIR + '/synthTemp' + file = Config.TMP_DIR + '/synthTemp' f = shelve.open(file, 'r') self.loadState(f) f.close() diff --git a/TamTamSynthLab.activity/TamTamSynthLab.py b/TamTamSynthLab.activity/TamTamSynthLab.py index 496dd97..483d4f0 100644 --- a/TamTamSynthLab.activity/TamTamSynthLab.py +++ b/TamTamSynthLab.activity/TamTamSynthLab.py @@ -21,7 +21,11 @@ from sugar.activity import activity class TamTamSynthLab(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) - self.ensure_dirs() + + for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']: + if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)): + shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.DATA_DIR + '/' + snd) + os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &') color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) @@ -93,7 +97,6 @@ class TamTamSynthLab(activity.Activity): def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' - os.system('rm -f ' + Config.PREF_DIR + '/synthTemp*') self.synthLab.onDestroy() @@ -103,6 +106,7 @@ class TamTamSynthLab(activity.Activity): gtk.main_quit() +# No more dir created by TamTam def ensure_dir(self, dir, perms=0777, rw=os.R_OK|os.W_OK): if not os.path.isdir( dir ): try: @@ -112,20 +116,6 @@ class TamTamSynthLab(activity.Activity): if not os.access(dir, rw): print 'ERROR: directory %s is missing required r/w access\n' % dir - def ensure_dirs(self): - self.ensure_dir(Config.TUNE_DIR) - self.ensure_dir(Config.SYNTH_DIR) - self.ensure_dir(Config.SNDS_DIR) - self.ensure_dir(Config.SNDS_INFO_DIR) - self.ensure_dir(Config.SCRATCH_DIR) - - if not os.path.isdir(Config.PREF_DIR): - os.mkdir(Config.PREF_DIR) - os.system('chmod 0777 ' + Config.PREF_DIR + ' &') - for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']: - shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.SNDS_DIR + '/' + snd) - os.system('chmod 0777 ' + Config.SNDS_DIR + '/' + snd + ' &') - def read_file(self,file_path): self.synthLab.handleJournalLoad(file_path) -- cgit v0.9.1