コード例 #1
0
 def __writeReport(self, report):
     if self._reportForcedPath:
         reportPath = self._reportForcedPath
     else:
         reportPath = self._reportDefaultPath
         #if running in diagnose mode, don't overrite it
         if self._diagnoseMode:
             reportPath = reportPath + ".diag"
     self.debug("Writing report file '%s'", reportPath)
     report.status = self._status
     fileutils.ensureDirExists(os.path.dirname(reportPath),
                               "report", self._pathAttr)
     saver = IniFile()
     saver.saveToFile(report, reportPath)
     if self._pathAttr:
         self._pathAttr.apply(reportPath)
コード例 #2
0
 def transcoder_checks(result):
     # PyChecker doesn't like dynamic attributes
     __pychecker__ = "no-objattrs"
     props = self.config["properties"]
     #FIXME: Better checks for path roots
     self._waitAcknowledge = props.get("wait-acknowledge", False)
     self._moveInputFile = props.get("move-input-file", True)
     self._niceLevel = props.get("nice-level", None)
     self._pathAttr = fileutils.PathAttributes.createFromComponentProperties(props)
     localRepPath = props.get("report", None)
     self._reportForcedPath = localRepPath and os.path.realpath(localRepPath)
     if props.has_key("config"):
         self._local = Local.createFromComponentProperties(props)
         configPath = VirtualPath(props["config"])
         localConfigPath = configPath.localize(self._local)
         self.debug("Loading configuration from '%s'",
                    localConfigPath)
         self._configPath = localConfigPath
         self._inputPath = None
         self._diagnoseMode = False
     else:
         localReportPath = props["diagnose"]
         self.debug("Loading report from '%s'", localReportPath)
         baseReport = TranscodingReport()
         loader = IniFile()
         loader.loadFromFile(baseReport, localReportPath)
         self.info("Using local '%s' from report file",
                   baseReport.local.name)
         self._local = baseReport.local.getLocal()
         self._local.updateFromComponentProperties(props)
         configPath = baseReport.configPath
         localConfigPath = configPath.localize(self._local)
         if not os.path.exists(localConfigPath):
             msg = "Config file not found ('%s')" % localConfigPath
             raise TranscoderConfigError(msg)
         self._configPath = localConfigPath
         alternatives = [baseReport.source.lastPath,
                         baseReport.source.failedPath,
                         baseReport.source.donePath,
                         baseReport.source.inputPath]
         for virtAltPath in alternatives:
             self._inputPath = virtAltPath.localize(self._local)
             if os.path.isfile(self._inputPath):
                 break
         self._diagnoseMode = True
     return result
コード例 #3
0
    def do_setup(self):
        try:
            localConfigPath = self._configPath
            configPath = VirtualPath.virtualize(localConfigPath, self._local)
            self.debug("Loading configuration from '%s'", localConfigPath)

            self._config = TranscodingConfig()
            loader = IniFile()
            loader.loadFromFile(self._config, localConfigPath)

            if self._inputPath:
                confInputFile = self._config.source.inputFile
                if not self._inputPath.endswith(confInputFile):
                    raise Exception("The source file path "
                                    + "doesn't match the configuration "
                                    + "source input-file property")
                altInputDir = self._inputPath[:-len(confInputFile)]
            else:
                altInputDir=None

            #TODO add cue points in report
            self._report = TranscodingReport()
            self._report.init(self._config)
            self._report.configPath = configPath

            if not self._diagnoseMode:
                moveInputFile = self._moveInputFile
            else:
                self.info("Entering diagnose mode")
                moveInputFile = False

            self._job = job.TranscodingJob(self, self, self._pathAttr)
            self._job.setup(self._local, self._config, self._report,
                            moveInputFile=moveInputFile,
                            altInputDir=altInputDir,
                            niceLevel=self._niceLevel)
            d = self._job.start()
            self._reportDefaultPath = self._job.getTempReportPath()
            self.__syncReport(self._report)
            d.addCallbacks(self.__cbJobDone, self.__ebJobFailed)
            return None
        except:
            self.__unexpectedError(task="component setup")