Ejemplo n.º 1
0
    def unitTestExecute(self):
        """
        check the execution of a job (without callback)
        """
        EDVerbose.DEBUG("EDTestCaseEDJob.unitTestExecute")
        edJob = EDJob(self.strPluginName)
        strJobId = edJob.getJobId()
        edJob.setDataInput(self.strXmlInput)
        ref = edJob.execute()
        EDAssert.equal(strJobId, ref, "JobId has not changed")
        strStatus = edJob.getStatus()
        EDVerbose.WARNING("Job %s in State %s" % (strJobId, strStatus))

        while strStatus in ["running", "uninitialized"]:
            EDVerbose.WARNING("Job %s in state %s" % (strJobId, strStatus))
            time.sleep(0.01)
            strStatus = edJob.getStatus()

        xsdOut = edJob.getDataOutput()
        while xsdOut is None:
            EDVerbose.WARNING("No Output data, still waiting for output data to arrive, %s" % edJob.getStatus())
            time.sleep(0.01)
            xsdOut = edJob.getDataOutput()
        strOutput = xsdOut.strip()
        strStatus = edJob.getStatus()
        while strStatus == "running":
            EDVerbose.WARNING("Job %s is still in state %s" % (strJobId, strStatus))
            time.sleep(0.01)
            strStatus = edJob.getStatus()

        EDAssert.equal(strOutput, self.strXmlInput, "Output is OK")
        EDAssert.equal("success", edJob.getStatus(), "Job %s is finished with ''success''" % edJob.getJobId())
Ejemplo n.º 2
0
    def unitTestExecute(self):
        """
        check the execution of a job (without callback)
        """
        EDVerbose.DEBUG("EDTestCaseEDJob.unitTestExecute")
        edJob = EDJob(self.strPluginName)
        strJobId = edJob.getJobId()
        edJob.setDataInput(self.strXmlInput)
        ref = edJob.execute()
        EDAssert.equal(strJobId, ref, "JobId has not changed")
        strStatus = edJob.getStatus()
        EDVerbose.WARNING("Job %s in State %s" % (strJobId, strStatus))

        while strStatus in ["running", "uninitialized"]:
            EDVerbose.WARNING("Job %s in state %s" % (strJobId, strStatus))
            time.sleep(0.01)
            strStatus = edJob.getStatus()

        xsdOut = edJob.getDataOutput()
        while xsdOut is None:
            EDVerbose.WARNING("No Output data, still waiting for output data to arrive, %s" % edJob.getStatus())
            time.sleep(0.01)
            xsdOut = edJob.getDataOutput()
        strOutput = xsdOut.strip()
        strStatus = edJob.getStatus()
        while strStatus == "running":
            EDVerbose.WARNING("Job %s is still in state %s" % (strJobId, strStatus))
            time.sleep(0.01)
            strStatus = edJob.getStatus()

        EDAssert.equal(strOutput, self.strXmlInput, "Output is OK")
        EDAssert.equal("success", edJob.getStatus(), "Job %s is finished with ''success''" % edJob.getJobId())
Ejemplo n.º 3
0
 def unitTestSetGetData(self):
     """
     check the status after a job creation
     """
     EDVerbose.DEBUG("EDTestCaseEDJob.unitTestSetGetData")
     edJob = EDJob(self.strPluginName)
     edJob.setDataInput(self.strXmlInput)
     EDAssert.equal(self.strXmlInput, edJob.getDataInput().strip(), "Data Input is correctly set")
     EDAssert.equal("uninitialized", edJob.getStatus(), "Job %s is still ''uninitialized''" % edJob.getJobId())
Ejemplo n.º 4
0
 def unitTestSetGetData(self):
     """
     check the status after a job creation
     """
     EDVerbose.DEBUG("EDTestCaseEDJob.unitTestSetGetData")
     edJob = EDJob(self.strPluginName)
     edJob.setDataInput(self.strXmlInput)
     EDAssert.equal(self.strXmlInput, edJob.getDataInput().strip(), "Data Input is correctly set")
     EDAssert.equal("uninitialized", edJob.getStatus(), "Job %s is still ''uninitialized''" % edJob.getJobId())
Ejemplo n.º 5
0
 def unitTestInitialState(self):
     """
     check the status after a job creation
     """
     EDVerbose.DEBUG("EDTestCaseEDJob.unitTestInitialState")
     edJob = EDJob(self.strPluginName)
     strJobId = edJob.getJobId()
     EDVerbose.DEBUG("EDJobId is: %s" % strJobId)
     EDAssert.equal(2, len(strJobId.split("-")), "JobID is composed of 2 parts")
     EDAssert.equal(True, strJobId.split("-")[1].isdigit(), "JobID's second part is an integer")
     EDAssert.equal("uninitialized", edJob.getStatus(), "Initial stat is ''uninitialized''")
Ejemplo n.º 6
0
 def unitTestExecuteCallbackSuccess(self):
     """
     check the execution of a job (without callback)
     """
     EDVerbose.DEBUG("EDTestCaseEDJob.unitTestExecuteCallbackSuccess")
     edJob = EDJob(self.strPluginName)
     edJob.connectSUCCESS(self.callBack)
     edJob.setDataInput(self.strXmlInput)
     strJobId = edJob.execute()
     strStatus = edJob.getStatus()
     EDVerbose.DEBUG("Job %s in State ''%s''" % (strJobId, strStatus))
Ejemplo n.º 7
0
 def unitTestInitialState(self):
     """
     check the status after a job creation
     """
     EDVerbose.DEBUG("EDTestCaseEDJob.unitTestInitialState")
     edJob = EDJob(self.strPluginName)
     strJobId = edJob.getJobId()
     EDVerbose.DEBUG("EDJobId is: %s" % strJobId)
     EDAssert.equal(2, len(strJobId.split("-")), "JobID is composed of 2 parts")
     EDAssert.equal(True, strJobId.split("-")[1].isdigit(), "JobID's second part is an integer")
     EDAssert.equal("uninitialized", edJob.getStatus(), "Initial stat is ''uninitialized''")
Ejemplo n.º 8
0
 def unitTestExecuteCallbackSuccess(self):
     """
     check the execution of a job (without callback)
     """
     EDVerbose.DEBUG("EDTestCaseEDJob.unitTestExecuteCallbackSuccess")
     edJob = EDJob(self.strPluginName)
     edJob.connectSUCCESS(self.callBack)
     edJob.setDataInput(self.strXmlInput)
     strJobId = edJob.execute()
     strStatus = edJob.getStatus()
     EDVerbose.DEBUG("Job %s in State ''%s''" % (strJobId, strStatus))
Ejemplo n.º 9
0
def runEdnaPlugin(execPath, pluginName, isDebug, xml, additionalPaths=None):
    
    '''
    execPath     - path to run plugin in
    pluginName   - plugin name
    isDebug      - True if should run edna in debug mode
    xml          - xml input to edna
    additionalPaths - list of other python path locations
    
    You must set EDNA_HOME to use this method
    This method blocks until the EDJob has reached a final status
    
    '''

    if (not 'EDNA_HOME' in os.environ):
        raise Exception("Cannot locate EDNA_HOME. Please set before running Edna plugins.")
    
    if (not 'EDNA_SITE' in os.environ):
        raise Exception(" Please set EDNA_SITE before running Edna plugins.")

    '''
    Add edna to path
    '''
    ednaKernelPath = os.environ['EDNA_HOME']+"/kernel/src"
    sys.path.insert(0, ednaKernelPath)
    
    '''
    If there are any additional paths such as fabio, add these
    '''
    if (not additionalPaths is None and len(additionalPaths)>0):
        for path in additionalPaths:
            sys.path.append(path)
    
    os.chdir(execPath)
    from EDVerbose import EDVerbose
    if (isDebug):
        EDVerbose.setVerboseDebugOn()
    else:
        EDVerbose.setVerboseOn()            
        EDVerbose.setVerboseDebugOff()
        
    from EDJob import EDJob
    
    EDVerbose.setLogFileName(execPath+"/"+pluginName+".log")           
    
    edJob = EDJob(pluginName)
    edJob.setDataInput(xml)
    edJob.execute()
    edJob.synchronize() # In theory should mean that the following loop is not needed
    
    # Unhelpful way of waiting for EDJob to be finished
    # TODO Fix this in EDJob some time
    while(True):
        status = edJob.getStatus()
        if (status is None):
            time.sleep(0.2) # 200 ms
            continue
        
        if ("failure" == status):
            raise Exception("EDJob failed! ")
        
        if ("success" == status):
            break
    
    ret = edJob.getDataOutput()
    
    return str(ret)
Ejemplo n.º 10
0
def runEdnaPlugin(execPath, pluginName, isDebug, xml, additionalPaths=None):
    '''
    execPath     - path to run plugin in
    pluginName   - plugin name
    isDebug      - True if should run edna in debug mode
    xml          - xml input to edna
    additionalPaths - list of other python path locations
    
    You must set EDNA_HOME to use this method
    This method blocks until the EDJob has reached a final status
    
    '''

    if (not 'EDNA_HOME' in os.environ):
        raise Exception(
            "Cannot locate EDNA_HOME. Please set before running Edna plugins.")

    if (not 'EDNA_SITE' in os.environ):
        raise Exception(" Please set EDNA_SITE before running Edna plugins.")
    '''
    Add edna to path
    '''
    ednaKernelPath = os.environ['EDNA_HOME'] + "/kernel/src"
    sys.path.insert(0, ednaKernelPath)
    '''
    If there are any additional paths such as fabio, add these
    '''
    if (not additionalPaths is None and len(additionalPaths) > 0):
        for path in additionalPaths:
            sys.path.append(path)

    os.chdir(execPath)
    from EDVerbose import EDVerbose
    if (isDebug):
        EDVerbose.setVerboseDebugOn()
    else:
        EDVerbose.setVerboseOn()
        EDVerbose.setVerboseDebugOff()

    from EDJob import EDJob

    EDVerbose.setLogFileName(execPath + "/" + pluginName + ".log")

    edJob = EDJob(pluginName)
    edJob.setDataInput(xml)
    edJob.execute()
    edJob.synchronize(
    )  # In theory should mean that the following loop is not needed

    # Unhelpful way of waiting for EDJob to be finished
    # TODO Fix this in EDJob some time
    while (True):
        status = edJob.getStatus()
        if (status is None):
            time.sleep(0.2)  # 200 ms
            continue

        if ("failure" == status):
            raise Exception("EDJob failed! ")

        if ("success" == status):
            break

    ret = edJob.getDataOutput()

    return str(ret)