def analyse(self, path, analyst=None):

        def cbShouldFail(result):
            raise Exception("Should have failed")

        def ebExpectedFailure(failure, result):
            if failure.check(MediaAnalysisUnknownTypeError):
                return result
            return failure

        if not analyst:
            analyst = MediaAnalyst()
        d = analyst.analyse(path)
        d.addCallbacks(cbShouldFail, ebExpectedFailure,
                       errbackArgs=(path,))
        return d
 def cbAnalyse(self, generator, analyst, timeout=None, oldResult=None):
     if not analyst:
         analyst = MediaAnalyst()
     d = analyst.analyse(generator.path, timeout)
     d.addCallback(self.cbCheckValid, generator, oldResult)
     return d