diff --git a/upload b/upload index 9aadd31..a8a9d00 100755 --- a/upload +++ b/upload @@ -40,34 +40,31 @@ def upload_ai(ai): zip.close() print_yellow("Uploading the AI...") - try: - curl = subprocess.Popen([ - 'curl', '-X', 'POST', - '-F', 'archive=@.archive.zip', - '-F', 'name=' + ai.name, - '-F', 'password=' + password, - API_URL], - stderr = subprocess.PIPE, - stdout = subprocess.PIPE) - code = curl.wait() - if code != 0: - raise subprocess.CalledProcessError + curl = subprocess.Popen([ + 'curl', '-X', 'POST', + '-F', 'archive=@.archive.zip', + '-F', 'name=' + ai.name, + '-F', 'password=' + password, + API_URL], + stderr = subprocess.PIPE, + stdout = subprocess.PIPE) + code = curl.wait() + + if code != 0: + return_code = 1 + response = "curl request failed" + else: response = curl.stdout.read().decode() - if response == 'Success': - print_green("Upload finished!") - else: - print_red("Upload failed: " + str(response).lower()) - return_code = 1 - - except subprocess.CalledProcessError: - print_red('An error occured while uploading the AI...') + if response == 'Success': + print_green("Upload finished!") + else: + print_red("Upload failed: " + str(response).lower()) return_code = 1 os.remove(".archive.zip") - sys.exit(return_code) def main():