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   
20  # but "the rest" is pretty minimal 
21  from buildbot.changes.changes import Change 
22  from buildbot.util import json 
23       
24 -def getChanges(request, options=None):
25 """ 26 Consumes a naive build notification (the default for now) 27 basically, set POST variables to match commit object parameters: 28 revision, revlink, comments, branch, who, files, links 29 30 files, links and properties will be de-json'd, the rest are interpreted as strings 31 """ 32 33 def firstOrNothing( value ): 34 """ 35 Small helper function to return the first value (if value is a list) 36 or return the whole thing otherwise 37 """ 38 if ( type(value) == type([])): 39 return value[0] 40 else: 41 return value
42 43 args = request.args 44 45 # first, convert files, links and properties 46 files = None 47 if args.get('files'): 48 files = json.loads( args.get('files')[0] ) 49 else: 50 files = [] 51 52 links = None 53 if args.get('links'): 54 links = json.loads( args.get('links')[0] ) 55 else: 56 links = [] 57 58 properties = None 59 if args.get('properties'): 60 properties = json.loads( args.get('properties')[0] ) 61 else: 62 properties = {} 63 64 revision = firstOrNothing(args.get('revision')) 65 when = firstOrNothing(args.get('when')) 66 who = firstOrNothing(args.get('who')) 67 comments = firstOrNothing(args.get('comments')) 68 isdir = firstOrNothing(args.get('isdir',0)) 69 branch = firstOrNothing(args.get('branch')) 70 category = firstOrNothing(args.get('category')) 71 revlink = firstOrNothing(args.get('revlink')) 72 repository = firstOrNothing(args.get('repository')) 73 project = firstOrNothing(args.get('project')) 74 75 ourchange = Change(who = who, files = files, comments = comments, isdir = isdir, links = links, 76 revision=revision, when = when, branch = branch, category = category, 77 revlink = revlink, properties = properties, repository = repository, 78 project = project) 79 return [ourchange] 80