diff options
author | 2010-07-31 16:51:33 +0300 | |
---|---|---|
committer | 2010-07-31 16:51:33 +0300 | |
commit | 2eeb2da75c4f782d01fdec3f4a27eb142e2f3f70 (patch) | |
tree | 3ea1670260d871b8160e7fd79d42c6d20d47b77b /utils/qa_check_herd.py | |
parent | Add sync method to Ebuild class (diff) | |
download | gsoc2010-grumpy-2eeb2da75c4f782d01fdec3f4a27eb142e2f3f70.tar.gz gsoc2010-grumpy-2eeb2da75c4f782d01fdec3f4a27eb142e2f3f70.tar.bz2 gsoc2010-grumpy-2eeb2da75c4f782d01fdec3f4a27eb142e2f3f70.zip |
Use transactions in herd check plugin
Diffstat (limited to 'utils/qa_check_herd.py')
-rw-r--r-- | utils/qa_check_herd.py | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/utils/qa_check_herd.py b/utils/qa_check_herd.py index 7088d5a..b8bdf5f 100644 --- a/utils/qa_check_herd.py +++ b/utils/qa_check_herd.py @@ -19,34 +19,34 @@ PLUGIN_NAME='qa::valid_herd' def gc_collect(timestamp): """Remove old QA issues from database returning number of rows deleted.""" db.session.expire_all() - print ("DEBUG: Deleted %d old issues." % PkgIssue.query \ + print ("DEBUG: Deleted %d resolved (?) issues." % PkgIssue.query \ .filter_by(plugin=PLUGIN_NAME) \ .filter(PkgIssue.created_on < timestamp).delete(False)) -def insert_issues(invalid): +def update_issues(invalid): """Insert QA issues into db.""" - if 'maintainer-needed' in invalid: - h = Herd.query.filter_by(name='maintainer-needed').first() - for pkg in h.packages: - pkg.qaissues.append(PkgIssue(pkg, PLUGIN_NAME, 'maintainer-needed')) - invalid.remove('maintainer-needed') - if 'no-herd' in invalid: - h = Herd.query.filter_by(name='no-herd').first() - for pkg in h.packages: - pkg.qaissues.append(PkgIssue(pkg, PLUGIN_NAME, 'maintainer-needed')) - invalid.remove('no-herd') - if 'fix-me' in invalid: - h = Herd.query.filter_by(name='fix-me').first() - for pkg in h.packages: - pkg.qaissues.append(PkgIssue(pkg, PLUGIN_NAME, 'invalid-herd', \ - 'Please use no-herd instead of empty tag')) - invalid.remove('fix-me') + cases = {'maintainer-needed': 'Package is looking for maintainer-herd', + 'no-herd': 'Package is missing herd', + 'fix-me' : 'Package should use "no-herd" instead of empty "herd" tag', + 'invalid-herd' : 'Herd %s is not listed in official herd list' + } for herd in invalid: - h = Herd.query.filter_by(name=herd).first() - for pkg in h.packages: - pkg.qaissues.append(PkgIssue(pkg, PLUGIN_NAME, 'unknown-herd', \ - 'Herd %s is not listed in official herd list.' % herd)) - db.session.commit() + issue = herd + if herd not in cases.keys(): + issue = 'invalid-herd' + data = cases[issue] % herd + else: + data = cases[herd] + try: + # Clean up old issues + PkgIssue.query.filter_by(plugin=PLUGIN_NAME,type=herd).delete(False) + for pkg in Herd.query.filter_by(name=herd).first().packages: + pkg.qaissues.append(PkgIssue(pkg, PLUGIN_NAME, issue, data)) + db.session.commit() + except Exception: + db.session.rollback() + print "Invalid error occurred!" + raise RuntimeError def download_and_parse_herds(): """Return list of herd names from 'herds.xml'""" @@ -77,7 +77,7 @@ if __name__ == '__main__': herds.remove(herd.name) else: b0rks.append(herd.name) - insert_issues(b0rks) + update_issues(b0rks) # Clean up issues < timestamp gc_collect(timestamp) # Update settings and add info about last run.. |