def check_properties(self, props, addMessage):
     #TODO: Add directories/files right checks
     if props.has_key("config"):
         if props.has_key("diagnose"):
             msg = ("Component properties 'config' "
                    + "and 'diagnose' should not be "
                    + "specified at the same time")
             raise TranscoderConfigError(msg)
         local = Local.createFromComponentProperties(props)
         configPath = VirtualPath(props["config"])
         localConfigPath = configPath.localize(local)
         if not os.path.exists(localConfigPath):
             msg = "Config file not found ('%s')" % localConfigPath
             raise TranscoderConfigError(msg)
     elif props.has_key("diagnose"):
         localReportPath = props["diagnose"]
         if not os.path.exists(localReportPath):
             msg = "Report file not found ('%s')" % localReportPath
             raise TranscoderConfigError(msg)
     else:
         msg = ("One of the component properties "
                + "'config' and 'diagnose' "
                + "should be specified")
         raise TranscoderConfigError(msg)
     if props.has_key("report"):
         localRealPath = os.path.realpath(props["report"])
         localReportDir = os.path.dirname(localRealPath)
         if not os.path.exists(localReportDir):
             msg = "Output report directory not found ('%s')" % localReportDir
             raise TranscoderConfigError(msg)
 def addFile(self, work, output):
     if len(self.report.workFiles) != len(self.report.outputFiles):
         raise Exception("Report's file list invalid")
     virtWork = VirtualPath.virtualize(work, self.local)
     virtOutput = VirtualPath.virtualize(output, self.local)
     self.report.workFiles.append(virtWork)
     self.report.outputFiles.append(virtOutput)
 def init(self, context):
     sourceCtx = context.getSourceContext()
     self.setCurrentPath(sourceCtx.getInputPath())
     self.report.local.loadFromLocal(context.local)
     virtInput = VirtualPath.virtualize(sourceCtx.getInputPath(), self.local)
     virtDone = VirtualPath.virtualize(sourceCtx.getDoneInputPath(), self.local)
     virtFailed = VirtualPath.virtualize(sourceCtx.getFailedInputPath(), self.local)
     self.report.source.inputPath = virtInput
     self.report.source.donePath = virtDone
     self.report.source.failedPath = virtFailed
 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
    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")
 def _fireTranscodingReport(self, reportPath):
     virtPath = VirtualPath.virtualize(reportPath, self._local)
     self.uiState.setitem('job-data', "transcoding-report", virtPath)
 def _getReportPath(self):
     if self._reportDefaultPath:
         virtPath = VirtualPath.virtualize(self._reportDefaultPath,
                                           self._local)
         return virtPath
     return None
 def onSourceInfo(self, info):
     inputFile = info["input-file"]
     virtFile = VirtualPath.virtualize(inputFile, self._local)
     info["input-file"] = str(virtFile)
     for key, value in info.iteritems():
         self.uiState.setitem('source-data', key, value)
 def setCurrentPath(self, path):
     self.report.source.lastPath = VirtualPath.virtualize(path, self.local)