Skip to content

Instantly share code, notes, and snippets.

@wolfv
Created December 6, 2020 07:55
Show Gist options
  • Save wolfv/685166dbb83e1cf6c10e0fcf265fd87d to your computer and use it in GitHub Desktop.
Save wolfv/685166dbb83e1cf6c10e0fcf265fd87d to your computer and use it in GitHub Desktop.
Delete from Anaconda channel
import requests
import json
repodata = requests.get("http://conda.anaconda.org/robostack/osx-64/repodata.json")
repodata = repodata.json()
def delete_url(owner_login, key, repodata):
item = repodata["packages"][key]
package_name = item["name"]
version = item["version"]
basename = key
subdir = repodata["info"]["subdir"]
basename = f"{subdir}/{key}"
return f"https://api.anaconda.org/dist/{owner_login}/{package_name}/{version}/{basename}"
for pkg, item in repodata["packages"].items():
if item["build_number"] == 3:
# print(item)
print(delete_url("robostack", pkg, repodata))
token = '<INSERT TOKEN>'
res = requests.delete(delete_url("robostack", pkg, repodata), headers={'Authorization': 'token ' + token})
print(res.status_code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment