sort before uploading assets
This commit is contained in:
parent
0526a2b120
commit
fb8c743d3b
@ -4,32 +4,31 @@ import os
|
|||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
import uritemplate
|
import uritemplate
|
||||||
|
import glob
|
||||||
|
|
||||||
sys.path.append("adabot")
|
sys.path.append("adabot")
|
||||||
import github_requests as github
|
import github_requests as github
|
||||||
|
|
||||||
exit_status = 0
|
exit_status = 0
|
||||||
|
|
||||||
for dirpath, dirnames, filenames in os.walk("../bin"):
|
filepaths = list(glob.iglob('../bin/*/*', recursive=True))
|
||||||
if not filenames:
|
filepaths.sort()
|
||||||
continue
|
|
||||||
for filename in filenames:
|
for full_filename in filepaths:
|
||||||
full_filename = os.path.join(dirpath, filename)
|
filename = os.path.basename(full_filename)
|
||||||
label = filename.replace("adafruit-circuitpython-", "")
|
url_vars = {}
|
||||||
url_vars = {}
|
url_vars["name"] = filename
|
||||||
url_vars["name"] = filename
|
url = uritemplate.expand(os.environ["UPLOAD_URL"], url_vars)
|
||||||
url_vars["label"] = label
|
headers = {"content-type": "application/octet-stream"}
|
||||||
url = uritemplate.expand(os.environ["UPLOAD_URL"], url_vars)
|
print(url)
|
||||||
headers = {"content-type": "application/octet-stream"}
|
with open(full_filename, "rb") as f:
|
||||||
print(url)
|
response = github.post(url, data=f, headers=headers)
|
||||||
with open(full_filename, "rb") as f:
|
if not response.ok:
|
||||||
response = github.post(url, data=f, headers=headers)
|
if response.status_code == 422 and response.json().get("errors", [{"code":""}])[0]["code"] == "already_exists":
|
||||||
if not response.ok:
|
print("File already uploaded. Skipping.")
|
||||||
if response.status_code == 422 and response.json().get("errors", [{"code":""}])[0]["code"] == "already_exists":
|
continue
|
||||||
print("File already uploaded. Skipping.")
|
print("Upload of {} failed with {}.".format(filename, response.status_code))
|
||||||
continue
|
print(response.text)
|
||||||
print("Upload of {} failed with {}.".format(filename, response.status_code))
|
sys.exit(response.status_code)
|
||||||
print(response.text)
|
|
||||||
sys.exit(response.status_code)
|
|
||||||
|
|
||||||
sys.exit(exit_status)
|
sys.exit(exit_status)
|
||||||
|
Loading…
Reference in New Issue
Block a user