1 from subprocess import PIPE, Popen
4 class CurlException(Exception): pass
6 def retrieve(url, postdata=None):
7 options = ('/usr/bin/curl', '--cacert', '/usr/boot/cacert.pem')
8 if postdata: options += ('--data', '@-')
9 p = Popen(options + (url,), stdin=PIPE, stdout=PIPE, stderr=PIPE)
10 if postdata: p.stdin.write(postdata)
12 data = p.stdout.read()
15 if rc != 0: raise CurlException(err)