Back to index

moin  1.9.0~rc2
googlepush.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # needs darcs.idyll.org/~t/projects/twill-latest.tar.gz
00004 
00005 import sys
00006 from textwrap import wrap
00007 
00008 from twill.commands import go, fv, submit, follow, notfind
00009 
00010 
00011 def login(username, password):
00012     go('https://www.google.com/accounts/ManageAccount')
00013     fv('1', 'Email', username)
00014     fv('1', 'Passwd', password)
00015     submit()
00016 
00017 
00018 def push_item(projectname, summary, comment, status, label):
00019     go('http://code.google.com/p/%s/issues/list' % (projectname, ))
00020     follow('New Issue')
00021     fv('3', 'summary', summary)
00022     fv('3', 'comment', wraptext(comment))
00023     fv('3', 'status', status)
00024     fv("3", "labelenter0", label)
00025     fv("3", "labelenter1", "")
00026 
00027     submit('submit')
00028     notfind("Letters did not match")
00029 
00030 
00031 def wraptext(text):
00032     lines = text.splitlines()
00033     cur_p = []
00034     output = []
00035     for line in lines + [""]:
00036         if not line and cur_p:
00037             output.extend(wrap("\n".join(cur_p)) + [""])
00038             cur_p = []
00039             continue
00040         cur_p.append(line)
00041     return "\n".join(output)
00042