def do_report_local(self): ''' Create a review report on already downloaded .spec & .src.rpm''' work_dir = '%s/%s' % (os.path.abspath( os.path.expanduser(self.args.workdir)), self.args.bug) spec_filter = '%s/%s*.spec' % (work_dir, self.args.name) srpm_filter = '%s/%s*.src.rpm' % (work_dir, self.args.name) files_spec = glob.glob(spec_filter) files_srpm = glob.glob(srpm_filter) if files_spec and files_srpm: spec = files_spec[0] srpm = files_srpm[0] self.log.debug(" --> Spec file : %s" % spec) self.log.debug(" --> SRPM file : %s" % srpm) self.checks = Checks(spec, srpm) outfile = "%s/%s-review.txt" % (self.bug.work_dir, self.checks.spec.name) output = open(outfile, "w") # get upstream sources rc = self.download_sources() if not rc: self.log.info('Cannot download upstream sources') sys.exit(1) self.log.info('Running checks and generate report\n') self.checks.run_checks(output=self.args.output) output.close() else: if not files_spec: self.log.error('Cannot find : %s ' % spec_filter) if not files_srpm: self.log.error('Cannot find : %s ' % srpm_filter)
def test_all_checks(self): ''' Run all automated review checks''' print('Setup Checks') self.checks = Checks(self.spec, self.srpm, self.source) print('Running All Checks') self.checks.run_checks() for typ in ['MUST', 'SHOULD']: # Automatic Checks checks = self.checks.checks[typ] for check in checks: result = check.get_result() self.assertNotEqual(result[1:2], '!')
def do_report(self): ''' Create a review report''' self.log.info('Getting .spec and .srpm Urls from bug report : %s' % self.args.bug) # get urls rc = self.bug.find_urls() if not rc: self.log.info('Cannot find any .spec and .srpm URLs in bugreport') sys.exit(1) self.log.debug(" --> Spec url : %s" % self.bug.spec_url) self.log.debug(" --> SRPM url : %s" % self.bug.srpm_url) # get the spec and SRPM file rc = self.bug.download_files() if not rc: self.log.info('Cannot download .spec and .srpm') sys.exit(1) self.log.debug(" --> Spec file : %s" % self.bug.spec_file) self.log.debug(" --> SRPM file : %s" % self.bug.srpm_file) self.checks = Checks(self.args, self.bug.spec_file, self.bug.srpm_file, cache=self.args.cache, nobuild=self.args.nobuild) self.outfile = "%s/%s-review.txt" % (self.bug.work_dir, self.checks.spec.name) output = open(self.outfile, "w") # get upstream sources rc = self.download_sources() if self.args.nobuild: self.checks.srpm.is_build = True if not rc: self.log.info('Cannot download upstream sources') sys.exit(1) self.log.info('Running checks and generate report\n') self.checks.run_checks(output=output) output.close() self.show_results()