Skip to content

Instantly share code, notes, and snippets.

@djmitche
Created November 2, 2019 17:12
Show Gist options
  • Save djmitche/08c06c8a6a310a28f6c040ace2dbca97 to your computer and use it in GitHub Desktop.
Save djmitche/08c06c8a6a310a28f6c040ace2dbca97 to your computer and use it in GitHub Desktop.
import json
import sys
import os
import urllib.request
def main():
rootUrl = os.environ["TASKCLUSTER_ROOT_URL"]
workerPoolId = sys.argv[1]
apiUrl = rootUrl + "/api/worker-manager/v1/workers/" + workerPoolId
continuationToken = None
while True:
url = apiUrl + "?limit=100"
if continuationToken:
url += "&continuationToken={}".format(continuationToken)
with urllib.request.urlopen(url) as res:
data = json.loads(res.read())
for worker in data["workers"]:
print(json.dumps(worker, sort_keys=True, indent=4))
if "continuationToken" in data:
continuationToken = data["continuationToken"]
else:
break
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment