Beispiel #1
0
def makeRunScript(scriptFile,
                  workflowModulePath,
                  workflowClassName,
                  primaryConfigSection,
                  configSections,
                  pythonBin=None):
    """
    This function generates the python workflow runscript

    The auto-generated python script presents the user with options to
    run and/or continue their workflow, and reads all workflow
    configuration info from an ini file.

    scriptFile -- file name of the runscript to create
    workflowModulePath -- the python module containing the workflow class
    workflowClassName -- the workflow class name
    primaryConfigSection -- the section used to create the primary workflow parameter object
    configSections -- a hash or hashes representing all configuration info
    @param pythonBin: optionally specify a custom python interpreter for the script she-bang
    """

    assert os.path.isdir(os.path.dirname(scriptFile))
    assert os.path.isfile(workflowModulePath)

    workflowModulePath = os.path.abspath(workflowModulePath)
    workflowModuleDir = os.path.dirname(workflowModulePath)
    workflowModuleName = os.path.basename(workflowModulePath)
    pyExt = ".py"
    if workflowModuleName.endswith(pyExt):
        workflowModuleName = workflowModuleName[:-len(pyExt)]

    # dump inisections to a file
    pickleConfigFile = scriptFile + ".config.pickle"
    pickleConfigSections(pickleConfigFile, configSections)

    sfp = open(scriptFile, "w")

    if pythonBin is None:
        pythonBin = "/usr/bin/env python2"

    sfp.write(runScript1 % (pythonBin, " ".join(
        sys.argv), workflowModuleDir, workflowModuleName, workflowClassName))

    sfp.write('\n')
    sfp.write(runScript2)
    sfp.write('\n')
    sfp.write(runScript3)
    sfp.write('\n')

    sfp.write('main(r"%s","%s",%s)\n' %
              (pickleConfigFile, primaryConfigSection, workflowClassName))
    sfp.write('\n')
    sfp.close()
    os.chmod(scriptFile, 0755)
Beispiel #2
0
def makeRunScript(scriptFile, workflowModulePath, workflowClassName, primaryConfigSection, configSections, pythonBin=None) :
    """
    This function generates the python workflow runscript

    The auto-generated python script presents the user with options to
    run and/or continue their workflow, and reads all workflow
    configuration info from an ini file.

    scriptFile -- file name of the runscript to create
    workflowModulePath -- the python module containing the workflow class
    workflowClassName -- the workflow class name
    primaryConfigSection -- the section used to create the primary workflow parameter object
    configSections -- a hash or hashes representing all configuration info
    @param pythonBin: optionally specify a custom python interpreter for the script she-bang
    """

    assert os.path.isdir(os.path.dirname(scriptFile))
    assert os.path.isfile(workflowModulePath)

    workflowModulePath=os.path.abspath(workflowModulePath)
    workflowModuleDir=os.path.dirname(workflowModulePath)
    workflowModuleName=os.path.basename(workflowModulePath)
    pyExt=".py"
    if workflowModuleName.endswith(pyExt) :
        workflowModuleName=workflowModuleName[:-len(pyExt)]

    # dump inisections to a file
    pickleConfigFile=scriptFile+".config.pickle"
    pickleConfigSections(pickleConfigFile,configSections)

    sfp=open(scriptFile,"w")

    if pythonBin is None :
        pythonBin="/usr/bin/env python"

    sfp.write(runScript1 % (pythonBin, " ".join(sys.argv),workflowModuleDir,workflowModuleName,workflowClassName))

    sfp.write('\n')
    sfp.write(runScript2)
    sfp.write('\n')
    sfp.write(runScript3)
    sfp.write('\n')

    sfp.write('main(r"%s","%s",%s)\n' % (pickleConfigFile, primaryConfigSection, workflowClassName))
    sfp.write('\n')
    sfp.close()
    os.chmod(scriptFile,0755)