From: Eric Leblond Date: Wed, 25 Sep 2013 19:22:11 +0000 (+0200) Subject: prscript: update code following buildbot upgrade X-Git-Tag: suricata-2.0beta2~323 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F560%2Fhead;p=thirdparty%2Fsuricata.git prscript: update code following buildbot upgrade The authentication scheme did change on the buildbot due to a software upgrade. This patch update prscript.py to fix the build submission. --- diff --git a/qa/prscript.py b/qa/prscript.py index 17a9c7fbcc..71abec92f4 100755 --- a/qa/prscript.py +++ b/qa/prscript.py @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -import urllib, urllib2 +import urllib, urllib2, cookielib import simplejson as json import time import argparse @@ -40,6 +40,7 @@ parser.add_argument('branch', metavar='branch', help='github branch to build') args = parser.parse_args() username = args.username password = args.password +cookie = None def TestRepoSync(branch): request = urllib2.Request(GITHUB_MASTER_URI) @@ -56,11 +57,25 @@ def TestRepoSync(branch): break return found +def OpenBuildbotSession(): + auth_params = { 'username':username,'passwd':password, 'name':'login'} + cookie = cookielib.LWPCookieJar() + params = urllib.urlencode(auth_params) + opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie)) + urllib2.install_opener(opener) + request = urllib2.Request(BASE_URI + '/login', params) + page = urllib2.urlopen(request) + return cookie + + def SubmitBuild(branch): - raw_params = {'username':username,'passwd':password,'branch':branch,'comments':'Testing ' + branch, 'name':'force_build'} + raw_params = {'branch':branch,'reason':'Testing ' + branch, 'name':'force_build', 'forcescheduler':'force'} params = urllib.urlencode(raw_params) + opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie)) + urllib2.install_opener(opener) request = urllib2.Request(BUILDERS_URI + username + '/force', params) page = urllib2.urlopen(request) + result = page.read() if args.verbose: print "=== response ===" @@ -109,6 +124,10 @@ if TestRepoSync(args.branch) == -1: # submit buildbot form to build current branch on the devel builder if not args.check: + cookie = OpenBuildbotSession() + if cookie == None: + print "Unable to connect to buildbot with provided credentials" + sys.exit(-1) res = SubmitBuild(args.branch) if res == -1: print "Unable to start build. Check command line parameters"