def DownloadActiveProgram(operator : DULPythonDownloadOperator):
""" This method is the entry point in to the download process. It will be called
by the E2 embedded python interpreter.
The method will try to initialize the loaded Downloader and loop through the program.
operator: download operator providing all necessary data for the download
"""
logger = operator.GetLogOperator()
logger.LogDebug("Starting Downloader")
#### Get the class name of the downloader from globals and instantiate
downloaderClass = "no_name"
try:
downloaderClass = globals()[DOWNLOAD_CLASS_NAME]
except:
logger.LogError("Downloader class name is not set! Aborting download.")
return
downloader = downloaderClass()
if downloader is None:
logger.LogError("Could not initialize downloader class. Aborting download.")
return
downloader.Initialize(operator)
controller = operator.GetController()
program = controller.GetActiveProgram()
#### Output a general header in file(s) if needed
HandleProgram(downloader, operator, controller, program)
# Handle Subprograms in separate program file
if downloader.OutputSubprogramInSeparateFiles():
subprogramList = []
for subprogram in program.GetSubprograms():
calledProgram = subprogram.GetCalledProgram()
# do not handle a subprogram twice
if calledProgram.GetName() not in subprogramList:
subprogramList.append(calledProgram.GetName())
HandleProgram(downloader, operator, controller, calledProgram)
|