Dev Zone

HTTPS Download Scripting

Effective May 2016, http://gracenote.flexnetoperations.com no longer supports FTP downloads, however, HTTPS download scripting is supported. Below we have provided a sample HTTPS download script using Python, but virtually any scripting language will work. Note: The script also makes use of WGET (www.gnu.org/software/wget/), a software package for retrieving files using HTTP and HTTPS.

The following script will query http://gracenote.flexnetoperations.com for any file(s) the user has not previously downloaded then downloads the first one found.

Sample Script

#This script will search for any files not downloaded and download the first file found in the XML file. If you receive an error on downloading the XML file, there are no files to download

import xml.etree.ElementTree as etree
import subprocess
import os
###########
#Inputs
###########
#URL encoded password Enter your Flexnetoperations Password
password="password"
#URL encoded email Enter your Flexnetoperations username (email address)
email="my@emailadress.com"
#Note: If you have multiple accounts on gracenote.flexnetoperations.com, you will also need to provide your AccountID (example: "xx-1234")
#accountID="xx-1234"

#fileNotDownloadURL without AccountID (for users with only 1 account)
fileNotDownloadURL = 'wget64.exe -q -L -O test.xml "https://gracenote.flexnetoperations.com/control/grac/login?username='+email+'&password='+password+'&action=authenticate&nextURL=%2Fcontrol%2Fgrac%2FfilesNotDownloaded%3Faction%3Dxml"'

#fileNotDownloadURL including AccountID (for users with multiple accounts)
#fileNotDownloadURL = 'wget64.exe -q -L -O test.xml "https://gracenote.flexnetoperations.com/control/grac/login?username='+email+'&password='+password+'&action=authenticate&accountID='+accountID+'&nextURL=%2Fcontrol%2Fgrac%2FfilesNotDownloaded%3Faction%3Dxml"'

print(fileNotDownloadURL);

print(">>>Attempting to get all file NOT downloaded from FlexNet Cloud....")
subprocess.run(fileNotDownloadURL, shell=True)
print(">>>Processing response....")
tree = etree.parse('test.xml')
root = tree.getroot()
#for File in root.iter('File'):
      #for child in File:
           #print(child.tag +": "+ child.text)
      #print("-------")
os.makedirs(root[0][0].text+"/"+root[0][1].text+"/"+root[0][2].text+"/" + root[0][3].text, exist_ok=True)
path = root[0][0].text+"/"+root[0][1].text+"/"+root[0][2].text+"/" + root[0][3].text+"/"+root[0][4].text
print(root[0][5].text)
print(">>>Attempting to download file....")
subprocess.run("wget64.exe -q -L -O \""+path+"\" \"" + root[0][5].text+"\"",shell=True)
print(">>>Done downloading file....")