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

Diff of /trunk/test.py

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

revision 1117 by johnpye, Wed Jan 10 13:07:45 2007 UTC revision 1118 by johnpye, Thu Jan 11 12:08:12 2007 UTC
# Line 35  class Ascend(unittest.TestCase): Line 35  class Ascend(unittest.TestCase):
35    
36      def setUp(self):      def setUp(self):
37          import ascpy          import ascpy
38          self.L = ascpy.Library(modelsdir)          self.L = ascpy.Library()
39            
40      def tearDown(self):      def tearDown(self):
41          self.L.clear()          self.L.clear()
# Line 706  class NotToBeTested: Line 706  class NotToBeTested:
706          pass          pass
707    
708  if __name__=='__main__':  if __name__=='__main__':
709        # a whole bag of tricks to make sure we get the necessary dirs in our ascend, python and ld path vars
710      restart = 0      restart = 0
     modelsdir = None  
   
     if not os.environ.get('ASCENDLIBRARY'):  
         modelsdir = os.path.normpath(os.path.join(sys.path[0],"models"))  
         os.environ['ASCENDLIBRARY'] = modelsdir  
         restart = 1  
711    
712      if platform.system()=="Windows":      if platform.system()=="Windows":
713          LD_LIBRARY_PATTH="PATH"          LD_LIBRARY_PATTH="PATH"
# Line 721  if __name__=='__main__': Line 716  if __name__=='__main__':
716          LD_LIBRARY_PATH="LD_LIBRARY_PATH"          LD_LIBRARY_PATH="LD_LIBRARY_PATH"
717          SEP = ":"          SEP = ":"
718    
719        modelsdir = os.path.normpath(os.path.join(sys.path[0],"models"))
720        if not os.environ.get('ASCENDLIBRARY'):
721            os.environ['ASCENDLIBRARY'] = modelsdir
722            restart = 1
723        else:
724            envmodelsdir = [os.path.abspath(i) for i in os.environ['ASCENDLIBRARY'].split(SEP)]
725            if modelsdir not in envmodelsdir:
726                envmodelsdir.insert(0,modelsdir)
727                os.environ['ASCENDLIBRARY']=SEP.join(envmodelsdir)
728                restart = 1    
729    
730      libdirs = ["pygtk","."]      libdirs = ["pygtk","."]
731      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]
732      if not os.environ.get(LD_LIBRARY_PATH):      if not os.environ.get(LD_LIBRARY_PATH):
# Line 745  if __name__=='__main__': Line 751  if __name__=='__main__':
751          envpypath = os.environ['PYTHONPATH'].split(SEP)          envpypath = os.environ['PYTHONPATH'].split(SEP)
752          if pypath not in envpypath:          if pypath not in envpypath:
753              envpypath.insert(0,pypath)              envpypath.insert(0,pypath)
754                os.environ['PYTHONPATH']=envpypath
755              restart = 1              restart = 1
756    
757      if restart:      if restart:
758          script = os.path.join(sys.path[0],"test.py")          script = os.path.join(sys.path[0],"test.py")
759          print "Restarting"          print "Restarting"
760          print "LD_LIBRARY_PATH = %s" % os.environ.get(LD_LIBRARY_PATH)          print "LD_LIBRARY_PATH = %s" % os.environ.get(LD_LIBRARY_PATH)
761            print "PYTHONPATH = %s" % os.environ.get('PYTHONPATH')
762            print "ASCENDLIBRARY = %s" % os.environ.get('ASCENDLIBRARY')
763          os.execvp("python",[script] + sys.argv)          os.execvp("python",[script] + sys.argv)
764    
765      import ascpy      import ascpy

Legend:
Removed from v.1117  
changed lines
  Added in v.1118

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