/[ascend]/trunk/test.py
ViewVC logotype

Diff of /trunk/test.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1519 by jpye, Thu Jun 28 13:46:33 2007 UTC revision 1520 by jpye, Sat Jun 30 01:23:36 2007 UTC
# Line 1394  class NotToBeTested: Line 1394  class NotToBeTested:
1394          print "v = %f" % M.v          print "v = %f" % M.v
1395          M.run(T.getMethod('self_test'))          M.run(T.getMethod('self_test'))
1396    
1397    def patchpath(VAR,SEP,addvals):
1398        restart = 0
1399        envpath = [os.path.abspath(i) for i in os.environ[VAR].split(SEP)]
1400        for l in addvals:
1401            if l in envpath[len(addvals):]:
1402                envpath.remove(l)
1403                restart = 1
1404        for l in addvals:
1405            if l not in envpath:
1406                envpath.insert(0,l)
1407                restart = 1
1408        os.environ[VAR] = SEP.join(envpath)
1409        return restart  
1410        
1411  if __name__=='__main__':  if __name__=='__main__':
1412      # a whole bag of tricks to make sure we get the necessary dirs in our ascend, python and ld path vars      # a whole bag of tricks to make sure we get the necessary dirs in our ascend, python and ld path vars
1413      restart = 0      restart = 0
# Line 1405  if __name__=='__main__': Line 1419  if __name__=='__main__':
1419          LD_LIBRARY_PATH="LD_LIBRARY_PATH"          LD_LIBRARY_PATH="LD_LIBRARY_PATH"
1420          SEP = ":"          SEP = ":"
1421    
     freesteamdir = os.path.expanduser("~/freesteam/ascend")  
     modeldirs = [os.path.abspath(os.path.join(sys.path[0],"models")),os.path.abspath(freesteamdir)]  
1422      solverdir = os.path.abspath(os.path.join(sys.path[0],"solvers"))      solverdir = os.path.abspath(os.path.join(sys.path[0],"solvers"))
1423      solverdirs = [os.path.join(solverdir,s) for s in "qrslv","cmslv","lrslv","conopt","ida","lsode"]      solverdirs = [os.path.join(solverdir,s) for s in "qrslv","cmslv","lrslv","conopt","ida","lsode"]
1424    
1425        if not os.environ.get('ASCENDSOLVERS'):
1426            os.environ['ASCENDSOLVERS'] = SEP.join(solverdirs)
1427            restart = 1
1428        else:
1429            if patchpath('ASCENDSOLVERS',SEP,solverdirs):
1430                restart = 1
1431        
1432        freesteamdir = os.path.expanduser("~/freesteam/ascend")
1433        modeldirs = [os.path.abspath(os.path.join(sys.path[0],"models")),os.path.abspath(freesteamdir)]
1434        
1435      if not os.environ.get('ASCENDLIBRARY'):      if not os.environ.get('ASCENDLIBRARY'):
1436          os.environ['ASCENDLIBRARY'] = SEP.join(modeldirs+solverdirs)          os.environ['ASCENDLIBRARY'] = SEP.join(modeldirs)
1437          restart = 1          restart = 1
1438      else:      else:
1439          envmodelsdir = [os.path.abspath(i) for i in os.environ['ASCENDLIBRARY'].split(SEP)]          if patchpath('ASCENDLIBRARY',SEP,modeldirs):
1440          for l in modeldirs:              restart = 1
             if l in envmodelsdir[len(modeldirs):]:  
                 envmodelsdir.remove(l)  
                 restart = 1  
         for l in modeldirs:  
             if l not in envmodelsdir:  
                 envmodelsdir.insert(0,l)  
                 restart = 1  
         os.environ['ASCENDLIBRARY'] = SEP.join(envmodelsdir)      
1441    
1442      libdirs = ["pygtk","."]      libdirs = ["pygtk","."]
1443      libdirs = [os.path.normpath(os.path.join(sys.path[0],l)) for l in libdirs]      libdirs = [os.path.normpath(os.path.join(sys.path[0],l)) for l in libdirs]
# Line 1452  if __name__=='__main__': Line 1467  if __name__=='__main__':
1467              restart = 1              restart = 1
1468    
1469      if restart:      if restart:
1470          #if platform.system()=="Windows":          script = os.path.join(sys.path[0],"test.py")                    
1471          #   pass          sys.stderr.write("Restarting with...\n")
1472          #else:          sys.stderr.write("  export LD_LIBRARY_PATH=%s\n" % os.environ.get(LD_LIBRARY_PATH))
1473          if 1:          sys.stderr.write("  export PYTHONPATH=%s\n" % os.environ.get('PYTHONPATH'))
1474              script = os.path.join(sys.path[0],"test.py")                              sys.stderr.write("  export ASCENDLIBRARY=%s\n" % os.environ.get('ASCENDLIBRARY'))
1475              sys.stderr.write("Restarting with...\n")          sys.stderr.write("  export ASCENDSOLVERS=%s\n" % os.environ.get('ASCENDSOLVERS'))
1476              sys.stderr.write("  export LD_LIBRARY_PATH=%s\n" % os.environ.get(LD_LIBRARY_PATH))          sys.stderr.flush()
1477              sys.stderr.write("  export PYTHONPATH=%s\n" % os.environ.get('PYTHONPATH'))          os.execvp("python",[script] + sys.argv)
1478              sys.stderr.write("  export ASCENDLIBRARY=%s\n" % os.environ.get('ASCENDLIBRARY'))          exit(1)
1479              sys.stderr.flush()      else:
1480              os.execvp("python",[script] + sys.argv)          sys.stderr.write("Got...\n")
1481            sys.stderr.write("  LD_LIBRARY_PATH=%s\n" % os.environ.get(LD_LIBRARY_PATH))
1482            sys.stderr.write("  PYTHONPATH=%s\n" % os.environ.get('PYTHONPATH'))
1483            sys.stderr.write("  ASCENDLIBRARY=%s\n" % os.environ.get('ASCENDLIBRARY'))
1484            sys.stderr.write("  ASCENDSOLVERS=%s\n" % os.environ.get('ASCENDSOLVERS'))
1485            sys.stderr.flush()
1486    
1487      import ascpy      import ascpy
1488    

Legend:
Removed from v.1519  
changed lines
  Added in v.1520

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22