def downloadFile(self, srcPathAndFilename, targetLocation, targetFilename): """ Download a file from the IxLoad gateway server. For IxLoad version 8.50+ Syntax: https://ip:8443/api/v1/downloadResource?localPath=/mnt/ixload-share/ Parameters: localOS: Linux | Windows: The operating system of the machine that you're running the script. srcPathAndFilename: The src path from where to download the file targetLocation: The path to download the file to targetFilename: The filename for the downloaded file """ versionMatch = re.match('([0-9]+\.[0-9]+)', self.ixLoadVersion) if float((versionMatch.group(1))) < float(8.5): self.logInfo('Your IxLoad version {} does not have the rest api to download files. You need version 8.50 or greater'.format(self.ixLoadVersion)) return self.logInfo('downloadFile src:{} -> {} -> {}'.format(srcPathAndFilename, targetLocation, targetFilename)) url = '{}/api/{}/downloadResource?localPath={}'.format(self.httpHeader, self.apiVersion, srcPathAndFilename) if platform.system() == 'Windows': targetFileLocation = '{}\\{}'.format(targetLocation, targetFilename) else: targetFileLocation = '{}/{}'.format(targetLocation, targetFilename) with self.get(url, downloadStream=True) as response: response.raise_for_status() with open(targetFileLocation,'wb')as fileObj: for chunk in response.iter_content(chunk_size=8192): fileObj.write(chunk)