def extract_exports()

in export.py [0:0]


def extract_exports(exports_info, agent_id, dir_name):
	logging.debug(str.format("extracting {}, url={}", exports_info['exportId'], exports_info['configurationsDownloadUrl']))
	zipped = download_with_retry(exports_info['configurationsDownloadUrl'])
	if zipped is None:
		msg = str.format("Unable to download {}", exports_info['configurationsDownloadUrl'])
		logging.error(msg)
		raise Exception(msg)
	# String representing start time of export
	actual_start = None
	actual_end = None
	export_meta = exporting_agents[agent_id]
	start_time, end_time, curr_id = export_meta[0], export_meta[1], export_meta[2]
	start_str = start_time.strftime('%Y-%m-%dT%H%M%SZ') + "_"
	with ZipFile(StringIO(zipped)) as zip_ref:
		for name in zip_ref.namelist():
			basename = os.path.basename(name)
			subdir = basename.split("_").pop().split(".")[0]
			if subdir == "results":
				json_file = zip_ref.open(name)
				d = json.load(json_file)
				if 'ActualEndTime' in d['ExportSummary']:
					actual_start = get_time(d['ExportSummary']['ActualStartTime'], True)
					actual_end = get_time(d['ExportSummary']['ActualEndTime'], True)
				# If 0 result files exported, may not have elements in ExportSummary so take requested as actual
				else:
					actual_start = get_time(d['RequestedStartTime'], True)
					actual_end = get_time(d['RequestedEndTime'], True)
			target_dir = os.path.join(dir_name, "agentExports", agent_id, subdir)
			try:
				os.makedirs(target_dir)
			except OSError: # already exists
				pass
			source = zip_ref.open(name)
			with open(os.path.join(target_dir, start_str + basename), 'w') as target:
				shutil.copyfileobj(source, target)
	return (actual_start, actual_end)