diff options
author | 2010-07-09 16:20:09 +0300 | |
---|---|---|
committer | 2010-07-09 20:39:48 +0300 | |
commit | 1c0631291d227c2923516c81fe474732c5c708f7 (patch) | |
tree | af05d7f7b1da3304d3129bdd521f74a39d7849c9 /utils/qa_check_herd.py | |
parent | Added configuration file handling (diff) | |
download | gsoc2010-grumpy-1c0631291d227c2923516c81fe474732c5c708f7.tar.gz gsoc2010-grumpy-1c0631291d227c2923516c81fe474732c5c708f7.tar.bz2 gsoc2010-grumpy-1c0631291d227c2923516c81fe474732c5c708f7.zip |
Update herd and active developer plugins
Diffstat (limited to 'utils/qa_check_herd.py')
-rw-r--r-- | utils/qa_check_herd.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/utils/qa_check_herd.py b/utils/qa_check_herd.py index 21c5ead..7088d5a 100644 --- a/utils/qa_check_herd.py +++ b/utils/qa_check_herd.py @@ -1,8 +1,10 @@ #! /usr/bin/env python import os, sys +import urllib2 from datetime import datetime -from lxml.etree import parse +from lxml.etree import fromstring +from optparse import OptionParser path = os.path.join(os.path.dirname(__file__), os.path.pardir) sys.path.insert(0, path) @@ -11,6 +13,7 @@ del path from grumpy import app from grumpy.models import db, Herd, PkgIssue, Setting +HERDS_URL = 'http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo/xml/htdocs/proj/en/metastructure/herds/herds.xml' PLUGIN_NAME='qa::valid_herd' def gc_collect(timestamp): @@ -45,26 +48,29 @@ def insert_issues(invalid): 'Herd %s is not listed in official herd list.' % herd)) db.session.commit() -def parse_herds_xml(file): +def download_and_parse_herds(): """Return list of herd names from 'herds.xml'""" + data = urllib2.urlopen(HERDS_URL) herds = [] - if not os.path.isfile(file): - print ("File '%s' does not exist" % file) - raise RuntimeError - for child in parse(file).getroot().getchildren(): + for child in fromstring(data.read()).getchildren(): for value in child.getchildren(): if value.tag == 'name': herds.append(value.text) return herds if __name__ == '__main__': - # TODO: Download latest herds file - # Parse list of herds from file - herds = parse_herds_xml('herds.xml') + parser = OptionParser(usage="usage: %prog [options] CONFFILE") + (opts, args) = parser.parse_args() + if len(args) != 1: + parser.error("provide path to configuration file as first argument") + sys.exit(1) + # Fetch data and parse it + herds = download_and_parse_herds() b0rks = [] timestamp = datetime.now() - # Setup database for application with app.test_request_context(): + # Load configuration + app.config.from_pyfile(args[0]) # Fetch list of herds from db for herd in Herd.query.all(): if herd.name in herds: |