still flailing - try a random name

This commit is contained in:
jobevers 2017-02-23 09:16:10 -06:00
parent 478ca98b0e
commit 318160b328
3 changed files with 9 additions and 3 deletions

View file

@ -41,6 +41,7 @@ build_script:
- python zip_daemon.py
- dir dist
- pip install PyGithub uritemplate
- pip install -U requests[security]
- python release_on_tag.py
test: off

View file

@ -84,6 +84,7 @@ if [ "$FULL_BUILD" == "true" ]; then
# it to reliably work and it also seemed difficult to configure. Not proud of
# this, but it seemed better to write my own.
pip install PyGithub uritemplate
pip install -U requests[security]
python release_on_tag.py
deactivate
fi

View file

@ -4,6 +4,7 @@ import json
import logging
import os
import platform
import random
import re
import subprocess
import sys
@ -89,15 +90,18 @@ def upload_asset(release, asset_to_upload, token):
while count < 10:
uploader = uploaders[count % len(uploaders)]
try:
return _upload_asset_requests(release, asset_to_upload, token, uploader)
return _upload_asset(release, asset_to_upload, token, uploader)
except Exception:
log.exception('Failed to upload')
count += 1
def _upload_asset_requests(release, asset_to_upload, token, uploader):
def _upload_asset(release, asset_to_upload, token, uploader):
basename = os.path.basename(asset_to_upload)
upload_uri = uritemplate.expand(release.upload_url, {'name': basename})
upload_uri = uritemplate.expand(
release.upload_url,
{'name': ''.join([random.choice('abcdef') for _ in range(10)])}
)
output = uploader(upload_uri, asset_to_upload, token)
if 'errors' in output:
raise Exception(output)