X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=curlwrapper.py;h=08223e39a2499411cfbd99b56139a49604748ca0;hb=e57432c1dfdfeaa52cc32799e2abbc34b7704ce9;hp=21b499c2d12fd998e8afd5634761adaf6f73a654;hpb=195acb58ed96247b2265364ac11f7f77fb361bc1;p=nodemanager.git diff --git a/curlwrapper.py b/curlwrapper.py index 21b499c..08223e3 100644 --- a/curlwrapper.py +++ b/curlwrapper.py @@ -3,7 +3,7 @@ # it turned out, however, that after around 10 cycles of the nodemanager, # attempts to call GetSlivers were failing with a curl error 60 # we are thus reverting to the version from tag curlwrapper.py-NodeManager-2.0-8 -# the (broekn) pycurl version can be found in tags 2.0-9 and 2.0-10 +# the (broken) pycurl version can be found in tags 2.0-9 and 2.0-10 from subprocess import PIPE, Popen from select import select @@ -13,19 +13,26 @@ import os import logger +verbose=False +#verbose=True + class Sopen(Popen): def kill(self, signal = signal.SIGTERM): os.kill(self.pid, signal) def retrieve(url, cacert=None, postdata=None, timeout=90): -# options = ('/usr/bin/curl', '--fail', '--silent') - options = ('/usr/bin/curl', '--fail', ) - if cacert: options += ('--cacert', cacert) - if postdata: options += ('--data', '@-') +# command = ('/usr/bin/curl', '--fail', '--silent') + command = ('/usr/bin/curl', '--fail', ) + if cacert: command += ('--cacert', cacert) + if postdata: command += ('--data', '@-') if timeout: - options += ('--max-time', str(timeout)) - options += ('--connect-timeout', str(timeout)) - p = Sopen(options + (url,), stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) + command += ('--max-time', str(timeout)) + command += ('--connect-timeout', str(timeout)) + command += (url,) + if verbose: + print 'Invoking ',command + if postdata: print 'with postdata=',postdata + p = Sopen(command , stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) if postdata: p.stdin.write(postdata) p.stdin.close() sout, sin, serr = select([p.stdout,p.stderr],[],[], timeout)