def testGetWorkflowStatus(self):
     # Workflow status    
     st = reqMgr.getWorkflowStatus(url, testwf)
     if st is None:"None status")
     if st not in VALID_STATUS:"%s not a valid state"%st)
def closeOutStep0Requests(url, workflows):
    Closes either montecarlo step0 requests
    noSiteWorkflows = []
    for workflow in workflows:
        datasets = reqMgrClient.outputdatasetsWorkflow(url, workflow)
        status = reqMgrClient.getWorkflowStatus(url, workflow)
        #if not completed skip
        if status != 'completed':
        closeOutWorkflow = True
        #skip montecarlos on a special queue
        if reqMgrClient.getRequestTeam(url, workflow) == 'analysis':
        for dataset in datasets:
            closeOutDataset = False
            percentage = percentageCompletion(url, workflow, dataset)
            phedexSubscription = phedexClient.getCustodialMoveSubscriptionSite(dataset)
            transPerc = 0
            closedBlocks = None
            duplicate = None
            correctLumis = None
            # if dataset has subscription and enough events we check
            # duplicates, transfer percentage, closed blocks and lumis
            if phedexSubscription and percentage >= float(0.95):
                transPerc = phedexClient.getTransferPercentage(url, dataset, phedexSubscription)
                duplicate = dbs3Client.duplicateLumi(dataset)
                correctLumis = checkCorrectLumisEventGEN(dataset)
                #TODO validate closed blocks
                if not duplicate and correctLumis:
                    closeOutDataset = True
                    closeOutDataset = False
            #validate when percentage is ok but has not phedex subscription
            if percentage >= float(0.95) and not phedexSubscription:
            #if at least one dataset is not ready wf cannot be closed out
            closeOutWorkflow = closeOutWorkflow and closeOutDataset
            print '| %80s | %100s | %4s | %5s| %3s | %5s| %5s| ' % (workflow, dataset,str(int(percentage*100)),
                        str(phedexSubscription), str(correctLumis), duplicate, closeOutDataset)
        #workflow can only be closed out if all datasets are ready
        if closeOutWorkflow:
            reqMgrClient.closeOutWorkflowCascade(url, workflow)
    print '-'*180
    return noSiteWorkflows
def filterUndealtWorkflows(workflowsCompleted, workflowsRunning, wfType):
    Filter's workflows that have no acdc running
    wfs = workflowsCompleted[wfType]
    result = []
    #check for everyone if it has one runnign with the same strng name
    for wf in wfs:
        reqString = getRequestString(wf)
        #check how many acdcs have
        #print wf
        if reqString in workflowsRunning:
            #print workflowsRunning[reqString]
            #print 'no acdcs running'
            #retrieve status to double validate
            status = reqMgrClient.getWorkflowStatus(url, wf)
            if status == 'completed':
    return result