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