-
Notifications
You must be signed in to change notification settings - Fork 1
/
hermes-update.py
executable file
·44 lines (34 loc) · 1.15 KB
/
hermes-update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /usr/bin/env python
import subprocess
import cgitb, cgi
import json
cgitb.enable()
print "Content-type: text/plain"
print
form = cgi.FieldStorage()
payload = name = form.getvalue('payload')
gitInfo = json.loads(payload)
file_changed = ""
author = ""
commit_message = ""
for f in gitInfo['commits'][0]['added']:
file_changed += "'" + f + "' "
for f in gitInfo['commits'][0]['removed']:
file_changed += "'" + f + "' "
for f in gitInfo['commits'][0]['modified']:
file_changed += "'" + f + "' "
author = "'" + gitInfo['commits'][0]['author']['name'] + "'"
commit_message = "'" + gitInfo['commits'][0]['message'] + "'"
cmd = 'sudo /bin/su git -c "/bin/sh update-hermes-repo.sh"'
print "Running update script."
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
output = p.stdout.read()
print output
cmd = "buildbot sendchange --branch=master --master=buildbot.hpfem.org:9994 --username=" + author + " --comments=" + commit_message + " " + file_changed
print "Sending change to buildbot"
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
output = p.stdout.read()
print output
print " Done."