#!/usr/bin/env python3
import json
import urllib.requestdef main():
baseurl = ‘http://127.0.0.1:8081/’
downloadRepository = ‘yum-internet’
url = baseurl + ‘browse/search/yum=repository_name%3D’ + downloadRepositoryresponse = urllib.request.urlopen(url) data = json.load(response) for item in data["items"]: for asset in item["assets"]: fileurl = asset["downloadUrl"] filename = downloadPath + fileurl.split('/')[-1] # '\' for Windows outfile = open(filename, "w") outfile.write(str(urllib.request.urlopen(fileurl).read())) outfile.close() if data["continuationToken"] is None: break else: # construct pagination url and loop url = baseurl + 'components?continuationToken=' + data["continuationToken"] + '&repository=' + downloadRepository
if__name__==“main”:
main()
I am trying to use this python file code to download the dependencies at the right URL of my nexus repo, but the main problem is that the following code is giving me errors for the line data = json.load(response) which resulted in the following output,
json.DecodeError Expecting value
. Tried using try except method but the line after that for item in data[items] resulted in the following output,
NameError: data is not defined
is the URL correct? I am a bit worried that I am doing it wrongly, thus all the error occurs.
any advice and help are appreciated, been working on this for ages. Thank you