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

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

 1  # code inspired/copied from contrib/github_buildbot 
 2  #  and inspired from code from the Chromium project 
 3  # otherwise, Andrew Melo <andrew.melo@gmail.com> wrote the rest 
 4   
 5  # but "the rest" is pretty minimal 
 6  from twisted.web import resource 
 7  from buildbot.status.builder import FAILURE 
 8  import re 
 9  from buildbot import util, interfaces 
10  import logging 
11  import traceback 
12  import sys 
13  from buildbot.process.properties import Properties 
14  from buildbot.changes.changes import Change 
15  from twisted.python.reflect import namedModule 
16  from buildbot.util import json 
17  from twisted.python.log import msg,err 
18       
19 -def getChanges(request, options=None):
20 """ 21 Consumes a naive build notification (the default for now) 22 basically, set POST variables to match commit object parameters: 23 revision, revlink, comments, branch, who, files, links 24 25 files, links and properties will be de-json'd, the rest are interpreted as strings 26 """ 27 28 def firstOrNothing( value ): 29 """ 30 Small helper function to return the first value (if value is a list) 31 or return the whole thing otherwise 32 """ 33 if ( type(value) == type([])): 34 return value[0] 35 else: 36 return value
37 38 args = request.args 39 40 # first, convert files, links and properties 41 files = None 42 if args.get('files'): 43 files = json.loads( args.get('files')[0] ) 44 else: 45 files = [] 46 47 links = None 48 if args.get('links'): 49 links = json.loads( args.get('links')[0] ) 50 else: 51 links = [] 52 53 properties = None 54 if args.get('properties'): 55 properties = json.loads( args.get('properties')[0] ) 56 else: 57 properties = {} 58 59 revision = firstOrNothing(args.get('revision')) 60 when = firstOrNothing(args.get('when')) 61 who = firstOrNothing(args.get('who')) 62 comments = firstOrNothing(args.get('comments')) 63 isdir = firstOrNothing(args.get('isdir',0)) 64 branch = firstOrNothing(args.get('branch')) 65 category = firstOrNothing(args.get('category')) 66 revlink = firstOrNothing(args.get('revlink')) 67 repository = firstOrNothing(args.get('repository')) 68 project = firstOrNothing(args.get('project')) 69 70 ourchange = Change(who = who, files = files, comments = comments, isdir = isdir, links = links, 71 revision=revision, when = when, branch = branch, category = category, 72 revlink = revlink, properties = properties, repository = repository, 73 project = project) 74 return [ourchange] 75