Exemplo n.º 1
0
 def processCommandLineVersion(self):
     EDVerbose.DEBUG("EDApplication.processCommandLineVersion")
     if (self.__edCommandLine.existCommand(EDApplication.VERSION_PARAM_LABEL_1) or
         self.__edCommandLine.existCommand(EDApplication.VERSION_PARAM_LABEL_2)):
         EDVerbose.setVerboseOn()
         EDVerbose.screen("%s version %s" % (self.__strName, self.__strVersion))
         self.__bIsFailure = True
Exemplo n.º 2
0
 def processCommandLineHelp(self):
     EDVerbose.DEBUG("EDApplication.processCommandLineHelp")
     if (self.__edCommandLine.existCommand(EDApplication.HELP_LABEL_1)
         or self.__edCommandLine.existCommand(EDApplication.HELP_LABEL_2)):
         EDVerbose.setVerboseOn()
         self.usage()
         self.__bIsFailure = True
Exemplo n.º 3
0
 def processCommandLineDebugVerboseLogFile(self):
     EDVerbose.DEBUG("EDApplication.processCommandLineDebugVerboseLogFile")
     EDVerbose.setVerboseOff()
     # Check if no log file
     if (self.__edCommandLine.existCommand(EDApplication.NO_LOG_LABEL)):
         EDVerbose.setLogFileOff()
         EDVerbose.DEBUG("Log file output switched off")
     # Check if debug mode
     if (self.__edCommandLine.existCommand(EDApplication.DEBUG_PARAM_LABEL_1) or
         self.__edCommandLine.existCommand(EDApplication.DEBUG_PARAM_LABEL_2)):
         EDVerbose.setVerboseDebugOn()
         EDVerbose.DEBUG("Debug Mode [ON]")
     # Check if verbose
     if (self.__edCommandLine.existCommand(EDApplication.VERBOSE_MODE_LABEL)):
         EDVerbose.setVerboseOn()
Exemplo n.º 4
0
from XSDataISPyBv1_4 import XSDataInputStoreAutoProc
from XSDataISPyBv1_4 import AutoProcContainer


def successAction(self, _edObject=None):
    EDVerbose.screen("XML data sucessfully stored in ISPyB")

def failureAction(self, _edObject=None):
    EDVerbose.ERROR("XML data not stored in ISPyB")

if __name__ == '__main__':
    strCwd = os.getcwd()
    strPathToTempDir = tempfile.mkdtemp(prefix="edna-autoproc2ispyb_")
    os.chdir(strPathToTempDir)
    EDVerbose.setVerboseOn()
    EDVerbose.setLogFileName(os.path.join(strPathToTempDir, "edna.log"))
    # Populate input data
    EDVerbose.DEBUG("Arguments: %r" % sys.argv)
    bVerbose = False
    bDebug = False
    listPaths = []
    for iIndex, strArg in enumerate(sys.argv[1:]):
        strarg = strArg.lower()
        if strarg == "--verbose":
            EDVerbose.setVerboseOn()
        elif strarg == "--debug":
            EDVerbose.setVerboseDebugOn()
        strArgPath = strArg
        if os.path.dirname(strArgPath) == "":
            strArgPath = os.path.join(strCwd, strArg)
Exemplo n.º 5
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)
Exemplo n.º 6
0
from XSDataISPyBv1_3 import XSDataInputStoreAutoProc
from XSDataISPyBv1_3 import AutoProcContainer


def successAction(self, _edObject=None):
    EDVerbose.screen("XML data sucessfully stored in ISPyB")

def failureAction(self, _edObject=None):
    EDVerbose.ERROR("XML data not stored in ISPyB")

if __name__ == '__main__':
    strCwd = os.getcwd()
    strPathToTempDir = tempfile.mkdtemp(prefix="edna-autoproc2ispyb_")
    os.chdir(strPathToTempDir)
    EDVerbose.setVerboseOn()
    EDVerbose.setLogFileName(os.path.join(strPathToTempDir, "edna.log"))
    # Populate input data
    EDVerbose.DEBUG("Arguments: %r" % sys.argv)
    bVerbose = False
    bDebug = False
    listPaths = []
    for iIndex, strArg in enumerate(sys.argv[1:]):
        strarg = strArg.lower()
        if strarg == "--verbose":
            EDVerbose.setVerboseOn()
        elif strarg == "--debug":
            EDVerbose.setVerboseDebugOn()
        strArgPath = strArg
        if os.path.dirname(strArgPath) == "":
            strArgPath = os.path.join(strCwd, strArg)
Exemplo n.º 7
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)