def run(self): srcObj = AudioFile(self.src) frames = srcObj.getSize() print(_MOD, 'length', frames) #refObj = srcObj.extract(self.ref, 0, frames) # store a version #storageObj = srcObj.extract(self.storage, 0, frames) #print _MOD, 'duration', storageObj.getDur() br = self.bitRateArray[0] encodeSrcPath = copy.copy(self.src) for i in range(self.steps): tempEnc = os.path.join(self.dir, '%s%s' % (self.nameStub+'-enc'+str(i), '.mp3')) junk, tempEncName = os.path.split(tempEnc) tempDec = os.path.join(self.dir, '%s%s' % (self.nameStub+'-dec'+str(i), '.wav')) junk, tempDecName = os.path.split(tempDec) postMp3 = encodeMp3(encodeSrcPath, None, br, '', '', '', '', tempEncName, 9) # quality set to 9 postWav = decodeMp3(postMp3, None, tempDecName, 9) postAif = soxConvert(postWav, '.wav', '.aif') osTools.rm(postWav) encodeSrcPath = postAif # store re-decoded aif path
def writeUnixLauncher(pathLaunchScript, pathShellScript, optInstallTool=0, sudoFound=None): """used to create shell scripts that act as application launcher creates file in local directory first, using paths in args will optional move to /usr/local/bin if optInstallTool is 1 pathLaunchScript is the path to the python file pathShellScript is the path to the shell script to be written\ if optInstallTool == 2; case were to assume already root """ environment.printWarn('writing launcher script:\n%s' % pathLaunchScript) pythonExe = sys.executable # get name of shell script dir, name = os.path.split(pathShellScript) # sets command line options: -O for optimized # sets -u for unbuffered standard out launchScript = '#!/bin/sh \n%s -O -u %s $*\n\n' % (pythonExe, pathLaunchScript) # erase if already exists if os.path.exists(pathShellScript): if optInstallTool <= 1: # use sudo osTools.rmSudo(pathShellScript, sudoFound) elif optInstallTool == 2: # do not use sudo osTools.rm(pathShellScript) # touch a file first # always write a basic script in local dirs try: f = open(pathShellScript, 'w') # test opening the file f.close() permissionError = 0 except IOError: permissionError = 1 if permissionError: # try to change mod of parent dir dir, name = os.path.split(pathShellScript) osTools.chmodSudo(775, dir, sudoFound) # try again w/ changed permissions try: f = open(pathShellScript, 'w') f.write(launchScript) f.close() osTools.chmod(775, pathShellScript) except IOError: environment.printWarn(lang.msgFileIoError % pathShellScript) # optionally move this script to /usr/local/bin if optInstallTool >= 1: # install tool into /usr/local/bin binPath = osTools.findBinPath() flagStr = '-p' # create intermediate dirs as required dstPath = os.path.join(binPath, name) print _MOD, 'installing launcher script:\n%s' % dstPath if not os.path.exists(binPath): # create directory if optInstallTool == 1: # use sudo osTools.mkdirSudo(binPath, sudoFound, flagStr) if optInstallTool == 2: # already root osTools.mkdir(binPath, flagStr) # mv launcher script to dir if optInstallTool == 1: # use sudo, get permissioin osTools.mvSudo(pathShellScript, dstPath, sudoFound) elif optInstallTool == 2: # already root osTools.mv(pathShellScript, dstPath)
def run(self): srcObj = AudioFile(self.src) frames = srcObj.getSize() print _MOD, 'length', frames #refObj = srcObj.extract(self.ref, 0, frames) # store a version #storageObj = srcObj.extract(self.storage, 0, frames) #print _MOD, 'duration', storageObj.getDur() br = self.bitRateArray[0] encodeSrcPath = copy.copy(self.src) for i in range(self.steps): tempEnc = os.path.join(self.dir, '%s%s' % (self.nameStub+'-enc'+str(i), '.mp3')) junk, tempEncName = os.path.split(tempEnc) tempDec = os.path.join(self.dir, '%s%s' % (self.nameStub+'-dec'+str(i), '.wav')) junk, tempDecName = os.path.split(tempDec) postMp3 = encodeMp3(encodeSrcPath, None, br, '', '', '', '', tempEncName, 9) # quality set to 9 postWav = decodeMp3(postMp3, None, tempDecName, 9) postAif = soxConvert(postWav, '.wav', '.aif') osTools.rm(postWav) encodeSrcPath = postAif # store re-decoded aif path
def writeManifestTemplate(fpPackageDir): # remove old maniest osTools.rm(os.path.join(fpPackageDir, 'MANIFEST')) dst = os.path.join(fpPackageDir, 'MANIFEST.in') msg = [] msg.append('global-include *.txt *.aif *.htm *.mid *.png *.xml *.css *.py *.mp3\n') msg.append('prune buildDoc\n') msg.append('prune dist\n') msg.append('prune obsolete\n') msg.append('prune tools\n') f = open(dst, 'w') f.writelines(msg) f.close()