From: <re...@us...> - 2006-10-07 22:58:31
|
Revision: 6154 http://svn.sourceforge.net/openhpi/?rev=6154&view=rev Author: renierm Date: 2006-10-07 15:58:18 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Chaning web scripts. Need an additional one to post sf tracker data to wiki, automagically. Modified Paths: -------------- www/trunk/htdocs/Makefile www/trunk/htdocs/index.html www/trunk/htdocs/tracker/Makefile www/trunk/htdocs/tracker/sf2changelog.py www/trunk/htdocs/tracker/sfexport2.py Added Paths: ----------- www/trunk/htdocs/tracker/post2wiki.py www/trunk/htdocs/tracker/sf2wiki.py Removed Paths: ------------- www/trunk/htdocs/tracker/sf2html.py Modified: www/trunk/htdocs/Makefile =================================================================== --- www/trunk/htdocs/Makefile 2006-10-06 18:54:12 UTC (rev 6153) +++ www/trunk/htdocs/Makefile 2006-10-07 22:58:18 UTC (rev 6154) @@ -2,7 +2,7 @@ # TDIR=tracker -TPROG=sf2html.py +TPROG=sf2wiki.py SDIR=status SDATA=$(shell ls -d $(SDIR)/raw/* | grep -v .svn) Modified: www/trunk/htdocs/index.html =================================================================== --- www/trunk/htdocs/index.html 2006-10-06 18:54:12 UTC (rev 6153) +++ www/trunk/htdocs/index.html 2006-10-07 22:58:18 UTC (rev 6154) @@ -1,11 +1,11 @@ <html> <head> -<meta http-equiv="refresh" content="5;URL=http://wiki.openhpi.org"> +<meta http-equiv="refresh" content="5;URL=http://www.openhpi.org"> <title>OpenHPI has moved!</title> </head> <body> <p> -The OpenHPI website has moved to <a href="http://wiki.openhpi.org">http://wiki.openhpi.org</a> +The OpenHPI website has moved to <a href="http://www.openhpi.org">http://www.openhpi.org</a> </p> <p> Please, update your bookmarks. Modified: www/trunk/htdocs/tracker/Makefile =================================================================== --- www/trunk/htdocs/tracker/Makefile 2006-10-06 18:54:12 UTC (rev 6153) +++ www/trunk/htdocs/tracker/Makefile 2006-10-07 22:58:18 UTC (rev 6154) @@ -2,7 +2,7 @@ all: - ./sf2html.py + ./sf2wiki.py pull: ./sfexport.py Added: www/trunk/htdocs/tracker/post2wiki.py =================================================================== --- www/trunk/htdocs/tracker/post2wiki.py (rev 0) +++ www/trunk/htdocs/tracker/post2wiki.py 2006-10-07 22:58:18 UTC (rev 6154) @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# +# (C) Copyright IBM Corp. 2006 +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This +# file and program are licensed under a BSD style license. See +# the Copying file included with the OpenHPI distribution for +# full licensing terms. +# +""" +Get parsed data from SourceForge tracker in wiki format. Then, post that +to the wiki on http://www.openhpi.org/Status/OpenhpiBugsFeatures + +Author(s): + Renier Morales <re...@op...> +""" +import sys, time +from subprocess import Popen, PIPE +from mechanize import Browser +from optparse import OptionParser +from getpass import getpass + +optsparser = OptionParser(usage='%prog [options] <release>') +optsparser.add_option('-f', + '--xmlfile', + default='xml_export.xml', + dest='xmlfile', + help='Read tracker data from this file ' + '[default: %default]') +optsparser.add_option('-u', + '--username', + default=None, + dest='user', + help='User name') +optsparser.add_option('-p', + '--password', + default=None, + dest='password', + help='Password') +options, args = optsparser.parse_args() +if len(args) != 1: + print 'Did not get a release level (e.g. %s 2.6.0).' % sys.argv[0] + optsparser.print_help() + sys.exit() + +z = 1 +# Capture wiki tracker data +print 'Capturing wiki data...' +popen = Popen('./sf2wiki.py -f %s %s' % (options.xmlfile, args[0]), + shell=True, + stdout=PIPE) +popen.wait() +wikidata = popen.stdout.read() + +# Post it +br = Browser() +br.clear_history() +br.set_handle_robots(False) # don't pay attention to robots.txt +print 'Going to wiki...' +response = br.open('http://www.openhpi.org/Status/OpenhpiBugsFeatures?action=login') +br.select_form(nr=2) # The form we want is the third one +br['name'] = options.user or raw_input('Enter your username: ') +br['password'] = options.password or getpass('Enter password for \'%s\': ' % + br['name']) +print 'Loggin in...' +time.sleep(z) # Be nice to the website +response = br.submit() +time.sleep(z) +print 'Editing page...' +response = br.follow_link(url_regex='editor=text') +br.select_form(nr=0) +br['savetext'] = wikidata +time.sleep(z) +print 'Saving page...' +response = br.submit() +print 'Done.' + Property changes on: www/trunk/htdocs/tracker/post2wiki.py ___________________________________________________________________ Name: svn:executable + * Modified: www/trunk/htdocs/tracker/sf2changelog.py =================================================================== --- www/trunk/htdocs/tracker/sf2changelog.py 2006-10-06 18:54:12 UTC (rev 6153) +++ www/trunk/htdocs/tracker/sf2changelog.py 2006-10-07 22:58:18 UTC (rev 6154) @@ -25,7 +25,7 @@ optsparser.add_option('-w', '--web', dest='web', - help='Produce html output instead of plain text', + help='Produce wiki output instead of plain text', action='store_true', default=False) optsparser.add_option('-f', Deleted: www/trunk/htdocs/tracker/sf2html.py =================================================================== --- www/trunk/htdocs/tracker/sf2html.py 2006-10-06 18:54:12 UTC (rev 6153) +++ www/trunk/htdocs/tracker/sf2html.py 2006-10-07 22:58:18 UTC (rev 6154) @@ -1,86 +0,0 @@ -#!/usr/bin/env python -# -# (C) Copyright IBM Corp. 2006 -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This -# file and program are licensed under a BSD style license. See -# the Copying file included with the OpenHPI distribution for -# full licensing terms. -# -""" -This will parse the SF XML export file and generate a table -showing the status of bugs and feature per release in html. - -Author(s): - Renier Morales <re...@us...> -""" -from optparse import OptionParser -from xml.sax import make_parser, handler, SAXException -import sfparser - -# List of releases to go in the html report -releases = ['2.7.0'] -# Parse options -optsparser = OptionParser(usage='%prog [options] [release [release ...]]') -optsparser.add_option('-f', '--xmlfile', - dest='xmlfile', - metavar='XMLEXPORTFILE', - help='XML file which contains the SF exported data [default: %default]', - default='xml_export.xml') -options, args = optsparser.parse_args() - -# Get list of releases if specified -if len(args) > 0: - releases = args - -# This is for determining what css class name to use for printing the artifact -def get_colors(artifact): - style = '<style="background-color: %s; color: %s">' - colors = {'Bad': ('red', 'black'), - 'Open': ('yellow', 'black'), - 'Pending': ('#11ff00', 'black'), - 'Closed': ('#009900', 'white')} - - if artifact['status'] != 'Closed': - if 'Nobody' in artifact['assigned_to']: - return style % colors['Bad'] - else: - return style % colors['Open'] - else: - if artifact['resolution'] != 'Fixed': - return style % colors['Pending'] - else: - return style % colors['Closed'] - -# Go get the parsed data -db = sfparser.get_data(options.xmlfile, releases, ['Features', 'Bugs']) - -# Generate the wiki page -url = 'http://sourceforge.net/tracker/?func=detail&aid=%s&group_id=71730&atid=' -for release in releases: - print '==== %s ====' % release - for x in db: - if len(x['categories']) == 0: continue - print "||||||||<tablestyle=\"border: 0\"style=\"border: 0\"> '''~+%s+~''' ||" % x['title'] - curl = url + x['id'] - categories = x['categories'].keys() - categories.sort() - for category in categories: - printed_cat = False - for artifact in x['categories'][category]: - if artifact['artifact_group_id'] != release: - continue - if artifact['status'] == 'Deleted': continue - if not printed_cat: - print "||||||||<(> '''%s''' ||" % category - printed_cat = True - aid = artifact['artifact_id'] - aurl = curl % aid - summary = artifact['summary'] - assigned_to = artifact['assigned_to'] - status = artifact['status'] - resolution = artifact['resolution'] - print '||%s %s ||<bgcolor="#eeeeee"> [%s %s] ||<bgcolor="#eeeeee"> %s ||<bgcolor="#eeeeee"> %s - %s ||' % (get_colors(artifact), aid, aurl, summary, assigned_to, status, resolution) - Copied: www/trunk/htdocs/tracker/sf2wiki.py (from rev 6147, www/trunk/htdocs/tracker/sf2html.py) =================================================================== --- www/trunk/htdocs/tracker/sf2wiki.py (rev 0) +++ www/trunk/htdocs/tracker/sf2wiki.py 2006-10-07 22:58:18 UTC (rev 6154) @@ -0,0 +1,86 @@ +#!/usr/bin/env python +# +# (C) Copyright IBM Corp. 2006 +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This +# file and program are licensed under a BSD style license. See +# the Copying file included with the OpenHPI distribution for +# full licensing terms. +# +""" +This will parse the SF XML export file and generate a table +showing the status of bugs and feature per release in html. + +Author(s): + Renier Morales <re...@us...> +""" +from optparse import OptionParser +from xml.sax import make_parser, handler, SAXException +import sfparser + +# List of releases to go in the html report +releases = ['2.7.0'] +# Parse options +optsparser = OptionParser(usage='%prog [options] [release [release ...]]') +optsparser.add_option('-f', '--xmlfile', + dest='xmlfile', + metavar='XMLEXPORTFILE', + help='XML file which contains the SF exported data [default: %default]', + default='xml_export.xml') +options, args = optsparser.parse_args() + +# Get list of releases if specified +if len(args) > 0: + releases = args + +# This is for determining what css class name to use for printing the artifact +def get_colors(artifact): + style = '<style="background-color: %s; color: %s">' + colors = {'Bad': ('red', 'black'), + 'Open': ('yellow', 'black'), + 'Pending': ('#11ff00', 'black'), + 'Closed': ('#009900', 'white')} + + if artifact['status'] != 'Closed': + if 'Nobody' in artifact['assigned_to']: + return style % colors['Bad'] + else: + return style % colors['Open'] + else: + if artifact['resolution'] != 'Fixed': + return style % colors['Pending'] + else: + return style % colors['Closed'] + +# Go get the parsed data +db = sfparser.get_data(options.xmlfile, releases, ['Features', 'Bugs']) + +# Generate the wiki page +url = 'http://sourceforge.net/tracker/?func=detail&aid=%s&group_id=71730&atid=' +for release in releases: + print '==== %s ====' % release + for x in db: + if len(x['categories']) == 0: continue + print "||||||||<tablestyle=\"border: 0\"style=\"border: 0\"> '''~+%s+~''' ||" % x['title'] + curl = url + x['id'] + categories = x['categories'].keys() + categories.sort() + for category in categories: + printed_cat = False + for artifact in x['categories'][category]: + if artifact['artifact_group_id'] != release: + continue + if artifact['status'] == 'Deleted': continue + if not printed_cat: + print "||||||||<(> '''%s''' ||" % category + printed_cat = True + aid = artifact['artifact_id'] + aurl = curl % aid + summary = artifact['summary'] + assigned_to = artifact['assigned_to'] + status = artifact['status'] + resolution = artifact['resolution'] + print '||%s %s ||<bgcolor="#eeeeee"> [%s %s] ||<bgcolor="#eeeeee"> %s ||<bgcolor="#eeeeee"> %s - %s ||' % (get_colors(artifact), aid, aurl, summary, assigned_to, status, resolution) + Modified: www/trunk/htdocs/tracker/sfexport2.py =================================================================== --- www/trunk/htdocs/tracker/sfexport2.py 2006-10-06 18:54:12 UTC (rev 6153) +++ www/trunk/htdocs/tracker/sfexport2.py 2006-10-07 22:58:18 UTC (rev 6154) @@ -73,7 +73,7 @@ # Go to page and set to browse specific state and release print 'Going to %s tracker' % x response = br.open(url + trackers[x]) - br.select_form('tracker_browse') + br.select_form(name='tracker_browse') print 'Looking for %s %s for %s release' % (status, x, args[0]) control = br.find_control('_status', type='select') for item in control.items: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |