aboutsummaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorJeremy Laine <jeremy.laine@m4x.org>2008-05-16 10:25:11 +0000
committerJeremy Laine <jeremy.laine@m4x.org>2008-05-16 10:25:11 +0000
commit9c36fb3b4266b5b0864b9898d171c731bcf403b4 (patch)
tree77ead07cb5c4ceeff079b84033700cf5b3ecb115 /classes
parent0d183d43d530b466d6fb877f2b393f6c3a2b3f66 (diff)
downloadopenembedded-9c36fb3b4266b5b0864b9898d171c731bcf403b4.tar.gz
openembedded-9c36fb3b4266b5b0864b9898d171c731bcf403b4.tar.bz2
openembedded-9c36fb3b4266b5b0864b9898d171c731bcf403b4.zip
oestats-client.bbclass: include elapsed time in task reports
Diffstat (limited to 'classes')
-rw-r--r--classes/oestats-client.bbclass35
1 files changed, 25 insertions, 10 deletions
diff --git a/classes/oestats-client.bbclass b/classes/oestats-client.bbclass
index da70a77825..f87b58f817 100644
--- a/classes/oestats-client.bbclass
+++ b/classes/oestats-client.bbclass
@@ -8,6 +8,16 @@
# OESTATS_SERVER = "some.server.org:8000"
# OESTATS_BUILDER = "some title"
+def oestats_setid(d, val):
+ import bb
+ f = file(bb.data.getVar('TMPDIR', d, True) + '/oestats.id', 'w')
+ f.write(val)
+
+def oestats_getid(d):
+ import bb
+ f = file(bb.data.getVar('TMPDIR', d, True) + '/oestats.id', 'r')
+ return f.read()
+
def oestats_revision(dir):
import re
try:
@@ -34,7 +44,7 @@ def oestats_start(server, builder, d):
import os.path
# collect information about revisions
- path_bb = bb.data.getVar('BBPATH', d, 1)
+ path_bb = bb.data.getVar('BBPATH', d, True)
for p in (path_bb or "").split(':'):
revision = oestats_revision(p)
if revision:
@@ -44,22 +54,19 @@ def oestats_start(server, builder, d):
response = oestats_send(server, "/builds/start/", {
'builder': builder,
'revision': revision,
- 'machine': bb.data.getVar( 'MACHINE', d, True ),
- 'distro': bb.data.getVar( 'DISTRO', d, True ),
+ 'machine': bb.data.getVar('MACHINE', d, True),
+ 'distro': bb.data.getVar('DISTRO', d, True),
})
id = response.read()
# save the build id
- bb.note("Stats id: %s" % id)
- f = file(bb.data.getVar('TMPDIR', d, True)+"/oestats.id", 'w')
- f.write(id)
+ oestats_setid(d, id)
def oestats_stop(server, d, status):
import bb
# retrieve build id
- f = file(bb.data.getVar('TMPDIR',d,True)+"/oestats.id", 'r')
- id = f.read()
+ id = oestats_getid(d)
# send report
response = oestats_send(server, "/builds/stop/%s/" % id, {
@@ -68,10 +75,14 @@ def oestats_stop(server, d, status):
def oestats_task(server, d, task, status):
import bb
+ import time
# retrieve build id
- f = file(bb.data.getVar('TMPDIR',d,True)+"/oestats.id", 'r')
- id = f.read()
+ id = oestats_getid(d)
+ try:
+ elapsed = time.time() - float(bb.data.getVar('OESTATS_STAMP', d, True))
+ except:
+ elapsed = 0
# send report
response = oestats_send(server, "/builds/task/%s/" % id, {
@@ -80,12 +91,14 @@ def oestats_task(server, d, task, status):
'revision': bb.data.getVar('PR', d, True),
'task': task,
'status': status,
+ 'time': elapsed,
})
addhandler oestats_eventhandler
python oestats_eventhandler () {
from bb.event import getName
import bb
+ import time
if e.data is None or getName(e) == "MsgNote":
return NotHandled
@@ -99,6 +112,8 @@ python oestats_eventhandler () {
oestats_start(server, builder, e.data)
elif getName(e) == 'BuildCompleted':
oestats_stop(server, e.data, 'Completed')
+ elif getName(e) == 'TaskStarted':
+ bb.data.setVar('OESTATS_STAMP', repr(time.time()), e.data)
elif getName(e) == 'TaskSucceeded':
oestats_task(server, e.data, e.task, 'Succeeded')
elif getName(e) == 'TaskFailed':