Skip to content

Instantly share code, notes, and snippets.

@johnpmitsch
Created February 15, 2018 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnpmitsch/0297e7b0c6ac7e261dbfd559d4903133 to your computer and use it in GitHub Desktop.
Save johnpmitsch/0297e7b0c6ac7e261dbfd559d4903133 to your computer and use it in GitHub Desktop.
Get SUSE repos using subscription registration code
#!/usr/bin/python
# Usage: ./get_suse_repos MYTOKEN
import requests
import json
import sys
url = "https://scc.suse.com/connect/subscriptions/products"
headers = {"Authorization": "Token token={0}".format(sys.argv[1])}
print("Fetching repos...")
r = requests.get(url, headers=headers)
if r.status_code == 200:
scc = r.json()
for entitlement in scc:
for repo in entitlement['repositories']:
feed, token = repo['url'].split('?')
print(repo['name'])
print('- Feed: {}'.format(feed))
print('- Token: {}'.format(token))
else:
print("ERROR!")
print(r.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment