def downloadFiles(report_name, script):
""" Download a specific file in a report project """
#TODO add a check on the class variable DOWNLOAD to check if the module is downloadable (by default it is the case)
requestParams = getHttpParams(request)
if '.' not in script:
# We assume it is a python script
script = "%s.py" % script
if report_name.startswith("_"):
pathDirectory = os.path.join(current_app.config['ROOT_PATH'], config.ARES_FOLDER, 'reports')
else:
pathDirectory = config.ARES_USERS_LOCATION
if '&' in script:
splitScriptPath = script.strip("\\").split("&")
userDirectory = os.path.join(pathDirectory, report_name, *splitScriptPath[:-1])
else:
splitScriptPath = [script]
userDirectory = os.path.join(pathDirectory, report_name)
return send_from_directory(userDirectory, splitScriptPath[-1], as_attachment=True)
评论列表
文章目录