def attrValTests(pf): print "ATTR Value Tests" try: # test missing value for name av = AttrVal() av.addPair("","frank") except PTexception, a: pf.passed("PTexception raised for missing 'name' value: " + a.value)
def attrValTests(pf): print "ATTR Value Tests" try: # test missing value for name av = AttrVal() av.addPair("", "frank") except PTexception, a: pf.passed("PTexception raised for missing 'name' value: " + a.value)
def execTests(pf): print "Execution Tests" try: # try giving Application non-list execution b = "superduper" c = "extra" d = "eddie" av = AttrVal() av.addPair(b, c) av.addPair(d, "") e = Execution("sally") app = Application("frank", av ,e) except PTexception, a: pf.passed(a.value)
def translateBuild(buildFile, buildXML): try: iF = open(buildFile, 'r') except: print "in transateBuild: Unable to open %s for reading." % buildFile return attrs = AttrVal() # get the attribute value pairs line = iF.readline() while line != '': # get this value nvlist = re.split('=', line, 1) if len(nvlist) == 1: [n] = nvlist attrs.addPair(n) else: [n, v] = nvlist attrs.addPair(n, v) line = iF.readline() iF.close() if attrs.getFirst()[0] != "BuildDataBegin": raise PTexception("Missing BuildDataBegin in build data file: %s" % buildFile) if attrs.getLast()[0] != "BuildDataEnd": raise PTexception("Missing BuildDataEnd in build data file: %s" % buildFile) # create a peri object peri = PERIxml() # create the build build = peri.createBuild() getBuildData(attrs, build, peri) if attrs.getCurrent()[0] != "BuildDataEnd": getCompilerData(attrs, peri) if attrs.getCurrent()[0] != "BuildDataEnd": getLibraries(attrs, peri, build) peri.writeData(buildXML)
def translateBuild(buildFile, buildXML): try: iF = open(buildFile,'r') except: print "in transateBuild: Unable to open %s for reading." % buildFile return attrs = AttrVal() # get the attribute value pairs line = iF.readline() while line != '': # get this value nvlist = re.split('=', line, 1) if len(nvlist) == 1: [n] = nvlist attrs.addPair(n) else: [n,v] = nvlist attrs.addPair(n,v) line = iF.readline() iF.close() if attrs.getFirst()[0] != "BuildDataBegin": raise PTexception("Missing BuildDataBegin in build data file: %s" % buildFile) if attrs.getLast()[0] != "BuildDataEnd": raise PTexception("Missing BuildDataEnd in build data file: %s" % buildFile) # create a peri object peri = PERIxml() # create the build build = peri.createBuild() getBuildData(attrs, build, peri) if attrs.getCurrent()[0] != "BuildDataEnd": getCompilerData(attrs, peri) if attrs.getCurrent()[0] != "BuildDataEnd": getLibraries(attrs, peri, build) peri.writeData(buildXML)
def execTests(pf): print "Execution Tests" try: # try giving Application non-list execution b = "superduper" c = "extra" d = "eddie" av = AttrVal() av.addPair(b, c) av.addPair(d, "") e = Execution("sally") app = Application("frank", av, e) except PTexception, a: pf.passed(a.value)
def process(resIdx, arg, eInfo, ptds): if not ptds: raise PTexception( "Run.process: expect to be connected to database, but am not.") # open the data file try: f = open(arg, 'r') except: raise PTexception("Run.process: could not open run data file:%s" % arg) attrs = AttrVal() line = f.readline() while line != '': # get this value nvlist = re.split('=', line, 1) if len(nvlist) == 1: [n] = nvlist attrs.addPair(n) else: [n, v] = nvlist attrs.addPair(n, v) line = f.readline() if attrs.getFirst()[0] != "RunDataBegin": raise PTexception("Missing RunDataBegin in run data file %s" % arg) if attrs.getLast()[0] != "RunDataEnd": raise PTexception("Missing RunDataEnd in run data file %s" % arg) get_initial_run_info(resIdx, attrs, eInfo, ptds) if eInfo.pbsOut: parsePBSoutput(resIdx, arg, ptds) f.close()
def process(resIdx, arg, eInfo, ptds): if not ptds: raise PTexception("Run.process: expect to be connected to database, but am not.") # open the data file try: f = open(arg, "r") except: raise PTexception("Run.process: could not open run data file:%s" % arg) attrs = AttrVal() line = f.readline() while line != "": # get this value nvlist = re.split("=", line, 1) if len(nvlist) == 1: [n] = nvlist attrs.addPair(n) else: [n, v] = nvlist attrs.addPair(n, v) line = f.readline() if attrs.getFirst()[0] != "RunDataBegin": raise PTexception("Missing RunDataBegin in run data file %s" % arg) if attrs.getLast()[0] != "RunDataEnd": raise PTexception("Missing RunDataEnd in run data file %s" % arg) get_initial_run_info(resIdx, attrs, eInfo, ptds) if eInfo.pbsOut: parsePBSoutput(resIdx, arg, ptds) f.close()
def translateRun(runFile, runXML): try: iF = open(runFile,'r') except: print "in transateRun: Unable to open %s for reading." % runFile return attrs = AttrVal() # get the attribute value pairs line = iF.readline() while line != '': # get this value nvlist = re.split('=', line, 1) if len(nvlist) == 1: [n] = nvlist attrs.addPair(n) else: [n,v] = nvlist attrs.addPair(n,v) line = iF.readline() iF.close() if attrs.getFirst()[0] != "RunDataBegin": raise PTexception("Missing RunDataBegin in run data file for: %s" % runFile) if attrs.getLast()[0] != "RunDataEnd": raise PTexception("Missing RunDataEnd in run data file for: %s" % runFile) # make a peri object peri = PERIxml() # create the run run = peri.createRun() getRunData(attrs, peri, run) if attrs.getCurrent()[0] != "RunDataEnd": getSubmissionData(attrs, peri, run) if attrs.getCurrent()[0] != "RunDataEnd": getFileSystems(attrs, peri, run) if attrs.getCurrent()[0] != "RunDataEnd": getLibraries(attrs, peri, run) if attrs.getCurrent()[0] != "RunDataEnd": getInputDecks(attrs, peri, run) peri.writeData(runXML)
try: # test missing value for name av = AttrVal() av.addPair("","frank") except PTexception, a: pf.passed("PTexception raised for missing 'name' value: " + a.value) except: pf.failed("non-PTexception raised AttrVal missing 'name'") raise else: pf.failed("no exception raised AttrVal 'missing name'") try: # test non-list given to addPairs av = AttrVal() av.addPairs("frank") except PTexception, a: pf.passed("PTexception raised for non-list to addPairs: " + a.value) except: pf.failed("non-PTexception raised AttrVal non-list to addPairs") raise else: pf.failed("no exception raised AttrVal non-list to addPairs") try: # test non-pair list given to addPairs av = AttrVal() a = ["frank","allice","steve"] av.addPairs(a)
def process(resIdx, arg, exeName, ptds=None): if not ptds: raise PTexception("Build.process: expect to already be connected to database, but am not.") # open the data file try: f = open(arg, "r") except: raise PTexception("Build.process: could not open build data file:%s." % arg) attrs = AttrVal() line = f.readline() # eat BuildDataBegin line = f.readline() while line != "" and not (line.strip().endswith("Begin") or line.strip() == "BuildDataEnd"): # get this value nvlist = re.split("=", line, 1) if len(nvlist) == 1: [n] = nvlist attrs.addPair(n) else: [n, v] = nvlist attrs.addPair(n, v) line = f.readline() (Build, Exe) = getInitialAVs(resIdx, attrs, exeName, ptds) attrs_rest = AttrVal() while line != "" and line.strip() != "BuildDataEnd": # get this value nvlist = re.split("=", line, 1) if len(nvlist) == 1: [n] = nvlist attrs_rest.addPair(n) else: [n, v] = nvlist attrs_rest.addPair(n, v) line = f.readline() if line.strip() != "BuildDataEnd": print "line is:" + line raise PTexception("missing BuildDataEnd in build data file for " "execution:%s" % Exe.name) if attrs_rest.getLength() != 0: (Exe, Build) = get_rest_of_build_info(resIdx, Exe, Build, attrs_rest, exeName, ptds) f.close() return (Build, Exe)
def process(resIdx, arg, exeName, ptds=None): if not ptds: raise PTexception("Build.process: expect to already be connected to database, but am not.") # open the data file try: f = open(arg, 'r') except: raise PTexception("Build.process: could not open build data file:%s."\ % arg) attrs = AttrVal() line = f.readline() # eat BuildDataBegin line = f.readline() while line != '' and not (line.strip().endswith("Begin") or line.strip() == "BuildDataEnd"): # get this value nvlist = re.split('=', line, 1) if len(nvlist) == 1: [n] = nvlist attrs.addPair(n) else: [n,v] = nvlist attrs.addPair(n,v) line = f.readline() (Build, Exe) = getInitialAVs(resIdx, attrs,exeName, ptds) attrs_rest = AttrVal() while line != '' and line.strip() != "BuildDataEnd": # get this value nvlist = re.split('=', line, 1) if len(nvlist) == 1: [n] = nvlist attrs_rest.addPair(n) else: [n,v] = nvlist attrs_rest.addPair(n,v) line = f.readline() if line.strip() != "BuildDataEnd": print "line is:" + line raise PTexception("missing BuildDataEnd in build data file for " "execution:%s" % Exe.name) if attrs_rest.getLength() != 0: (Exe,Build) = get_rest_of_build_info(resIdx, Exe, Build, \ attrs_rest, exeName,ptds) f.close() return (Build, Exe)
print "ATTR Value Tests" try: # test missing value for name av = AttrVal() av.addPair("", "frank") except PTexception, a: pf.passed("PTexception raised for missing 'name' value: " + a.value) except: pf.failed("non-PTexception raised AttrVal missing 'name'") raise else: pf.failed("no exception raised AttrVal 'missing name'") try: # test non-list given to addPairs av = AttrVal() av.addPairs("frank") except PTexception, a: pf.passed("PTexception raised for non-list to addPairs: " + a.value) except: pf.failed("non-PTexception raised AttrVal non-list to addPairs") raise else: pf.failed("no exception raised AttrVal non-list to addPairs") try: # test non-pair list given to addPairs av = AttrVal() a = ["frank", "allice", "steve"] av.addPairs(a) except PTexception, a:
def translateRun(runFile, runXML): try: iF = open(runFile, 'r') except: print "in transateRun: Unable to open %s for reading." % runFile return attrs = AttrVal() # get the attribute value pairs line = iF.readline() while line != '': # get this value nvlist = re.split('=', line, 1) if len(nvlist) == 1: [n] = nvlist attrs.addPair(n) else: [n, v] = nvlist attrs.addPair(n, v) line = iF.readline() iF.close() if attrs.getFirst()[0] != "RunDataBegin": raise PTexception("Missing RunDataBegin in run data file for: %s" % runFile) if attrs.getLast()[0] != "RunDataEnd": raise PTexception("Missing RunDataEnd in run data file for: %s" % runFile) # make a peri object peri = PERIxml() # create the run run = peri.createRun() getRunData(attrs, peri, run) if attrs.getCurrent()[0] != "RunDataEnd": getSubmissionData(attrs, peri, run) if attrs.getCurrent()[0] != "RunDataEnd": getFileSystems(attrs, peri, run) if attrs.getCurrent()[0] != "RunDataEnd": getLibraries(attrs, peri, run) if attrs.getCurrent()[0] != "RunDataEnd": getInputDecks(attrs, peri, run) peri.writeData(runXML)