diff options
author | 2010-08-08 23:28:51 +0300 | |
---|---|---|
committer | 2010-08-08 23:28:51 +0300 | |
commit | 13e46b4dfd39b01121cfefd92f7c2e617ada43f9 (patch) | |
tree | 43cf600680661b818cdcec84394b65c83627f135 /utils | |
parent | Added CSS file (diff) | |
download | gsoc2010-grumpy-13e46b4dfd39b01121cfefd92f7c2e617ada43f9.tar.gz gsoc2010-grumpy-13e46b4dfd39b01121cfefd92f7c2e617ada43f9.tar.bz2 gsoc2010-grumpy-13e46b4dfd39b01121cfefd92f7c2e617ada43f9.zip |
Added preliminary version bump check plugins
Diffstat (limited to 'utils')
-rw-r--r-- | utils/version_check.py | 65 |
1 files changed, 28 insertions, 37 deletions
diff --git a/utils/version_check.py b/utils/version_check.py index 20d1caa..eac7dad 100644 --- a/utils/version_check.py +++ b/utils/version_check.py @@ -1,61 +1,52 @@ #! /usr/bin/env python import os, sys from datetime import datetime -from lxml.html import fromstring from optparse import OptionParser +from werkzeug.utils import import_string path = os.path.join(os.path.dirname(__file__), os.path.pardir) sys.path.insert(0, path) del path -from grumpy import app +from grumpy import app, vdb from grumpy.models import db, Package, PkgIssue, Setting from grumpy.utils import compare_version PLUGIN_NAME='ver_bumper::' -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 \ - .filter_by(plugin=PLUGIN_NAME) \ - .filter(PkgIssue.created_on < timestamp).delete(False)) - -def insert_issues(invalid): - """Insert QA issues into db.""" - if 'maintainer-needed@gentoo.org' in invalid: - h = Developer.query.filter_by(email='maintainer-needed@gentoo.org').first() - for pkg in h.packages: - pkg.qaissues.append(PkgIssue(pkg, PLUGIN_NAME, 'maintainer-needed')) - invalid.remove('maintainer-needed@gentoo.org') - for dev in invalid: - d = Developer.query.filter_by(email=dev).first() - for pkg in d.packages: - pkg.qaissues.append(PkgIssue(pkg, PLUGIN_NAME, 'unknown-dev', \ - 'Maintainer %s listed in metadata.xml is not as ' \ - 'an active Gentoo developer.' % dev)) - db.session.commit() - if __name__ == '__main__': - from grumpy.vdb.pypi import PyPi - parser = OptionParser(usage="usage: %prog [options] CONFFILE") + parser = OptionParser(usage="usage: %prog [options] CONFFILE module") (opts, args) = parser.parse_args() - if len(args) != 1: - parser.error("provide path to configuration file as first argument") + if len(args) != 2: + parser.error("provide path to configuration file as first argument\n" \ + "package module you want to load as second argument.\n\n" \ + "Supported modules are:\n\t%s" % \ + ('\n\t'.join(vdb.modules))) + sys.exit(1) + # Check whether module is supported + mod = args[1] + if mod not in vdb.modules: + parser.error("Unknown module: %s\n" \ + "Supported modules are:\n\t%s" % \ + (mod, '\n\t'.join(vdb.modules))) sys.exit(1) - # ... - pypi = PyPi() - items = pypi.fetch_and_parse_all() + # Import our module + m = import_string('grumpy.vdb:%s' % mod, True) + if not m: + print "Unknown error occurred: unable to import module %s" % mod + raise RuntimeError + module = m() + items = module.fetch_and_parse_all() # Gather package versions updates = {} missing = [] - for p in pypi.pkgs: - pyp = pypi.pkgs[p] + for p in module.pkgs: + pyp = module.pkgs[p] if pyp not in items.keys(): missing.append([p, pyp]) else: updates[p] = items[pyp] - PLUGIN_NAME = PLUGIN_NAME + pypi.__class__.__name__ + PLUGIN_NAME = PLUGIN_NAME + module.__class__.__name__ with app.test_request_context(): timestamp = datetime.now() app.config.from_pyfile(args[0]) @@ -75,7 +66,7 @@ if __name__ == '__main__': p.qaissues.append(PkgIssue(p, PLUGIN_NAME, \ 'missing-upstream', \ 'No package "%s" found in upstream: %s' % \ - (item, pypi.__class__.__name__))) + (item, module.__class__.__name__))) # Run version checks # TODO: Figure out slotted ebuilds for pkg, ver in updates.iteritems(): @@ -90,12 +81,12 @@ if __name__ == '__main__': p.qaissues.append(PkgIssue(p, PLUGIN_NAME, \ 'version-mismatch', 'Package "%s" has newer version in ' \ 'Portage than on "%s" upstream' % \ - (pkg, pypi.__class__.__name__))) + (pkg, module.__class__.__name__))) elif res == 1: p.qaissues.append(PkgIssue(p, PLUGIN_NAME, \ 'version-bump', 'Package "%s" has newer version "%s" ' 'available in "%s" upstream ' % \ - (pkg, p.versions[0], pypi.__class__.__name__))) + (pkg, p.versions[0], module.__class__.__name__))) db.session.commit() # Update settings and add info about last run.. Setting.query.filter_by(name=PLUGIN_NAME).delete(False) |