Python scripting downloader - Scripts

downloadStarter

 

The downloadStarter script is loading the python environment for the download. It will try to initialize the provided downloader. If the instance of the actual downloader cannot be created, the script will return. If the instantiation is successful, the script will loop over the program and call the handlers for Program, OperationGroup and Operation.

 

The script is part of the FASTSUITE Edition 2 installation and may not be modified.


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)

 


Previous
Page précédente
Chapter
Page principale du chapitre
Next
Page suivante