This commit is contained in:
Thomas Forgione 2019-03-27 12:14:15 +01:00
parent 363ffc40ce
commit b2504f49f9
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41

5
upload
View File

@ -25,7 +25,7 @@ def find_ais(path):
return [Ai(x) for x in os.listdir(path) if not x.startswith('__')]
def upload_ai(ai):
print_yellow("Zipping " + ai.name + "...")
print_yellow("Zipping the AI...")
zip = zipfile.ZipFile('.archive.zip', mode = 'w')
try:
for file in os.listdir(AIS_DIR + "/" + ai.path):
@ -33,12 +33,15 @@ def upload_ai(ai):
finally:
zip.close()
print_yellow("Uploading the AI...")
try:
subprocess.check_call([
'curl', '-X', 'POST', '-F', 'archive=@.archive.zip', '-F', 'name=' + ai.name,
'http://pytron.tforgione.fr/upload-target/'],
stderr = subprocess.DEVNULL,
stdout = subprocess.DEVNULL)
print_green("Upload finished!")
except subprocess.CalledProcessError:
print_red('An error occured while uploading the AI...')