Beispiel #1
0
def _generateFileList(files, recursive, expand, deleteOnExpand):
    @defer.inlineCallbacks
    def _(accum, f):
        if expand and _isArchive(f):
            expandedFiles = yield _expandArchive(f)
            if deleteOnExpand:
                os.unlink(f)
            defer.returnValue(accum + [
                i for i in expandedFiles
                if os.path.isfile(i) and not '__MACOSX' in i
            ])
        elif recursive and os.path.isdir(f):
            recursedFiles = yield _generateFileList(
                [os.path.join(f, fname) for fname in os.listdir(f)], recursive,
                expand, deleteOnExpand)
            defer.returnValue(accum + recursedFiles)
        elif os.path.isfile(f):
            ## Hacky fix for Mac OSX-created archives that will have dot files in them
            if '__MACOSX' in str(f):
                defer.returnValue(accum)
            else:
                defer.returnValue(accum + [str(f)])
        else:
            raise IOError('%s does not exist' % f)

    return defer_utils.fold(_, [], files)
Beispiel #2
0
def _generateFileList(files, recursive, expand, deleteOnExpand):
    @defer.inlineCallbacks
    def _(accum, f):
        if expand and _isArchive(f):
            expandedFiles = yield _expandArchive(f)
            if deleteOnExpand:
                os.unlink(f)
            defer.returnValue(accum + [i for i in expandedFiles if os.path.isfile(i) and not '__MACOSX' in i])
        elif recursive and os.path.isdir(f):
            recursedFiles = yield _generateFileList([os.path.join(f, fname)
                                                     for fname in os.listdir(f)],
                                                    recursive,
                                                    expand,
                                                    deleteOnExpand)
            defer.returnValue(accum + recursedFiles)
        elif os.path.isfile(f):
            ## Hacky fix for Mac OSX-created archives that will have dot files in them
            if '__MACOSX' in str(f):
                defer.returnValue(accum)
            else:
                defer.returnValue(accum + [str(f)])
        else:
            raise IOError('%s does not exist' % f)

    return defer_utils.fold(_, [], files)
Beispiel #3
0
def runTasklet(taskName, initialText, tasklets):
    def _raise(tasklet, err):
        raise MetricError(tasklet, err)

    def _run(text, tasklet):
        stdout = StringIO.StringIO()
        stderr = StringIO.StringIO()

        p = commands.runProcess(parseCmd(tasklet),
                                initialText=text,
                                stdoutf=stdout.write,
                                stderrf=stderr.write)
        p.addCallback(
            lambda _: tasks.updateTask(taskName, lambda t: t.progress()))
        p.addCallback(lambda _: stdout.getvalue())
        p.addErrback(lambda _: _raise(tasklet, stderr.getvalue()))
        return p

    return defer_utils.fold(_run, initialText, tasklets)
Beispiel #4
0
def runTasklet(taskName, initialText, tasklets):
    def _raise(tasklet, err):
        raise MetricError(tasklet, err)
    
    def _run(text, tasklet):
        stdout = StringIO.StringIO()
        stderr = StringIO.StringIO()

        p = commands.runProcess(parseCmd(tasklet),
                                initialText=text,
                                stdoutf=stdout.write,
                                stderrf=stderr.write)
        p.addCallback(lambda _ : tasks.updateTask(taskName,
                                                  lambda t : t.progress()))
        p.addCallback(lambda _ : stdout.getvalue())
        p.addErrback(lambda _ : _raise(tasklet, stderr.getvalue()))
        return p

    return defer_utils.fold(_run, initialText, tasklets)
Beispiel #5
0
 def _(v):
     return defer_utils.fold(_runf, v, fs)
Beispiel #6
0
 def _(v):
     return defer_utils.fold(_runf, v, fs)