curlwrapper has a verbose mode that can be turned on manually
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 29 Jun 2011 13:46:26 +0000 (15:46 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 29 Jun 2011 13:46:26 +0000 (15:46 +0200)
curlwrapper.py

index bed1b3c..08223e3 100644 (file)
@@ -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)