Beispiel #1
0
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)
Beispiel #2
0
    def __init__(self, srcDir, dstDir, audioLength, fadeLength=None):
        """audio and fade lengths are in secondss
        will get all aiff files in the srcDir"""
        self.srcDir = srcDir
        self.dstDir = dstDir

        if not os.path.exists(self.dstDir):
            osTools.mkdir(self.dstDir)
        
        self.audioFrame = secToFrame(audioLength)
        if fadeLength != None:
            self.fadeFrame = secToFrame(fadeLength)
        else: 
            self.fadeFrame = None # turns off fades

        obj = fileTools.AllFiles(self.srcDir, ['aif', 'aiff'])
        self.srcFiles = obj.report()
        # make a list indices to get src files from; will randomize
        self.srcKeys = list(range(0, len(self.srcFiles)))
        self.dstFiles = []
Beispiel #3
0
    def __init__(self, srcDir, dstDir, audioLength, fadeLength=None):
        """audio and fade lengths are in secondss
        will get all aiff files in the srcDir"""
        self.srcDir = srcDir
        self.dstDir = dstDir

        if not os.path.exists(self.dstDir):
            osTools.mkdir(self.dstDir)
        
        self.audioFrame = secToFrame(audioLength)
        if fadeLength != None:
            self.fadeFrame = secToFrame(fadeLength)
        else: 
            self.fadeFrame = None # turns off fades

        obj = fileTools.AllFiles(self.srcDir, ['aif', 'aiff'])
        self.srcFiles = obj.report()
        # make a list indices to get src files from; will randomize
        self.srcKeys = range(0, len(self.srcFiles))
        self.dstFiles = []
Beispiel #4
0
def TestOld():
    src = '/Volumes/ydisc/_sync/iport/shardSrc/'
    dst = '/Volumes/ydisc/_sync/iport/shardDst/shardBassB-136/'

    if not os.path.exists(dst):
        osTools.mkdir(dst)
    indexStart = 0
    
    # original tests, base 60bpm
    #a = ShardHarvest(src, dst, .120, .012)
    #a = ShardHarvest(src, dst, .060, .006)
    #a = ShardHarvest(src, dst, .030, .003)
    #a = ShardHarvest(src, dst, .015, .0015)

    # bass 220 bpm
    #a = ShardHarvest(src, dst, 0.0170454545455, .0017045) # 500
    #a = ShardHarvest(src, dst, 0.0340909090909, .0034091)  # 500
    #a = ShardHarvest(src, dst, 0.0681818181818, .0068182) # 300
    a = ShardHarvest(src, dst, 0.1363636363636, .0136364) # 300


    # reccomended numbers between 300 and 500 (more for shorter)
    print(a.gather(300, indexStart))
Beispiel #5
0
def TestOld():
    src = '/Volumes/ydisc/_sync/iport/shardSrc/'
    dst = '/Volumes/ydisc/_sync/iport/shardDst/shardBassB-136/'

    if not os.path.exists(dst):
        osTools.mkdir(dst)
    indexStart = 0
    
    # original tests, base 60bpm
    #a = ShardHarvest(src, dst, .120, .012)
    #a = ShardHarvest(src, dst, .060, .006)
    #a = ShardHarvest(src, dst, .030, .003)
    #a = ShardHarvest(src, dst, .015, .0015)

    # bass 220 bpm
    #a = ShardHarvest(src, dst, 0.0170454545455, .0017045) # 500
    #a = ShardHarvest(src, dst, 0.0340909090909, .0034091)  # 500
    #a = ShardHarvest(src, dst, 0.0681818181818, .0068182) # 300
    a = ShardHarvest(src, dst, 0.1363636363636, .0136364) # 300


    # reccomended numbers between 300 and 500 (more for shorter)
    print a.gather(300, indexStart)