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 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