Ejemplo n.º 1
0
    def __init__(self, resultdir=None):
        runlist = []
        self.runs = {}
        self.resultnames = []
        self.resultdir = resultdir

        ## Try to get available runs from runObjFile
        runobjfile = os.path.join(resultdir, "runObjFile")
        if os.path.exists(runobjfile):
            self.runObjFile = psf.PSFReader(runobjfile, asc=True)
            self.runObjFile.open()

            for runName in self.runObjFile.getValueNames():
                run = PSFRun(runName, self.runObjFile.getValuesByName(runName),
                             self.runObjFile.getValuePropertiesByName(runName))
                runlist.append(run)
                self.runs[runName] = run

        ## If not present, create a single run
        else:
            run = PSFRun('Run1', {
                'logName': ['logFile'],
                'parent': '',
                'sweepVariable': []
            }, {})
            self.runs['Run1'] = run
            runlist.append(run)

        # Read log files
        for run in runlist:
            if self.runs.has_key(run.parentName):
                parent = self.runs[run.parentName]
                run.setParent(parent)
                parent.addChild(run)
            run.openLogs(resultdir)
Ejemplo n.º 2
0
 def openLogs(self, resultdir):
     for logname in self.logName:
         if len(logname) > 0:
             self.logs[logname] = psf.PSFReader(os.path.join(
                 resultdir, str(logname)),
                                                asc=True)
             self.logs[logname].open()
Ejemplo n.º 3
0
 def psfasc(self, _parent=None):
     _context = self.Context(_parent, self._scanner, 'psfasc', [])
     psfobj = psf.PSFReader()
     headersec = self.headersec(psfobj, _context)
     psfobj.header = headersec
     if self._peek('"TYPE"',
                   '"SWEEP"',
                   '"TRACE"',
                   '"END"',
                   '"VALUE"',
                   'STR',
                   context=_context) == '"TYPE"':
         typesec = self.typesec(psfobj, _context)
     if self._peek('"SWEEP"',
                   '"TRACE"',
                   '"END"',
                   '"VALUE"',
                   'STR',
                   context=_context) == '"SWEEP"':
         sweepsec = self.sweepsec(_context)
     if self._peek('"TRACE"', '"END"', '"VALUE"', 'STR',
                   context=_context) == '"TRACE"':
         tracesec = self.tracesec(_context)
     updatepsf(psfobj)
     if self._peek('"END"', '"VALUE"', 'STR',
                   context=_context) == '"VALUE"':
         valuesec = self.valuesec(psfobj, _context)
     self._scan('"END"', context=_context)
     EOF = self._scan('EOF', context=_context)
     return psfobj
Ejemplo n.º 4
0
 def __init__(self, sweepvariables, sweepvalues, psffilenames):
     self.sweepvariables = sweepvariables
     self.sweepvalues = sweepvalues
     self.psfobjects = [
         psf.PSFReader(psffilename) for psffilename in psffilenames
     ]
     for po in self.psfobjects:
         po.open()
Ejemplo n.º 5
0
    def __init__(self, psffilename=None, use_libpsf=True):
        if use_libpsf and psflibpsf:
            self.psfobj = psflibpsf.PSFReader(psffilename)
        else:
            self.psfobj = psf.PSFReader(psffilename)

        self.psfobj.open()

        super(PSFResult, self).__init__()
Ejemplo n.º 6
0
def create_psfreader(*args, **kwargs):
    """PSFReader factory that can use either libpsf or pure python"""
    use_libpsf = True

    if 'USELIBPSF' in os.environ:
        use_libpsf = bool(int(os.environ['USELIBPSF']))

    ## Try to import libpsf
    if use_libpsf:
        try:
            import psflibpsf
        except ImportError:
            use_libpsf = False
            os.environ['USELIBPSF'] = '0'

    if use_libpsf and not psfasc.is_psfasc(args[0]):
        return psflibpsf.PSFReader(*args, **kwargs)
    else:
        return psf.PSFReader(*args, **kwargs)
Ejemplo n.º 7
0
    def __init__(self, filename):
        self.filename = filename

        self.psfobj = psf.PSFReader(filename, asc=True)
        self.psfobj.open()

        self.itemnames = []
        self.items = {}
        self.roots = []

        for item_name in self.psfobj.getValueNames():
            new_item = PSFLogItem(item_name,
                                  self.psfobj.getValuesByName(item_name))

            if new_item.parentname != '':
                self.items[new_item.parentname].add_child(new_item)
            else:
                self.roots.append(new_item)

            self.items[item_name] = new_item
Ejemplo n.º 8
0
def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "ihav",
                                   ["info"
                                    "help", "output="])
    except getopt.GetoptError:
        # print help information and exit:
        sys.exit(2)
    output = None
    verbose = False

    cmd = "psfasc"

    for o, a in opts:
        if o == "-v":
            verbose = True
        if o in ("-h", "--help"):
            usage()
            sys.exit()
        if o in ("-i", "--info"):
            cmd = "info"
        if o in ("-a", "--asc"):
            cmd = "info"

    if len(args) < 1:
        usage()
        sys.exit(2)

    filename = args.pop()

    psfobj = psf.PSFReader(filename)
    psfobj.verbose = verbose
    psfobj.open()

    if cmd == "psfasc":
        print psfobj.toPSFasc()
    elif cmd == "info":
        print psfobj.info()
        if verbose:
            psfobj.printme()