def run(self): retcode = 0 # if we just want to print config, do so and leave if self.options['print_config']: self.print_config() return retcode # just explain the error and abort too if self.options['explain']: self.print_explanation(self.options['explain']) return retcode # if there are installed arguments just load them up as extra # items to the rpmfile option if self.options['installed']: self.validate_installed_packages(self._load_installed_rpms(self.options['installed'])) # if no exclusive option is passed then just loop over all the # arguments that are supposed to be either rpm or spec files self.validate_files(self.options['rpmfile']) self._print_header() print(self.output.print_results(self.output.results)) quit_color = Color.Bold if self.output.printed_messages['W'] > 0: quit_color = Color.Yellow if self.output.badness_threshold > 0 and self.output.score > self.output.badness_threshold: msg = string_center(f'Badness {self.output.score} exceeeds threshold {self.output.badness_threshold}, aborting.', '-') print(f'{Color.Red}{msg}{Color.Reset}') quit_color = Color.Red retcode = 66 elif self.output.printed_messages['E'] > 0: quit_color = Color.Red retcode = 64 msg = string_center('{} packages and {} specfiles checked; {} errors, {} warnings'.format(self.packages_checked, self.specfiles_checked, self.output.printed_messages['E'], self.output.printed_messages['W']), '=') print(f'{quit_color}{msg}{Color.Reset}') return retcode
def _run(self): start = time.monotonic() retcode = 0 # if we just want to print config, do so and leave if self.options['print_config']: self.print_config() return retcode # just explain the error and abort too if self.options['explain']: self.print_explanation(self.options['explain'], self.config) return retcode # if there are installed arguments just load them up as extra # items to the rpmfile option if self.options['installed']: self.validate_installed_packages( self._load_installed_rpms(self.options['installed'])) # if no exclusive option is passed then just loop over all the # arguments that are supposed to be either rpm or spec files self.validate_files(self.options['rpmfile']) self._print_header() print(self.output.print_results(self.output.results, self.config), end='') quit_color = Color.Bold if self.output.printed_messages['W'] > 0: quit_color = Color.Yellow if self.output.badness_threshold > 0 and self.output.score > self.output.badness_threshold: msg = string_center( f'Badness {self.output.score} exceeds threshold {self.output.badness_threshold}, aborting.', '-') print(f'{Color.Red}{msg}{Color.Reset}') quit_color = Color.Red retcode = 66 elif self.output.printed_messages[ 'E'] > 0 and not self.config.permissive: quit_color = Color.Red all_promoted = self.output.printed_messages[ 'E'] == self.output.promoted_to_error retcode = 65 if all_promoted else 64 self._maybe_print_reports() duration = time.monotonic() - start msg = string_center( f'{self.packages_checked} packages and {self.specfiles_checked} specfiles checked; ' f'{self.output.printed_messages["E"]} errors, {self.output.printed_messages["W"]} warnings, ' f'{self.output.score} badness; has taken {duration:.1f} s', '=') print(f'{quit_color}{msg}{Color.Reset}') return retcode
def _print_header(self): """ Print out header information about the state of the rpmlint prior printing out the check report. """ intro = string_center('rpmlint session starts', '=') print(f'{Color.Bold}{intro}{Color.Reset}') print(f'rpmlint: {__version__}') print('configuration:') for config in self.config.conf_files: print(f' {config}') if self.options['rpmlintrc']: rpmlintrc = self.options['rpmlintrc'] print(f'rpmlintrc: {rpmlintrc}') no_checks = len(self.config.configuration['Checks']) no_pkgs = len(self.options['installed']) + len(self.options['rpmfile']) print(f'{Color.Bold}checks: {no_checks}, packages: {no_pkgs}{Color.Reset}') print('')