Added --fail argument to curl invocations, so that HTTP request fails get surfaced as non-zero exit codes

This commit is contained in:
Justin Santa Barbara
2010-07-29 14:48:10 -07:00
parent 251e41ff51
commit 93aee19fa2
4 changed files with 7 additions and 7 deletions

View File

@@ -59,21 +59,21 @@ def download(img):
for f in img['files']:
if f['kind'] == 'kernel':
dest = os.path.join(tempdir, 'kernel')
subprocess.call(['curl', f['url'], '-o', dest])
subprocess.call(['curl', '--fail', f['url'], '-o', dest])
kernel_id = image.Image.add(dest,
description='kernel/' + img['title'], kernel=True)
for f in img['files']:
if f['kind'] == 'ramdisk':
dest = os.path.join(tempdir, 'ramdisk')
subprocess.call(['curl', f['url'], '-o', dest])
subprocess.call(['curl', '--fail', f['url'], '-o', dest])
ramdisk_id = image.Image.add(dest,
description='ramdisk/' + img['title'], ramdisk=True)
for f in img['files']:
if f['kind'] == 'image':
dest = os.path.join(tempdir, 'image')
subprocess.call(['curl', f['url'], '-o', dest])
subprocess.call(['curl', '--fail', f['url'], '-o', dest])
ramdisk_id = image.Image.add(dest,
description=img['title'], kernel=kernel_id, ramdisk=ramdisk_id)

View File

@@ -44,8 +44,8 @@ CSRTEXT=$(python -c "import urllib; print urllib.quote('''$CSRTEXT''')")
# SIGN the csr and save as server.crt
# CURL fetch to the supervisor, POSTing the CSR text, saving the result as the CRT file
curl $SUPERVISOR -d "cert=$CSRTEXT" > /etc/openvpn/server.crt
curl $SUPERVISOR/getca/ > /etc/openvpn/ca.crt
curl --fail $SUPERVISOR -d "cert=$CSRTEXT" > /etc/openvpn/server.crt
curl --fail $SUPERVISOR/getca/ > /etc/openvpn/ca.crt
# Customize the server.conf.template
cd /etc/openvpn

View File

@@ -53,7 +53,7 @@ def fetchfile(url, target):
# c.perform()
# c.close()
# fp.close()
execute("curl %s -o %s" % (url, target))
execute("curl --fail %s -o %s" % (url, target))
def execute(cmd, input=None, addl_env=None, check_exit_code=True):
env = os.environ.copy()

View File

@@ -54,7 +54,7 @@ def _fetch_s3_image(image, path, user):
auth = signer.Signer(user.secret.encode()).s3_authorization(headers, 'GET', uri)
headers['Authorization'] = 'AWS %s:%s' % (user.access, auth)
cmd = ['/usr/bin/curl', '--silent', url]
cmd = ['/usr/bin/curl', '--fail', '--silent', url]
for (k,v) in headers.iteritems():
cmd += ['-H', '%s: %s' % (k,v)]