/[ascend]/trunk/pygtk/ascdev.in
ViewVC logotype

Diff of /trunk/pygtk/ascdev.in

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

revision 1149 by johnpye, Wed Jan 10 07:19:30 2007 UTC revision 1150 by johnpye, Tue Jan 16 04:49:21 2007 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!@PYTHON@
2    # to debug this program using 'gdb', invoke 'ASC_GDB=1 ascdev'.
3    
4  export ASC_START=$PWD  import os.path, sys, platform;
 cd @SOURCE_ROOT@/pygtk  
 export LD_LIBRARY_PATH=@SOURCE_ROOT@:@SOURCE_ROOT@/pygtk:$LD_LIBRARY_PATH  
 export ASCENDLIBRARY=@SOURCE_ROOT@/models:$ASCENDLIBRARY  
 export ASC_DEV=1  
   
 if [ "x$ASC_GDB" != "x" ]; then  
     cmd="gdb --symbols=../@ASC_SHLIBPREFIX@ascend@ASC_SHLIBSUFFIX@ --args python ascend"  
 else  
     cmd="./ascend"  
 fi  
5    
6  $cmd $@  def add_at_start(envvar,pathcomponents):
7        """ add path components at start of envvar, return 1 if changes made """
8    
9        if not os.environ.get(envvar):
10            v = SEP.join(pathcomponents)
11            os.environ[envvar]=v
12            return 1
13    
14        restart = 0
15        pathcomponents = [os.path.abspath(i) for i in pathcomponents]
16        envvals = [os.path.abspath(i) for i in os.environ[envvar].split(SEP)]
17        for k in range(0,len(pathcomponents)):
18            p = pathcomponents[k]
19            if p in envvals[k+1:]:
20                envvals.remove(p)
21                restart = 1
22        for p in reversed(pathcomponents):
23            if p not in envvals:
24                envvals.insert(0,p)
25                restart = 1
26        os.environ[envvar]=SEP.join(envvals)
27        return restart
28            
29    if __name__=='__main__':
30        sourceroot="@SOURCE_ROOT@"
31        script=os.path.join(sys.argv[0])
32    
33        if platform.system()=="Windows":
34            LD_LIBRARY_PATH="PATH"
35            SEP = ";"
36        else:
37            LD_LIBRARY_PATH="LD_LIBRARY_PATH"
38            SEP = ":"
39    
40        restart = []
41    
42        # ensure that we have our 'models' dir in the ASCENDLIBRARY path
43        modeldirs = ["@SOURCE_ROOT@/models"]
44        if add_at_start('ASCENDLIBRARY',modeldirs):
45            restart.append('ASCENDLIBRARY')
46    
47        # ensure that we have our shared libraries in the LD_LIBRARY_PATH
48        libdirs = ["@SOURCE_ROOT@","@SOURCE_ROOT@/pygtk"]
49        if add_at_start(LD_LIBRARY_PATH,libdirs):
50            restart.append(LD_LIBRARY_PATH)
51    
52        # ensure our pygtk dir is in the PYTHONPATH
53        pypath = ["@SOURCE_ROOT@/pygtk"]
54        if add_at_start('PYTHONPATH',pypath):
55            restart.append('PYTHONPATH')
56    
57        if restart:
58            print "\nRestarting with..."
59            for v in restart:
60                print "   %s = %s" % (v,os.environ[v])
61            if os.environ.get('ASC_GDB'):
62                print "   via GDB..."
63                os.execvp("gdb",['--symbols=../@ASC_SHLIBPREFIX@ascend@ASC_SHLIBSUFFIX@','--args','python',script]+sys.argv)
64            else:
65                print "PYTHON... ",script
66                os.execvp("python",[script,script]+sys.argv[1:])
67            # the above calls don't return so we can forget about line of enqiry
68    
69        import ascpy
70        from gtkbrowser import *
71        B = Browser(assetspath=os.path.join(sourceroot,"pygtk/glade"))
72        B.run()

Legend:
Removed from v.1149  
changed lines
  Added in v.1150

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