summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Laine <jeremy.laine@m4x.org>2008-05-18 11:45:32 +0000
committerJeremy Laine <jeremy.laine@m4x.org>2008-05-18 11:45:32 +0000
commit53877222d5a1a0d9d3783618eb3100d63786404e (patch)
treec134c9b1bd6b829e3bf0ce989d8787149c8ef1a1
parent3ca0ffc76f5077b8c11e80ddd846f87ca61e6ebe (diff)
oestats-client.bb: disable stats if we cannot get a build id
-rw-r--r--classes/oestats-client.bbclass33
1 files changed, 23 insertions, 10 deletions
diff --git a/classes/oestats-client.bbclass b/classes/oestats-client.bbclass
index b98177d40a..661ef74a22 100644
--- a/classes/oestats-client.bbclass
+++ b/classes/oestats-client.bbclass
@@ -22,28 +22,37 @@ def oestats_send(server, action, vars = {}):
import httplib, urllib
params = urllib.urlencode(vars)
- headers = {"Content-type": "application/x-www-form-urlencoded",
- "Accept": "text/plain"}
+ headers = {"Content-type": "application/x-www-form-urlencoded"}
conn = httplib.HTTPConnection(server)
conn.request("POST", action, params, headers)
response = conn.getresponse()
+ data = response.read()
conn.close()
- return response
+ return data
def oestats_start(server, builder, d):
import bb
import os.path
+ import re
# send report
- response = oestats_send(server, "/builds/start/", {
- 'builder': builder,
- 'revision': bb.data.getVar('METADATA_REVISION', d, True),
- 'machine': bb.data.getVar('MACHINE', d, True),
- 'distro': bb.data.getVar('DISTRO', d, True),
- })
- id = response.read()
+ id = ""
+ try:
+ data = oestats_send(server, "/builds/start/", {
+ 'builder': builder,
+ 'revision': bb.data.getVar('METADATA_REVISION', d, True),
+ 'machine': bb.data.getVar('MACHINE', d, True),
+ 'distro': bb.data.getVar('DISTRO', d, True),
+ })
+ if re.match("^\d+$", data): id=data
+ except:
+ pass
# save the build id
+ if id:
+ bb.note("oestats: build %s" % id)
+ else:
+ bb.note("oestats: server error, disabling stats")
oestats_setid(d, id)
def oestats_stop(server, d, status):
@@ -51,6 +60,7 @@ def oestats_stop(server, d, status):
# retrieve build id
id = oestats_getid(d)
+ if not id: return
# send report
response = oestats_send(server, "/builds/stop/%s/" % id, {
@@ -63,6 +73,9 @@ def oestats_task(server, d, task, status):
# retrieve build id
id = oestats_getid(d)
+ if not id: return
+
+ # calculate build time
try:
elapsed = time.time() - float(bb.data.getVar('OESTATS_STAMP', d, True))
except: