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 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 author = firstOrNothing(args.get('author'))
60 if not author:
61 author = 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 chdict = dict(author=author, files=files, comments=comments,
71 isdir=isdir, revision=revision, when=when,
72 branch=branch, category=category, revlink=revlink,
73 properties=properties, repository=repository,
74 project=project)
75 return ([ chdict ], None)
76