1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 from buildbot.util import json
22
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
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