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 properties = None 52 if args.get('properties'): 53 properties = json.loads( args.get('properties')[0] ) 54 else: 55 properties = {} 56 57 revision = firstOrNothing(args.get('revision')) 58 when = firstOrNothing(args.get('when')) 59 if when is not None: 60 when = float(when) 61 author = firstOrNothing(args.get('author')) 62 if not author: 63 author = firstOrNothing(args.get('who')) 64 comments = firstOrNothing(args.get('comments')) 65 isdir = firstOrNothing(args.get('isdir',0)) 66 branch = firstOrNothing(args.get('branch')) 67 category = firstOrNothing(args.get('category')) 68 revlink = firstOrNothing(args.get('revlink')) 69 repository = firstOrNothing(args.get('repository')) 70 project = firstOrNothing(args.get('project')) 71 72 chdict = dict(author=author, files=files, comments=comments, 73 isdir=isdir, revision=revision, when=when, 74 branch=branch, category=category, revlink=revlink, 75 properties=properties, repository=repository, 76 project=project) 77 return ([ chdict ], None) 78