Actually I'll send v2 which should work for HTTP Basic Authentication too.
On Fri, 2014-04-11 at 18:54 +0300, Stefan Stanacar wrote: > People behind a proxy couldn't send an error report to an upstream server, > this should fix the issue if they use a proxy that doesn't require > authentication, > and it's correctly exported in the enviroment. > There are probbaly better ways to fix this (urllib2, proxy connect, > a command line option for proxy) but those require more changes than > I feel confortable doing now. > > Signed-off-by: Stefan Stanacar <stefanx.stana...@intel.com> > --- > scripts/send-error-report | 27 +++++++++++++++++++++------ > 1 file changed, 21 insertions(+), 6 deletions(-) > > diff --git a/scripts/send-error-report b/scripts/send-error-report > index 3734b61..0bce8b6 100755 > --- a/scripts/send-error-report > +++ b/scripts/send-error-report > @@ -8,6 +8,24 @@ > > > import httplib, urllib, os, sys, json > +from urllib2 import _parse_proxy as parseproxy > + > + > +def handle_connection(server, data): > + params = urllib.urlencode({'data': data}) > + headers = {"Content-type": "application/json"} > + > + if os.environ.get("http_proxy") or os.environ.get("HTTP_PROXY"): > + proxy = parseproxy(os.environ.get("http_proxy") or > os.environ.get("HTTP_PROXY")) > + if proxy[1] or proxy[2]: > + raise Exception("http proxies that require > authentication are not supported for now.") > + conn = httplib.HTTPConnection(proxy[3]) > + conn.request("POST", "http://%s/ClientPost/" % server, > params, headers) > + else: > + conn = httplib.HTTPConnection(server) > + conn.request("POST", "/ClientPost/", params, headers) > + > + return conn > > > def sendData(json_file, server): > @@ -45,10 +63,7 @@ def sendData(json_file, server): > return > > try: > - params = urllib.urlencode({'data': data}) > - headers = {"Content-type": "application/json"} > - conn = httplib.HTTPConnection(server) > - conn.request("POST", "/ClientPost/", params, headers) > + conn = handle_connection(server, data) > response = conn.getresponse() > print response.status, response.reason > res = response.read() > @@ -59,8 +74,8 @@ def sendData(json_file, server): > with open("%s.response.html" % json_file, "w") as f: > f.write(res) > conn.close() > - except: > - print("Server connection failed") > + except Exception as e: > + print("Server connection failed: %s" % e) > > else: > print("No data file found.") -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core