diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/base.bbclass | 4 | ||||
-rw-r--r-- | classes/oestats-client.bbclass | 30 |
2 files changed, 14 insertions, 20 deletions
diff --git a/classes/base.bbclass b/classes/base.bbclass index bc50c67d4b..9c51c0a08e 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -885,7 +885,7 @@ def base_get_metadata_svn_revision(path, d): def base_get_metadata_git_branch(path, d): import os - branch = os.popen('cd %s; PATH=%s git symbolic-ref HEAD 2>/dev/null' % (path, d.getVar("BBPATH", 1))).read().rstrip() + branch = os.popen('cd %s; PATH=%s git symbolic-ref HEAD 2>/dev/null' % (path, d.getVar("PATH", 1))).read().rstrip() if len(branch) != 0: return branch.replace("refs/heads/", "") @@ -893,7 +893,7 @@ def base_get_metadata_git_branch(path, d): def base_get_metadata_git_revision(path, d): import os - rev = os.popen("cd %s; PATH=%s git show-ref HEAD 2>/dev/null" % (path, d.getVar("BBPATH", 1))).read().split(" ")[0].rstrip() + rev = os.popen("cd %s; PATH=%s git show-ref HEAD 2>/dev/null" % (path, d.getVar("PATH", 1))).read().split(" ")[0].rstrip() if len(rev) != 0: return rev return "<unknown>" diff --git a/classes/oestats-client.bbclass b/classes/oestats-client.bbclass index 8922496242..e6b8485385 100644 --- a/classes/oestats-client.bbclass +++ b/classes/oestats-client.bbclass @@ -5,8 +5,9 @@ # To make use of this class, add to your local.conf: # # INHERIT += "oestats-client" -# OESTATS_SERVER = "some.server.org" +# OESTATS_SERVER = "http://some.server.org" # OESTATS_BUILDER = "some_nickname" +# def oestats_setid(d, val): import bb @@ -19,8 +20,8 @@ def oestats_getid(d): return f.read() def oestats_send(d, server, action, vars = {}, files = {}): - import httplib import bb + import urllib2 # build body output = [] @@ -49,21 +50,12 @@ def oestats_send(d, server, action, vars = {}, files = {}): "Content-type": "multipart/form-data; boundary=%s" % bound, "Content-length": str(len(body))} - # send request - proxy = bb.data.getVar('HTTP_PROXY', d, True ) - if (proxy): - if (proxy.endswith('/')): - proxy = proxy[:-1] - if (proxy.startswith('http://')): - proxy = proxy[7:] - conn = httplib.HTTPConnection(proxy) - action = "http://%s%s" %(server, action) - else: - conn = httplib.HTTPConnection(server) - conn.request("POST", action, body, headers) - response = conn.getresponse() + # send request using urllib2, proxies should be auto-detected + actionURL = "%s%s" %(server, action) + req = urllib2.Request(actionURL, body, headers); + response = urllib2.urlopen(req) data = response.read() - conn.close() + return data def oestats_start(server, builder, d): @@ -111,7 +103,7 @@ def oestats_stop(server, d, failures): 'status': status, }) if status == 'Failed': - bb.note("oestats: build failed, see http://%s%s" % (server,response)) + bb.note("oestats: build failed, see %s%s" % (server, response)) except: bb.note("oestats: error stopping build") @@ -169,7 +161,7 @@ def oestats_task(server, d, task, status): try: response = oestats_send(d, server, "/tasks/", vars, files) if status == 'Failed': - bb.note("oestats: task failed, see http://%s%s" % (server, response)) + bb.note("oestats: task failed, see %s%s" % (server, response)) except: bb.note("oestats: error sending task, disabling stats") oestats_setid(d, "") @@ -184,6 +176,8 @@ python oestats_eventhandler () { return NotHandled server = bb.data.getVar('OESTATS_SERVER', e.data, True) + if not server.startswith('http://') and not server.startswith('https://'): + server = "http://%s" %(server) builder = bb.data.getVar('OESTATS_BUILDER', e.data, True) if not server or not builder: return NotHandled |