1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-09 12:35:48 +01:00

- fixed "osc -H ..." in combination with a proxy

This commit is contained in:
Marcus Huewe 2014-03-11 19:40:27 +01:00
parent 9034b27814
commit 8c506e5929

View File

@ -531,12 +531,20 @@ def init_basicauth(config):
# this is so ugly but httplib doesn't use # this is so ugly but httplib doesn't use
# a logger object or such # a logger object or such
def new_method(self, *args, **kwargs): def new_method(self, *args, **kwargs):
self._orig_stdout = sys.stdout # check if this is a recursive call (note: we do not
sys.stdout = StringIO() # have to care about thread safety)
meth(self, *args, **kwargs) is_rec_call = getattr(self, '_orig_stdout', None) is not None
hdr = sys.stdout.getvalue() try:
sys.stdout = self._orig_stdout if not is_rec_call:
del self._orig_stdout self._orig_stdout = sys.stdout
sys.stdout = StringIO()
meth(self, *args, **kwargs)
hdr = sys.stdout.getvalue()
finally:
# restore original stdout
if not is_rec_call:
sys.stdout = self._orig_stdout
del self._orig_stdout
for i in hdrs: for i in hdrs:
if ishdr: if ishdr:
hdr = re.sub(r'%s:[^\\r]*\\r\\n' % i, '', hdr) hdr = re.sub(r'%s:[^\\r]*\\r\\n' % i, '', hdr)