def log_details(text, spacing, max_len): text = utils.truncate_text(text, max_len=max_len, from_bottom=True) for line in text.splitlines(): line = line.replace("\t", "\\t") line = line.replace("\r", "\\r") line = utils.truncate_text(line, max_len=120) LOG.info("%s>> %s", (" " * spacing), line)
def run_tests(self): app_dir = self.get_option('app_dir') if not sh.isdir(app_dir): LOG.warn("Unable to find application directory at %s, can not run %s tests.", colorizer.quote(app_dir), colorizer.quote(self.name)) return pre_cmd = self._get_pre_test_command() cmd = self._get_test_command() if not cmd: LOG.warn("Unable to determine test command for %s, can not run tests.", colorizer.quote(self.name)) return env = self._get_env() try: if pre_cmd: LOG.info("Running test setup via: %s", utils.truncate_text(" ".join(pre_cmd), 80)) sh.execute(pre_cmd, stdout_fh=sys.stdout, stderr_fh=sys.stdout, cwd=app_dir, env_overrides=env) LOG.info("Running tests via: %s", utils.truncate_text(" ".join(cmd), 80)) sh.execute(cmd, stdout_fh=sys.stdout, stderr_fh=sys.stdout, cwd=app_dir, env_overrides=env) except excp.ProcessExecutionError as e: if self.ignore_test_failures: LOG.warn("Ignoring test failure of component %s: %s", colorizer.quote(self.name), e) else: raise
def details_printer(entry, spacing, max_len): det = utils.truncate_text(entry.details, max_len=max_len, from_bottom=True) for line in det.splitlines(): line = line.replace("\t", "\\t") line = line.replace("\r", "\\r") line = utils.truncate_text(line, max_len=120) LOG.info("%s>> %s", (" " * spacing), line)
def details(self): base = super(PythonPackager, self).details if self._extended_details is None: ext_dets = { 'automatic_dependencies': False, } setup_cmd = ['python', self._setup_fn] replacements = { 'version': '--version', 'license': '--license', 'name': '--name', 'vendor': '--author', 'url': '--url', } for (key, opt) in replacements.items(): cmd = setup_cmd + [opt] (stdout, _stderr) = sh.execute(*cmd, run_as_root=True, cwd=self.get_option('app_dir')) stdout = stdout.strip() if stdout: ext_dets[key] = stdout description = self._description() if description: ext_dets['description'] = "\n".join(description) ext_dets['summary'] = utils.truncate_text("\n".join(description[0:1]), 50) ext_dets['changelog'] = self._build_changelog() self._extended_details = ext_dets extended_dets = dict(base) extended_dets.update(self._extended_details) return extended_dets
def details(self): base = super(PythonPackager, self).details if self._extended_details is None: ext_dets = {"automatic_dependencies": False} setup_cmd = ["python", self._setup_fn] replacements = {"version": "--version", "license": "--license", "vendor": "--author", "url": "--url"} # only replace name if it isn't set in the component config file if self.get_option("rpm_package_name") is None: replacements["name"] = "--name" for (key, opt) in replacements.items(): cmd = setup_cmd + [opt] (stdout, _stderr) = sh.execute(*cmd, run_as_root=True, cwd=self.get_option("app_dir")) stdout = stdout.strip() if stdout: ext_dets[key] = stdout description = self._description() if description: ext_dets["description"] = "\n".join(description) ext_dets["summary"] = utils.truncate_text("\n".join(description[0:1]), 50) ext_dets["changelog"] = self._build_changelog() self._extended_details = ext_dets extended_dets = dict(base) extended_dets.update(self._extended_details) return extended_dets