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 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: properties = self.config['properties'] self._local = Local.createFromComponentProperties(properties) self._pathAttr = PathAttributes.createFromComponentProperties(properties) for s in properties.get("named-profile", []): profile, path, active = s.split('!') vpath = VirtualPath(path) active = bool(int(active)) self.profiles_virtualbase[profile] = vpath self.uiState.setitem('virtbase-map', profile, str(vpath)) self.uiState.append('monitored-profiles', profile) if active: self.active_profiles.append(profile) self.uiState.append('active-profiles', profile) else: self.http_profiles.append(profile) self.uiState.append('http-profiles', profile) except: return fail(self._unexpected_error(task="component setup"))