Changeset 9d001db0a579a4224338ea1ec905a4603dadd635

Show
Ignore:
Timestamp:
06/25/08 19:35:14 (7 months ago)
Author:
Jonny Lamb <jonnylamb@…>
Parents:
095675ba471b43d0a8fa08f604b71504f76810a7
Children:
225a4625840e9adbbce4cecf55a0f5d453129fd8
git-committer:
Jonny Lamb <jonnylamb@jonnylamb.com> / 2008-06-25T18:35:14Z+0100
Message:

Changed API of plugins to provide an outcomes dictionary and use tags.

Signed-off-by: Jonny Lamb <jonnylamb@…>

Location:
debexpo
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • debexpo/lib/plugins.py

    r095675 r9d001d  
    148148 
    149149            if hasattr(module, 'plugin'): 
    150                 p = getattr(module, 'plugin')(changes=self.changes, \ 
     150                p = getattr(module, 'plugin')(name=plugin, changes=self.changes, \ 
    151151                    changes_file=self.changes_file, tempdir=self.tempdir, 
    152152                    user_id=self.user_id) 
  • debexpo/plugins/__init__.py

    r325bed r9d001d  
    6565        return self.result 
    6666 
    67     def passed(self, name, data, severity): 
     67    def passed(self, outcome, data, severity): 
    6868        """ 
    6969        Adds a PluginResult for a passed test to the result list. 
    7070 
    71         ``name`` 
    72             Name of the plugin. 
     71        ``outcome`` 
     72            Outcome tag of the test. 
    7373 
    7474        ``data`` 
     
    7878            Severity of the result. 
    7979        """ 
    80         self.result.append(PluginResult(from_plugin=name, outcome=constants.PLUGIN_OUTCOME_PASSED, 
     80        self.result.append(PluginResult(from_plugin=self.name, outcome=outcome, 
    8181            data=data, severity=severity)) 
    8282 
    83     def failed(self, name, data, severity): 
     83    def failed(self, outcome, data, severity): 
    8484        """ 
    8585        Adds a PluginResult for a failed test to the result list. 
    8686 
    87         ``name`` 
    88             Name of the plugin. 
     87        ``outcome`` 
     88            Outcome tag of the test. 
    8989 
    9090        ``data`` 
     
    9595 
    9696        """ 
    97         self.result.append(PluginResult(from_plugin=name, outcome=constants.PLUGIN_OUTCOME_FAILED, 
     97        self.result.append(PluginResult(from_plugin=self.name, outcome=outcome, 
    9898            data=data, severity=severity)) 
    9999 
    100     def info(self, name, data): 
     100    def info(self, outcome, data): 
    101101        """ 
    102102        Adds a PluginResult for an info test to the result list. 
    103103 
    104         ``name`` 
    105             Name of the plugin. 
     104        ``outcome`` 
     105            Outcome tag of the test. 
    106106 
    107107        ``data`` 
    108108            Resulting data from the plugin, like more detail about the process. 
    109109        """ 
    110         self.result.append(PluginResult(from_plugin=name, outcome=constants.PLUGIN_OUTCOME_INFO, 
     110        self.result.append(PluginResult(from_plugin=self.name, outcome=outcome, 
    111111            data=data, severity=constants.PLUGIN_SEVERITY_INFO)) 
    112112 
     
    141141        Returns whether the test failed. 
    142142        """ 
    143         return self.outcome == constants.PLUGIN_OUTCOME_FAILED 
     143        return self.severity > constants.PLUGIN_SEVERITY_INFO 
    144144 
    145145    def stop(self): 
  • debexpo/plugins/checkfiles.py

    r095675 r9d001d  
    5858            sum = md5sum(os.path.join(config['debexpo.upload.incoming'], file['name'])) 
    5959 
    60             data = 'Changes file says md5sum is: %s\n' % file['md5sum'] 
    61             data += 'Actual md5sum of file is: %s' % sum 
     60            data = 'Changes file says md5sum of %s is: %s\n' % (file['name'], file['md5sum']) 
     61            data += 'Actual md5sum of %s is: %s' % (file['name'], sum) 
    6262 
    6363            if sum != file['md5sum']: 
    64                 log.error('%s != %s; test failed' % (sum, file['md5sum'])) 
    65                 self.failed(__name__, data, constants.PLUGIN_SEVERITY_ERROR) 
     64                log.error('%s != %s' % (sum, file['md5sum'])) 
     65                self.failed('md5sum-not-match', data, constants.PLUGIN_SEVERITY_ERROR) 
    6666            else: 
    6767                log.debug('Test passed') 
    68                 self.passed(__name__, data, constants.PLUGIN_SEVERITY_INFO) 
     68                self.passed('md5sum-match', None, constants.PLUGIN_SEVERITY_INFO) 
    6969 
    7070plugin = CheckFilesPlugin 
     71 
     72outcomes = { 
     73    'md5sum-not-match' : { 'name' : 'A package source file\'s md5sum does match its changes value' }, 
     74    'md5sum-match' : { 'name' : 'A package source file\'s md5sum matches its changes value' }, 
     75} 
  • debexpo/plugins/closedbugs.py

    r095675 r9d001d  
    7777                if self._package_in_descriptions(name, binary_packages): 
    7878                    log.debug('Bug #%s belongs to this package' % bug) 
    79                     self.passed(__name__, 'Bug #%s belongs to this package', constants.PLUGIN_SEVERITY_INFO) 
     79                    self.passed('bug-in-package', None, constants.PLUGIN_SEVERITY_INFO) 
    8080                else: 
    8181                    log.error('Bug #%s does not belong to this package' % bug) 
    82                     self.failed(__name__, 'Bug #%s does not belong to this package', constants.PLUGIN_SEVERITY_ERROR) 
     82                    self.failed('bug-not-in-package', bug, constants.PLUGIN_SEVERITY_ERROR) 
    8383 
    8484        except KeyError: 
     
    103103 
    104104plugin = ClosedBugsPlugin 
     105 
     106outcomes = { 
     107    'bug-not-in-package' : { 'name' : 'A bug closed in this package doesn\'t belong to this package' }, 
     108    'bug-in-package' : { 'name' : 'A bug closed in this package belongs to this package' }, 
     109} 
  • debexpo/plugins/controlfields.py

    r095675 r9d001d  
    4545log = logging.getLogger(__name__) 
    4646 
     47fields = ['Homepage', 'Vcs-Browser', 'Vcs-Git', 'Vcs-Svn', 'Vcs-Bzr', 'Vcs-Hg'] 
     48 
     49def _gen_outcomes(): 
     50    outcomes = {} 
     51 
     52    for field in fields: 
     53        for isisnot in ['', '-not']: 
     54            outcomes['%s-is%s-present' % (field.lower(), isisnot)] = \ 
     55                'The %s field is%s present in debian/control' % (field, isisnot.replace('-', ' ')) 
     56 
     57    return outcomes 
     58 
    4759class ControlFieldsPlugin(BasePlugin): 
    4860    tests = ['check_control_fields'] 
     
    6072            return 
    6173 
    62         for item in ['Homepage', 'Vcs-Browser', 'Vcs-Git', 'Vcs-Svn', 'Vcs-Bzr', 'Vcs-Hg']: 
    63  
    64             try: 
    65                 self.info(__name__, '%s field is present: %s' % (item, dsc[item])) 
    66                 log.debug('%s field is present: %s' % (item, dsc[item])) 
    67             except KeyError: 
     74        for item in fields: 
     75            if item in dsc: 
     76                self.info('%s-is-present' % item.lower(), '%s: %s' % (item, dsc[item])) 
     77                log.debug('%s: %s' % (item, dsc[item])) 
     78            else: 
     79                self.info('%s-is-not-present' % item.lower(), item) 
    6880                log.debug('%s field is not present' % item) 
    6981 
    7082plugin = ControlFieldsPlugin 
     83 
     84outcomes = _gen_outcomes() 
  • debexpo/plugins/diffclean.py

    r095675 r9d001d  
    6060            return 
    6161 
    62         diffstat = commands.getoutput('diffstat -p1 -l %s' % difffile) 
     62        diffstat = commands.getoutput('diffstat -p1 %s' % difffile) 
    6363 
    6464        dirty = False 
    6565        for item in diffstat.split('\n'): 
    66             if not item.startswith('debian/'): 
     66            if not item.startswith(' debian/'): 
    6767                dirty = True 
    6868                break 
     
    7070        if not dirty: 
    7171            log.debug('Diff file %s is clean' % difffile) 
    72             self.passed(__name__, 'Diff file %s is clean' % difffile, constants.PLUGIN_SEVERITY_INFO) 
     72            self.passed('diff-clean', None, constants.PLUGIN_SEVERITY_INFO) 
    7373        else: 
    7474            log.error('Diff file %s is not clean' % difffile) 
    75             self.failed(__name__, 'Diff file %s is not clean' % difffile, constants.PLUGIN_SEVERITY_ERROR) 
     75            self.failed('diff-dirty', diffstat, constants.PLUGIN_SEVERITY_ERROR) 
    7676 
    7777plugin = DiffCleanPlugin 
     78 
     79outcomes = { 
     80    'diff-clean' : { 'name' : 'The diff.gz file is clean' }, 
     81    'diff-dirty' : { 'name' : 'The diff.gz file is dirty' }, 
     82} 
  • debexpo/plugins/gpgsigned.py

    r095675 r9d001d  
    6666            if contents.startswith('-----BEGIN PGP SIGNED MESSAGE-----'): 
    6767                log.debug('File %s is GPG signed' % filename) 
    68                 self.passed(__name__, 'File %s is GPG signed' % filename, constants.PLUGIN_SEVERITY_INFO) 
     68                self.passed('gpg-signed', filename, constants.PLUGIN_SEVERITY_INFO) 
    6969            else: 
    7070                log.error('File %s is not GPG signed' % filename) 
    71                 self.failed(__name__, 'File %s is not GPG signed' % filename, constants.PLUGIN_SEVERITY_ERROR) 
     71                self.failed('not-gpg-signed', filename, constants.PLUGIN_SEVERITY_ERROR) 
    7272 
    7373plugin = GpgSignedPlugin 
     74 
     75outcomes = { 
     76    'gpg-signed' : { 'name' : 'A file is GPG signed' }, 
     77    'not-gpg-signed' : { 'name' : 'A file is not GPG signed, and it should be' }, 
     78} 
  • debexpo/plugins/lintian.py

    r095675 r9d001d  
    6161        if items and output != '': 
    6262            severity = constants.PLUGIN_SEVERITY_WARNING 
     63            outcome = 'lintian-warnings' 
    6364            logmessage = log.warning 
    6465            for item in items: 
    6566                if item.startswith('E:'): 
    6667                    severity = constants.PLUGIN_SEVERITY_ERROR 
     68                    outcome = 'lintian-errors' 
    6769                    logmessage = log.error 
    6870                    break 
    6971 
    70             output = 'Package is not Lintian clean\n' + output 
    7172            logmessage('Package is not Lintian clean') 
    72             self.failed(__name__, output, severity) 
     73            self.failed(outcome, output, severity) 
    7374        else: 
    7475            log.debug('Package is Lintian clean') 
    75             self.passed(__name__, 'Package is Lintian clean', constants.PLUGIN_SEVERITY_INFO) 
     76            self.passed('lintian-clean', None, constants.PLUGIN_SEVERITY_INFO) 
    7677 
    7778plugin = LintianPlugin 
     79 
     80outcomes = { 
     81    'lintian-clean' : { 'name' : 'Package is Lintian clean' }, 
     82    'lintian-warnings' : { 'name' : 'Package has Lintian warnings' }, 
     83    'lintian-errors' : { 'name' : 'Package has Lintian errors' }, 
     84} 
  • debexpo/plugins/maintaineremail.py

    r095675 r9d001d  
    6666                if user.email == email[1:-1]: 
    6767                    log.debug('Maintainer email is the same as the uploader') 
    68                     self.passed(__name__, 'Maintainer email is the same as the uploader', constants.PLUGIN_SEVERITY_INFO) 
     68                    self.passed('maintainer-is-uploader', None, constants.PLUGIN_SEVERITY_INFO) 
    6969                else: 
    7070                    log.warning('%s != %s' % (user.email, email[1:-1])) 
    71                     self.failed(__name__, 'Changes file is not GPG signed', constants.PLUGIN_SEVERITY_WARNING) 
     71                    self.failed('maintainer-is-not-uploader', '%s != %s' % (user.email, email[1:-1]), 
     72                        constants.PLUGIN_SEVERITY_WARNING) 
    7273 
    73         log.warning('Could not get the uploader\'s user details from the database') 
     74        else: 
     75            log.warning('Could not get the uploader\'s user details from the database') 
    7476 
    7577plugin = MaintainerEmailPlugin 
     78 
     79outcomes = { 
     80    'maintainer-is-uploader' : { 'name' : 'The maintainer and uploader emails are the same' }, 
     81    'maintainer-is-not-uploader' : { 'name' : 'The maintainer and uploader emails are not the same' }, 
     82} 
  • debexpo/plugins/native.py

    r095675 r9d001d  
    6262            # package is almost probably in error. 
    6363            log.warning('Package is native') 
    64             self.failed(__name__, 'Package is native', constants.PLUGIN_SEVERITY_WARNING) 
     64            self.failed('is-native', None, constants.PLUGIN_SEVERITY_WARNING) 
    6565        else: 
    6666            log.debug('Package is not native') 
    67             self.passed(__name__, 'Package is not native', constants.PLUGIN_SEVERITY_INFO) 
     67            self.passed('is-not-native', None, constants.PLUGIN_SEVERITY_INFO) 
    6868 
    6969plugin = NativePlugin 
     70 
     71outcomes = { 
     72    'is-native' : { 'name' : 'Package is native' }, 
     73    'is-not-native' : { 'name' : 'Package is not native' }, 
     74} 
  • debexpo/plugins/watchfile.py

    r095675 r9d001d  
    7070        if self._watch_file_present(): 
    7171            log.debug('Watch file present') 
    72             self.passed(__name__, 'debian/watch file exists', constants.PLUGIN_SEVERITY_INFO) 
     72            self.passed('watch-file-present', None, constants.PLUGIN_SEVERITY_INFO) 
    7373        else: 
    7474            log.warning('Watch file not present') 
    75             self.failed(__name__, 'debian/watch does not exist', constants.PLUGIN_SEVERITY_WARNING) 
     75            self.failed('watch-file-not-present', None, constants.PLUGIN_SEVERITY_WARNING) 
    7676 
    7777    def check_watch_file_works(self): 
     
    8484        if self._watch_file_works(): 
    8585            log.debug('Watch file works') 
    86             self.passed(__name__, 'debian/watch file works', constants.PLUGIN_SEVERITY_INFO) 
     86            self.passed('watch-file-works', None, constants.PLUGIN_SEVERITY_INFO) 
    8787        else: 
    8888            log.warning('Watch file does not work') 
    89             self.failed(__name__, 'debian/watch file does not work\n' + self.output, constants.PLUGIN_SEVERITY_WARNING) 
     89            self.failed('watch-file-does-not-work', self.output, constants.PLUGIN_SEVERITY_WARNING) 
    9090 
    9191    def check_new_upstream(self): 
     
    9999        if self.status == 256: 
    100100            log.debug('Package is the latest upstream version') 
    101             self.passed(__name__, 'Package is the latest upstream version', constants.PLUGIN_SEVERITY_INFO) 
     101            self.passed('no-new-upstream-version', None, constants.PLUGIN_SEVERITY_INFO) 
    102102        else: 
    103103            log.warning('Package is not the latest upstream version') 
    104             self.failed(__name__, 'Package is not the latest upstream version\n' + self.output, constants.PLUGIN_SEVERITY_WARNING) 
     104            self.failed('new-upstream-available', self.output, constants.PLUGIN_SEVERITY_WARNING) 
    105105 
    106106plugin = WatchFilePlugin 
     107 
     108outcomes = { 
     109    'watch-file-present' : { 'name' : 'A watch file is present' }, 
     110    'watch-file-not-present' : { 'name' : 'A watch file is not present' }, 
     111    'watch-file-works' : { 'name' : 'The watch file works' }, 
     112    'watch-file-does-not-work' : { 'name' : 'The watch file does not work' }, 
     113    'new-upstream-available' : { 'name' : 'A new upstream version is available' }, 
     114    'no-new-upstream-available' : { 'name' : 'Package is the latest upstream version' }, 
     115}