def getEnvironmentParams(): ''' In every case, keep default if no new envir var present.''' try: P.nRandomSeed = fnIntPlease(environ["RANDOMSEED"]) except (KeyError,TypeError,ValueError): pass try: P.nSimLength = fnIntPlease(environ["SIMLENGTH"]) except (KeyError,TypeError,ValueError): pass try: P.sLogFile = environ["LOG_FILE"] except KeyError: pass try: P.sLogLevel = environ["LOG_LEVEL"] except KeyError: pass P.nPoliteTimer = fnIntPlease(getenv("NPOLITE", P.nPoliteTimer)) G.nShockType = fnIntPlease(environ.get("SHELF_SHOCKTYPE", G.nShockType)) # Have to resolve some of these from P to G before considering the # CLI params that may override them, so that they can be # reported correctly. G.nSimLength = (P.nSimLength if P.nSimLength > 0 else P.nSimLengthDefault) G.nRandomSeed = P.nRandomSeed
def getEnvironmentParams(): ''' In every case, keep default if no new envir var present.''' try: P.nRandomSeed = fnIntPlease(environ["RANDOMSEED"]) except (KeyError, TypeError, ValueError): pass try: P.nSimLength = fnIntPlease(environ["SIMLENGTH"]) except (KeyError, TypeError, ValueError): pass try: P.sLogFile = environ["LOG_FILE"] except KeyError: pass try: P.sLogLevel = environ["LOG_LEVEL"] except KeyError: pass P.nPoliteTimer = fnIntPlease(getenv("NPOLITE", P.nPoliteTimer)) G.nShockType = fnIntPlease(environ.get("SHELF_SHOCKTYPE", G.nShockType)) # Have to resolve some of these from P to G before considering the # CLI params that may override them, so that they can be # reported correctly. G.nSimLength = (P.nSimLength if P.nSimLength > 0 else P.nSimLengthDefault) G.nRandomSeed = P.nRandomSeed
def fdGetParams(mysFile, mylGuide): ''' fdGetParams() Return a dictionary of entries from a CSV file according to the specified format. Generally, the dict has a string or int key and returns a list. The list may contain more lists. Remove blank lines and comment lines (#) Integers in this case drive me nucking futs. Everything from a CSV file is a string, but some of the dict keys returned and many of the dict values returned are to be used as ints. One must carefully convert anything that might look like an int to a real one. ''' dParams = dict() # If there is no file of the right name, then return None. try: fh = open(mysFile, "r") fh.close() except (ValueError, IOError): NTRC.ntracef(3, "READ", "proc fdGetParams1 file not found |%s|" % (mysFile)) dParams = None # If there is such a file, then parse it and return its dictionary. (sKey, lCols) = mylGuide if dParams == None: pass else: with open(mysFile, "rb") as fhInfile: lLines = fhInfile.readlines() # Remove comments and blank lines. for sLine in lLines[:]: if re.match("^ *#",sLine) \ or re.match("^ *$",sLine.rstrip()): lLines.remove(sLine) NTRC.ntracef( 3, "READ", "proc fdGetParams3 remove comment or blank line |%s|" % (sLine.strip())) # Now get the CSV args into a list of dictionaries. lRowDicts = csv.DictReader(lLines) for dRow in lRowDicts: dNewRow = dict() # Sanitize (i.e., re-integerize) the entire row dict, # keys and values, and use the new version. for xKey in dRow: dNewRow[fnIntPlease(xKey)] = fnIntPlease(dRow[xKey]) intKey = dNewRow[sKey] if intKey not in dParams: dParams[intKey] = [] lVal = list() for sCol in lCols: # Many of the values might be ints. lVal.append(dNewRow[sCol]) dParams[intKey].append(lVal) NTRC.ntracef( 5, "READ", "proc fdGetParams2 mylGuide|%s|dRow|%s|intKey|%s|lVal|%s|dParams|%s|" % (mylGuide, dRow, intKey, lVal, dParams)) return dParams
def fndProcessOneUserRule(mydInstructionDict, mysName, myxRule): ''' Use one user rule to remove value options from instructions. ''' try: lInsVals = mydInstructionDict[mysName] except KeyError: raise KeyError("Error: Unknown parameter name|%s|" % (mysName)) try: # sRule = str(myxRule).encode('ascii', 'ignore').replace('u"', '"') sRule = str(myxRule).replace('u"', '"') xResult = json.loads(sRule) except ValueError: raise ValueError("Error: Query string is not valid JSON|%s|" % (sRule)) # One last fixup: Maybe the rule is a string that did not get integer-ified. if not xResult: xResult = util.fnIntPlease(myxRule) if isinstance(xResult, int): lNewVals = [item for item in lInsVals if item == xResult] elif isinstance(xResult, list): lNewVals = [item for item in lInsVals if item in xResult] elif isinstance(xResult, dict): lCleanResult = [(k,util.fnIntPlease(v)) for (k,v) in xResult.items()] lNewVals = copy.deepcopy(lInsVals) for k,v in lCleanResult: if "$eq" == k: lNewVals = [item for item in lNewVals if item == v] elif "$ne" == k: lNewVals = [item for item in lNewVals if item != v] elif "$lt" == k: lNewVals = [item for item in lNewVals if item < v] elif "$lte" == k: lNewVals = [item for item in lNewVals if item <= v] elif "$gt" == k: lNewVals = [item for item in lNewVals if item > v] elif "$gte" == k: lNewVals = [item for item in lNewVals if item >= v] elif "$in" in xResult: raise NotImplementedError("$in") elif "$nin" in xResult: raise NotImplementedError("$nin") else: lNewVals = ["rule type not found"] raise ValueError("Error: unknown comparison operator|%s|" % (xResult)) mydInstructionDict[mysName] = lNewVals return mydInstructionDict
def fdGetParams(mysFile,mylGuide): ''' fdGetParams() Return a dictionary of entries from a CSV file according to the specified format. Generally, the dict has a string or int key and returns a list. The list may contain more lists. Remove blank lines and comment lines (#) Integers in this case drive me nucking futs. Everything from a CSV file is a string, but some of the dict keys returned and many of the dict values returned are to be used as ints. One must carefully convert anything that might look like an int to a real one. ''' dParams = dict() # If there is no file of the right name, then return None. try: fh = open(mysFile,"r") fh.close() except (ValueError, IOError): NTRC.ntracef(3,"READ","proc fdGetParams1 file not found |%s|" % (mysFile)) dParams = None # If there is such a file, then parse it and return its dictionary. (sKey,lCols) = mylGuide if dParams == None: pass else: with open(mysFile,"rb") as fhInfile: lLines = fhInfile.readlines() # Remove comments and blank lines. for sLine in lLines[:]: if re.match("^ *#",sLine) \ or re.match("^ *$",sLine.rstrip()): lLines.remove(sLine) NTRC.ntracef(3,"READ","proc fdGetParams3 remove comment or blank line |%s|" % (sLine.strip())) # Now get the CSV args into a list of dictionaries. lRowDicts = csv.DictReader(lLines) for dRow in lRowDicts: dNewRow = dict() # Sanitize (i.e., re-integerize) the entire row dict, # keys and values, and use the new version. for xKey in dRow: dNewRow[fnIntPlease(xKey)] = fnIntPlease(dRow[xKey]) intKey = dNewRow[sKey] if intKey not in dParams: dParams[intKey] = [] lVal = list() for sCol in lCols: # Many of the values might be ints. lVal.append(dNewRow[sCol]) dParams[intKey].append(lVal) NTRC.ntracef(5,"READ","proc fdGetParams2 mylGuide|%s|dRow|%s|intKey|%s|lVal|%s|dParams|%s|" % (mylGuide,dRow,intKey,lVal,dParams)) return dParams
def fndProcessOneUserRule(mydInstructionDict, mysName, myxRule): ''' Use one user rule to remove value options from instructions. ''' try: lInsVals = mydInstructionDict[mysName] except KeyError: raise KeyError("Error: Unknown parameter name|%s|" % (mysName)) try: # sRule = str(myxRule).encode('ascii', 'ignore').replace('u"', '"') sRule = str(myxRule).replace('u"', '"') xResult = json.loads(sRule) except ValueError: raise ValueError("Error: Query string is not valid JSON|%s|" % (sRule)) # One last fixup: Maybe the rule is a string that did not get integer-ified. if not xResult: xResult = util.fnIntPlease(myxRule) if isinstance(xResult, int): lNewVals = [item for item in lInsVals if item == xResult] elif isinstance(xResult, list): lNewVals = [item for item in lInsVals if item in xResult] elif isinstance(xResult, dict): lCleanResult = [(k, util.fnIntPlease(v)) for (k, v) in xResult.items()] lNewVals = copy.deepcopy(lInsVals) for k, v in lCleanResult: if "$eq" == k: lNewVals = [item for item in lNewVals if item == v] elif "$ne" == k: lNewVals = [item for item in lNewVals if item != v] elif "$lt" == k: lNewVals = [item for item in lNewVals if item < v] elif "$lte" == k: lNewVals = [item for item in lNewVals if item <= v] elif "$gt" == k: lNewVals = [item for item in lNewVals if item > v] elif "$gte" == k: lNewVals = [item for item in lNewVals if item >= v] elif "$in" in xResult: raise NotImplementedError("$in") elif "$nin" in xResult: raise NotImplementedError("$nin") else: lNewVals = ["rule type not found"] raise ValueError("Error: unknown comparison operator|%s|" % (xResult)) mydInstructionDict[mysName] = lNewVals return mydInstructionDict
def fnnProcessOneInstructionManyTimes(mynRunNumber, mydInstruction): ''' Process a single instruction (set of params) once for each of a predetermined number and sequence of random seeds. Assign an id to each run that consists of the instruction hash (_id) followed by _<seed number>. ''' lManyInstr = [] lSeedsToUse = fnlGetRandomSeeds(util.fnIntPlease(g.nRandomSeeds), g.sRandomSeedFile) mydInstruction["sBaseId"] = str(mydInstruction["_id"]) for (nIdx, nMaybeSeed) in enumerate(lSeedsToUse): # Adjust run number and mongo id because there are now # multiple seeds and runs per instruction. sRunId = str(mynRunNumber) + "." + str(nIdx + 1) sId = str(mydInstruction["sBaseId"]) mydInstruction["_id"] = sId + "_" + str(nIdx + 1) mydInstruction["_runid"] = sRunId nStatus = 0 try: nSeed = int(nMaybeSeed) except ValueError: raise ValueError("Random seed not integer |%s|" % (nMaybeSeed)) mydInstruction["nRandomseed"] = nSeed tOneInstr = fntProcessOneInstruction(sRunId, mydInstruction, nSeed) return g.nRandomSeeds
def fnltProcessOneInstructionManyTimes(mynRunNumber, mydInstruction): ''' Process a single instruction (set of params) once for each of a predetermined number and sequence of random seeds. Assign an id to each run that consists of the instruction hash (_id) followed by _<seed number>. ''' lManyInstr = [] lSeedsToUse = fnlGetRandomSeeds(util.fnIntPlease(g.nRandomSeeds), g.sRandomSeedFile) mydInstruction["sBaseId"] = str(mydInstruction["_id"]) for (nIdx, nMaybeSeed) in enumerate(lSeedsToUse): # Adjust run number and mongo id because there are now # multiple seeds and runs per instruction. sRunId = str(mynRunNumber) + "." + str(nIdx+1) sId = str(mydInstruction["sBaseId"]) mydInstruction["_id"] = sId + "_" + str(nIdx+1) mydInstruction["_runid"] = sRunId nStatus = 0 try: nSeed = int(nMaybeSeed) except ValueError: raise ValueError("Random seed not integer |%s|" % (nMaybeSeed)) mydInstruction["nRandomseed"] = nSeed tOneInstr = fntProcessOneInstruction(sRunId, mydInstruction, nSeed) lManyInstr.append(tOneInstr) return lManyInstr
def fnlGetRandomSeeds(mynHowMany, mysFilename): ''' Return a list of the first mynHowMany random seeds from the file specified. This is the primitive version that does not permit blank lines, comments, or other detritus in the list of seed numbers. ''' with open(mysFilename, "r") as fhSeeds: lsSeeds = [(next(fhSeeds)) for _ in range(mynHowMany)] lnSeeds = [util.fnIntPlease(_) for _ in lsSeeds] return lnSeeds
def fnlGetRandomSeeds(mynHowMany, mysFilename): ''' Return a list of the first mynHowMany random seeds from the file specified. This is the primitive version that does not permit blank lines, comments, or other detritus in the list of seed numbers. ''' with open(mysFilename, "r") as fhSeeds: lsSeeds = [(next(fhSeeds)) for _ in range(mynHowMany)] lnSeeds = [util.fnIntPlease(_) for _ in lsSeeds] return lnSeeds
def fndReadAllInsFiles(mysDir, mysTyp): ''' Get contents of all the instruction files into a dictionary. Use the new new new instruction format, 3 columns, and extract and reformat the value info from that. ''' dInstructions = dict() for sFile in os.listdir(mysDir): if sFile.endswith(mysTyp): (sName, _, lValueList) = fntReadOneFileForGUI(mysDir+'/'+sFile) dInstructions[sName] = [util.fnIntPlease(item["value"]) for item in lValueList] if len([k for k in dInstructions.keys()]) == 0: raise ValueError("No instruction files for type|%s|" % (mysTyp)) return dInstructions
def fntReadOneFile(mysFilespec): ''' Read one instruction file into a list with separate header name. All the values in the list are integer-ized where possible. WARNING: the single-column instruction files and this routine are OBSOLETE. Fatal error if called. ''' raise NotImplementedError("Old-format .ins files are now obsolete.") with open(mysFilespec, "r") as fhInsfile: lLines = [sLine.rstrip() for sLine in fhInsfile if not re.match("^\s*$", sLine) and not re.match("^\s*#", sLine)] sName = lLines.pop(0) lValueList = [util.fnIntPlease(line) for line in lLines] return (sName, lValueList)
def fndReadAllInsFiles(mysDir, mysTyp): ''' Get contents of all the instruction files into a dictionary. Use the new new new instruction format, 3 columns, and extract and reformat the value info from that. ''' dInstructions = dict() for sFile in os.listdir(mysDir): if sFile.endswith(mysTyp): (sName, _, lValueList) = fntReadOneFileForGUI(mysDir + '/' + sFile) dInstructions[sName] = [ util.fnIntPlease(item["value"]) for item in lValueList ] if len([k for k in dInstructions.keys()]) == 0: raise ValueError("No instruction files for type|%s|" % (mysTyp)) return dInstructions
def fntReadOneFile(mysFilespec): ''' Read one instruction file into a list with separate header name. All the values in the list are integer-ized where possible. WARNING: the single-column instruction files and this routine are OBSOLETE. Fatal error if called. ''' raise NotImplementedError("Old-format .ins files are now obsolete.") with open(mysFilespec, "r") as fhInsfile: lLines = [ sLine.rstrip() for sLine in fhInsfile if not re.match("^\s*$", sLine) and not re.match("^\s*#", sLine) ] sName = lLines.pop(0) lValueList = [util.fnIntPlease(line) for line in lLines] return (sName, lValueList)
def main(): ''' Process: - Parse the CLI command into g.various data items. - Validate user-supplied directories; get environment variables. - Make queues to send instructions to pool of worker processes. - Create pool of worker processes. - Query the searchspace for the stream of instructions - For each instruction from database selection, get dict for line - Using dict args, construct plausible command lines, into file - For each instruction, expand to the number of samples (seeds) to use. - When we finally have a single instruction to execute, queue that to the worker jobs. - When all instructions have been queued, close down the worker processes. ''' NTRC.ntracef(0, "MAIN", "Begin.") NTRC.ntracef(0, "MAIN", "TRACE traceproduction|%s|" % NTRC.isProduction()) sBrokerCommand = fnsReconstituteCommand(sys.argv) fnbMaybeLogCommand(sBrokerCommand) NTRC.ntracef(0, "MAIN", "command=|%s|" % (sBrokerCommand.rstrip())) # Get args from CLI and put them into the global data dCliDict = brokercli.fndCliParse("") # Carefully insert any new CLI values into the Global object. dCliDictClean = { k: util.fnIntPlease(v) for k, v in dCliDict.items() if v is not None } g.__dict__.update(dCliDictClean) # Validate that the user-specified directories exist. if not fnbValidateDir(g.sFamilyDir): raise ValueError("FamilyDir \"%s\" not found" % (g.sFamilyDir)) if not fnbValidateDir("%s/%s" % (g.sFamilyDir, g.sSpecificDir)): raise ValueError("SpecificDir \"%s\" not found" % (g.sSpecificDir)) # Get command templates from external file. fnGetCommandTemplates(g.sCommandListFilename) # Construct database query for this invocation. g.cFmt = brokerformat.CFormat() dQuery = g.cFmt.fndFormatQuery(dCliDict, g) # Look for overriding environment variables fnvGetEnvironmentOverrides() # Open the database to keep "done" records, # and delete moldy, old in-progress records. g.mdb = searchdatabasemongo.CSearchDatabase( g.sSearchDbMongoName, g.sSearchDbProgressCollectionName, g.sSearchDbDoneCollectionName) g.mdb.fnvDeleteProgressCollection() # Get the set of instructions for today from database. NTRC.tracef( 0, "MAIN", "proc querydict2|%s|" % (list(util.fngSortDictItemsByKeys(dQuery)))) itAllInstructions = searchspace.fndgGetSearchSpace(g.sInsDir, g.sInsTyp, dQuery) # Start the start-end threads. # Define queues. # Need a Multiprocessing Manager to own the output queue. (Do we?) (Yes.) mpmgr = mp.Manager() g.qJobs = mp.Queue() g.qOutput = mpmgr.Queue() # Start pool of worker processes. g.cWorkersInst = cworkers.CWorkers(nservers=g.nCores, qinputjobs=g.qJobs, qoutputdata=g.qOutput) # If this wasn't just a listonly run, do all the cases. if not g.sListOnly.startswith("Y"): NTRC.ntracef(3, "MAIN", "proc all instr|%s|" % (g.lGiantInstr)) else: NTRC.ntracef(0, "MAIN", "Listonly.") nRuns = fnnProcessAllInstructions(itAllInstructions) NTRC.ntracef(0, "MAIN", "End queued all runs ncases|%s|" % (g.nCases, ))
def main(): ''' Process: - Parse the CLI command into g.various data items. - Validate user-supplied directories; get environment variables. - Query the searchspace for the stream of instructions - For each instruction from database selection, get dict for line - Using dict args, construct plausible command lines, into file - Check to see that there aren't too many similar processes already running; if too many, then wait. - Launch ListActor process to execute commands. - Wait a polite interval before launching another. ''' NTRC.ntracef(0, "MAIN", "Begin.") NTRC.ntracef(0, "MAIN", "TRACE traceproduction|%s|" % NTRC.isProduction()) sBrokerCommand = fnsReconstituteCommand(sys.argv) fnbMaybeLogCommand(sBrokerCommand) NTRC.ntracef(0, "MAIN", "command=|%s|" % (sBrokerCommand.rstrip())) # Get args from CLI and put them into the global data dCliDict = brokercli.fndCliParse("") # Carefully insert any new CLI values into the Global object. dCliDictClean = {k:util.fnIntPlease(v) for k,v in dCliDict.items() if v is not None} g.__dict__.update(dCliDictClean) # Validate that the user-specified directories exist. if not fnbValidateDir(g.sFamilyDir): raise ValueError("FamilyDir \"%s\" not found" % (g.sFamilyDir)) if not fnbValidateDir("%s/%s" % (g.sFamilyDir, g.sSpecificDir)): raise ValueError("SpecificDir \"%s\" not found" % (g.sSpecificDir)) # Get command templates from external file. fnGetCommandTemplates(g.sCommandListFilename) # Construct database query for this invocation. g.cFmt = brokerformat.CFormat() dQuery = g.cFmt.fndFormatQuery(dCliDict, g) # Look for overriding environment variables fnvGetEnvironmentOverrides() # Open the database to keep "done" records, # and delete moldy, old in-progress records. g.mdb = searchdatabasemongo.CSearchDatabase(g.sSearchDbMongoName, g.sSearchDbProgressCollectionName, g.sSearchDbDoneCollectionName) g.mdb.fnvDeleteProgressCollection() # Get the set of instructions for today from database. NTRC.tracef(0,"MAIN","proc querydict2|%s|" % ((dQuery))) itAllInstructions = searchspace.fndgGetSearchSpace(g.sInsDir, g.sInsTyp, dQuery) nRuns = fnnProcessAllInstructions(itAllInstructions) # If this wasn't just a listonly run, do all the cases. if not g.sListOnly.startswith("Y"): NTRC.ntracef(3, "MAIN", "proc all instr|%s|" % (g.lGiantInstr)) nCases = nb.fntRunEverything(g, iter(g.lGiantInstr) , g.nCoreTimer, g.nStuckLimit) else: nCases = len(g.lGiantInstr) NTRC.ntracef(0, "MAIN", "End ncases|%s|" % (nCases,))
def main(): ''' Process: - Parse the CLI command into g.various data items. - Validate user-supplied directories; get environment variables. - Query the searchspace for the stream of instructions - For each instruction from database selection, get dict for line - Using dict args, construct plausible command lines, into file - Check to see that there aren't too many similar processes already running; if too many, then wait. - Launch ListActor process to execute commands. - Wait a polite interval before launching another. ''' NTRC.ntracef(0, "MAIN", "Begin.") NTRC.ntracef(0, "MAIN", "TRACE traceproduction|%s|" % NTRC.isProduction()) def fnbQEnd(): return g.bLast sBrokerCommand = fnsReconstituteCommand(sys.argv) fnbMaybeLogCommand(sBrokerCommand) NTRC.ntracef(0, "MAIN", "command=|%s|" % (sBrokerCommand.rstrip())) # Get args from CLI and put them into the global data dCliDict = brokercli.fndCliParse("") # Carefully insert any new CLI values into the Global object. dCliDictClean = { k: util.fnIntPlease(v) for k, v in dCliDict.items() if v is not None } g.__dict__.update(dCliDictClean) # Validate that the user-specified directories exist. if not fnbValidateDir(g.sFamilyDir): raise ValueError("FamilyDir \"%s\" not found" % (g.sFamilyDir)) if not fnbValidateDir("%s/%s" % (g.sFamilyDir, g.sSpecificDir)): raise ValueError("SpecificDir \"%s\" not found" % (g.sSpecificDir)) # Get command templates from external file. fnGetCommandTemplates(g.sCommandListFilename) # Construct database query for this invocation. g.cFmt = brokerformat.CFormat() dQuery = g.cFmt.fndFormatQuery(dCliDict, g) # Look for overriding environment variables fnvGetEnvironmentOverrides() # Open the database to keep "done" records, # and delete moldy, old in-progress records. g.mdb = searchdatabasemongo.CSearchDatabase( g.sSearchDbMongoName, g.sSearchDbProgressCollectionName, g.sSearchDbDoneCollectionName) g.mdb.fnvDeleteProgressCollection() # Get the set of instructions for today from database. NTRC.tracef( 0, "MAIN", "proc querydict2|%s|" % (list(util.fngSortDictItemsByKeys(dQuery)))) itAllInstructions = searchspace.fndgGetSearchSpace(g.sInsDir, g.sInsTyp, dQuery) # Start the start-end threads. nb.fntRunEverything(g, g.qInstructions, fnbQEnd, g.nCoreTimer, g.nStuckLimit) # If this wasn't just a listonly run, do all the cases. if not g.sListOnly.startswith("Y"): NTRC.ntracef(3, "MAIN", "proc all instr|%s|" % (g.lGiantInstr)) else: NTRC.ntracef(0, "MAIN", "Listonly.") nRuns = fnnProcessAllInstructions(itAllInstructions) NTRC.ntracef(0, "MAIN", "End queued all runs ncases|%s|" % (g.nCases, ))
def getParamFiles(mysParamdir): # --------------------------------------------------------------- # Read the parameter files, whatever their formats. dResult = readin.fdGetClientParams("%s/clients.csv" % (mysParamdir)) if dResult: P.dClientParams = dResult dResult = readin.fdGetServerParams("%s/servers.csv" % (mysParamdir)) if dResult: P.dServerParams = dResult dResult = readin.fdGetQualityParams("%s/quality.csv" % (mysParamdir)) if dResult: P.dShelfParams = dResult dResult = readin.fdGetParamsParams("%s/params.csv" % (mysParamdir)) if dResult: P.dParamsParams = dResult dResult = readin.fdGetDistnParams("%s/distn.csv" % (mysParamdir)) if dResult: P.dDistnParams = dResult dResult = readin.fdGetDocParams("%s/docsize.csv" % (mysParamdir)) if dResult: P.dDocParams = dResult dResult = readin.fdGetAuditParams("%s/audit.csv" % (mysParamdir)) if dResult: P.dAuditParams = dResult # --------------------------------------------------------------- # Process the params params specially. Unpack them into better names. try: P.nRandomSeed = fnIntPlease(P.dParamsParams["RANDOMSEED"][0][0]) except KeyError: pass try: P.nSimLength = fnIntPlease(P.dParamsParams["SIMLENGTH"][0][0]) except KeyError: pass try: P.sLogFile = P.dParamsParams["LOG_FILE"][0][0] except KeyError: pass try: P.sLogLevel = P.dParamsParams["LOG_LEVEL"][0][0] except KeyError: pass ''' try: P.nBandwidthMbps = fnIntPlease(P.dParamsParams["BANDWIDTH"][0][0]) except KeyError: pass ''' ''' # --------------------------------------------------------------- # Process the audit params specially. Maybe they override defaults. try: fnMaybeOverride("nAuditCycleInterval",P.dAuditParams,G) fnMaybeOverride("nBandwidthMbps",P.dAuditParams,G) except: pass ''' '''
def fnsQuoteMulti(mylMultiList): ''' Render list from multi-select input box into list syntax acceptable to json. ''' return '\'' + str([util.fnIntPlease(s) for s in mylMultiList]) + '\''
def getParamFiles(mysParamdir): # --------------------------------------------------------------- # Read the parameter files, whatever their formats. dResult = readin.fdGetClientParams("%s/clients.csv"%(mysParamdir)) if dResult: P.dClientParams = dResult dResult = readin.fdGetServerParams("%s/servers.csv"%(mysParamdir)) if dResult: P.dServerParams = dResult dResult = readin.fdGetQualityParams("%s/quality.csv"%(mysParamdir)) if dResult: P.dShelfParams = dResult dResult = readin.fdGetParamsParams("%s/params.csv"%(mysParamdir)) if dResult: P.dParamsParams = dResult dResult = readin.fdGetDistnParams("%s/distn.csv"%(mysParamdir)) if dResult: P.dDistnParams = dResult dResult = readin.fdGetDocParams("%s/docsize.csv"%(mysParamdir)) if dResult: P.dDocParams = dResult dResult = readin.fdGetAuditParams("%s/audit.csv"%(mysParamdir)) if dResult: P.dAuditParams = dResult # --------------------------------------------------------------- # Process the params params specially. Unpack them into better names. try: P.nRandomSeed = fnIntPlease(P.dParamsParams["RANDOMSEED"][0][0]) except KeyError: pass try: P.nSimLength = fnIntPlease(P.dParamsParams["SIMLENGTH"][0][0]) except KeyError: pass try: P.sLogFile = P.dParamsParams["LOG_FILE"][0][0] except KeyError: pass try: P.sLogLevel = P.dParamsParams["LOG_LEVEL"][0][0] except KeyError: pass ''' try: P.nBandwidthMbps = fnIntPlease(P.dParamsParams["BANDWIDTH"][0][0]) except KeyError: pass ''' ''' # --------------------------------------------------------------- # Process the audit params specially. Maybe they override defaults. try: fnMaybeOverride("nAuditCycleInterval",P.dAuditParams,G) fnMaybeOverride("nBandwidthMbps",P.dAuditParams,G) except: pass ''' '''
def fnsQuoteMulti(mylMultiList): ''' Render list from multi-select input box into list syntax acceptable to json. ''' return '\'' + str([util.fnIntPlease(s) for s in mylMultiList]) + '\''