[oe-commits] Dmitry Eremin-Solenikov : oestats-client: support working behind proxy
git version control
git at git.openembedded.org
Wed Jul 1 14:10:18 UTC 2009
Module: openembedded.git
Branch: stable/2009
Commit: 1d16e498fa079d509715d532351483ba93a4550a
URL: http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=1d16e498fa079d509715d532351483ba93a4550a
Author: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
Date: Mon Jun 22 22:56:28 2009 +0000
oestats-client: support working behind proxy
Detect if we are behind proxy by checking for HTTP_PROXY variable
and use specified proxy for http traffic.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
Signed-off-by: Marcin Juszkiewicz <marcin at juszkiewicz.com.pl>
Acked-by: Koen Kooi <koen at openembedded.org>
---
classes/oestats-client.bbclass | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/classes/oestats-client.bbclass b/classes/oestats-client.bbclass
index 6d348d3..8922496 100644
--- a/classes/oestats-client.bbclass
+++ b/classes/oestats-client.bbclass
@@ -18,8 +18,9 @@ def oestats_getid(d):
f = file(bb.data.getVar('TMPDIR', d, True) + '/oestats.id', 'r')
return f.read()
-def oestats_send(server, action, vars = {}, files = {}):
+def oestats_send(d, server, action, vars = {}, files = {}):
import httplib
+ import bb
# build body
output = []
@@ -49,7 +50,16 @@ def oestats_send(server, action, vars = {}, files = {}):
"Content-length": str(len(body))}
# send request
- conn = httplib.HTTPConnection(server)
+ 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()
data = response.read()
@@ -64,7 +74,7 @@ def oestats_start(server, builder, d):
# send report
id = ""
try:
- data = oestats_send(server, "/builds/", {
+ data = oestats_send(d, server, "/builds/", {
'builder': builder,
'build_arch': bb.data.getVar('BUILD_ARCH', d, True),
'metadata_branch': bb.data.getVar('METADATA_BRANCH', d, True),
@@ -97,7 +107,7 @@ def oestats_stop(server, d, failures):
status = "Succeeded"
try:
- response = oestats_send(server, "/builds/%s/" % id, {
+ response = oestats_send(d, server, "/builds/%s/" % id, {
'status': status,
})
if status == 'Failed':
@@ -157,7 +167,7 @@ def oestats_task(server, d, task, status):
# send report
try:
- response = oestats_send(server, "/tasks/", vars, files)
+ response = oestats_send(d, server, "/tasks/", vars, files)
if status == 'Failed':
bb.note("oestats: task failed, see http://%s%s" % (server, response))
except:
More information about the Openembedded-commits
mailing list