Example #1
0
def mkTempFile(ext):
    with Debug("mkTempFile"):
        temp = ""
        if ext in tempFile:
            temp = tempFile[ext]
        else:
            temp = mkstemp(ext)[1]
            tempFile[ext] = temp
        Debug.report(temp)
        return temp
Example #2
0
def ExecCommand(cmd):
    with Debug("Exec: " + cmd, "Exec"):
        try:
            process = subprocess.Popen(split(cmd), stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE, close_fds=True)
        except OSError:
            raise AcSoxNotFoundException()
        (stdout, stderr) = process.communicate()
        if not stderr == "":
            Debug.report(stderr)
        return stdout
Example #3
0
 def __gatherFiles(self):
     with Debug("gatherFiles"):
         Files = []
         if self.Options.dir is not None:
             for d in self.Options.dir:
                 directory = abspath(d)
                 if exists(directory) and isdir(directory):
                     for f in glob(join(directory, self.Options.pathExtension)):
                         file = join(directory, f)
                         Files.append(file)
                 else:
                     Debug.report("%s does not Exist or is not a Directory." % d)
         if len(self.Args) > 0:
             for f in self.Args:
                 if exists(f) and isfile(f):
                     Files.append(abspath(f))
         Debug.report("%s found." % len(Files))
         return Files
Example #4
0
def getLength(f):
    with Debug("getLength"):
        lengthString = ExecCommand(soxLength.format(f))
        length = float(lengthString)
        Debug.report(str(length))
        return length
Example #5
0
def SetupSox(command):
    with Debug("SetupSox"):
        Debug.report("Sox command: " + command)
        global soxTrim, soxLength
        soxTrim = command + soxTrim
        soxLength = command + soxLength
Example #6
0
 def __exit__(self, t, value, stacktrace):
     if self.Options.debug:
         print(Debug.getDebugData())
     cleanTemp()