Added the start of moving fedorahosted's Hosting Requests to an automated process. (See infra ticket 2131). The script doesn't actually execute any commands or such yet, but does get information about tickets, parsed from a template that users are expected to fill out, when they request a project.. Upon mmcgrath returning from PHX and being able to give me orientation, I will play with it on hosted2, and actually make it do stuff ;).

Another thing it does not handle yet is a user incorrectly filling out the template, or deleting questions or such. This needs handled before it gets moved to hosted1 obviously, but I'd like it to actually /work/ first (assuming a correctly filled-in template), and thus be able to test it on hosted2. At this point, I'm just committing it to show that I have started on it, and so there's a copy of it out there, should anything happen. Don't expect it to ...work yet ;).
This commit is contained in:
Rick Elrod 2010-05-12 00:21:11 -04:00
parent 936882fb9a
commit b31f988560
2 changed files with 70 additions and 0 deletions

View file

@ -0,0 +1,11 @@
Project name: myProject
Project short summary: myProject does X and Y, for the purpose of Z.
SCM choice (git/bzr/hg/svn): hg
Project admin Fedora Account System account name: myAccountName
Yes/No, would you like a Trac instance for your project?: yes
Do you need a mailing list? If so, comma-separate a list of what you'd like them to be called. Otherwise, put "no": myProject-developers, myProject-commits

View file

@ -0,0 +1,59 @@
#!/usr/bin/env python
# XML_RPC interface to "Hosting request" tickets on fedorahosted Trac.
import sys, urllib, xmlrpclib
USERNAME = ''
PASSWORD = ''
SERVER = 'fedorahosted.org'
PROJECT_PATH = 'fedora-infrastructure'
xmlrpc = xmlrpclib.ServerProxy("https://%s:%s@%s/%s/login/xmlrpc" % (
urllib.quote(USERNAME), urllib.quote(PASSWORD), SERVER, PROJECT_PATH))
multicall = xmlrpclib.MultiCall(xmlrpc)
def parse_line(search, shortname, line):
global project
if search in line:
project[shortname] = line.split(": ", 1)[1]
return None
for ticket in xmlrpc.ticket.query("summary=^Hosting request&status=new|open"):
#print "Ticket #" + str(ticket)
ticket_info = xmlrpc.ticket.get(ticket)
if ticket == 2152: # Just for testing purposes, on hosted2.
project = {}
project['mailing_lists'] = []
description = ticket_info[3]['description'] # For now, assume [3] will always be the dictionary.
description = description.split("\n")
for line in description:
# parse_line(Search, Short-Name, line)
parse_line("Project name: ", "name", line)
parse_line("Project short summary", "summary", line)
parse_line("SCM choice", "scm", line)
parse_line("Trac instance", "trac", line)
parse_line("mailing list", "mailinglist", line)
if project['mailinglist'].lower() != "no":
lists = project['mailinglist'].split(",")
for list_name in lists:
# Kill spaces
list_name = list_name.replace(" ", "")
# Append it to the list, so we can iterate over it later.
project['mailing_lists'].append(list_name)
for key, value in project.items():
print "%s: %s" % (key, value)
# Script Output:
# MacBook:fedorahosted relrod$ python xmlrpc.py
# scm: hg
# mailinglist: myProject-developers, myProject-commits
# name: myProject
# trac: yes
# mailing_lists: ['myProject-developers', 'myProject-commits']
# summary: myProject does X and Y, for the purpose of Z.