Package buildbot :: Package status :: Package web :: Package hooks :: Module base
[frames] | no frames]

Source Code for Module buildbot.status.web.hooks.base

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16  # code inspired/copied from contrib/github_buildbot 
17  #  and inspired from code from the Chromium project 
18  # otherwise, Andrew Melo <andrew.melo@gmail.com> wrote the rest 
19  # but "the rest" is pretty minimal 
20   
21  from buildbot.util import json 
22       
23 -def getChanges(request, options=None):
24 """ 25 Consumes a naive build notification (the default for now) 26 basically, set POST variables to match commit object parameters: 27 revision, revlink, comments, branch, who, files, links 28 29 files, links and properties will be de-json'd, the rest are interpreted as strings 30 """ 31 32 def firstOrNothing( value ): 33 """ 34 Small helper function to return the first value (if value is a list) 35 or return the whole thing otherwise 36 """ 37 if ( type(value) == type([])): 38 return value[0] 39 else: 40 return value
41 42 args = request.args 43 44 # first, convert files, links and properties 45 files = None 46 if args.get('files'): 47 files = json.loads( args.get('files')[0] ) 48 else: 49 files = [] 50 51 links = None 52 if args.get('links'): 53 links = json.loads( args.get('links')[0] ) 54 else: 55 links = [] 56 57 properties = None 58 if args.get('properties'): 59 properties = json.loads( args.get('properties')[0] ) 60 else: 61 properties = {} 62 63 revision = firstOrNothing(args.get('revision')) 64 when = firstOrNothing(args.get('when')) 65 who = firstOrNothing(args.get('who')) 66 comments = firstOrNothing(args.get('comments')) 67 isdir = firstOrNothing(args.get('isdir',0)) 68 branch = firstOrNothing(args.get('branch')) 69 category = firstOrNothing(args.get('category')) 70 revlink = firstOrNothing(args.get('revlink')) 71 repository = firstOrNothing(args.get('repository')) 72 project = firstOrNothing(args.get('project')) 73 74 chdict = dict(who=who, files=files, comments=comments, 75 isdir=isdir, links=links, revision=revision, when=when, 76 branch=branch, category=category, revlink=revlink, 77 properties=properties, repository=repository, 78 project=project) 79 return [ chdict ] 80