]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/ide/activegrid/util/sysutils.py
   1 #---------------------------------------------------------------------------- 
   3 # Purpose:      System Utilities 
   9 # Copyright:    (c) 2004-2005 ActiveGrid, Inc. 
  10 # License:      wxWindows License 
  11 #---------------------------------------------------------------------------- 
  16 # this will be set to true in IDE.py when we are running release builds. 
  19 # Commented out for now..... 
  20 # Required for Unicode support with python 
  21 # Put over here because of py2exe problems 
  22 # Python suggests modifying site.py  
  23 #if hasattr(sys,"setdefaultencoding"): 
  24 #    sys.setdefaultencoding("UTF-8") 
  27 MAINMODULE_DIR 
= "AG_MAINMODULE_DIR" 
  28 IS_RELEASE 
= "AG_IS_RELEASE" 
  31     return 'true' == (str(os
.getenv(IS_RELEASE
)).lower()) 
  33 def setRelease(value
): 
  35         os
.environ
[IS_RELEASE
]= "TRUE" 
  37         os
.environ
[IS_RELEASE
]= "FALSE" 
  40     return os
.name 
== 'nt' 
  43 def _generateMainModuleDir(): 
  44     mainModuleDir 
= os
.getenv(MAINMODULE_DIR
) 
  45     if mainModuleDir
:  # if environment variable set, return it 
  48     # On Mac, the python executable sometimes has a capital "P" so we need to  
  49     # lower the string first 
  50     sysExecLower 
= sys
.executable
.lower() 
  51     if sysExecLower 
== "/" or sysExecLower
.find('python') != -1 or sysExecLower
.find('apache') != -1: 
  52         utilModuleDir 
= os
.path
.dirname(__file__
) 
  53         if not os
.path
.isabs(utilModuleDir
): 
  54             utilModuleDir 
= os
.path
.join(os
.getcwd(), utilModuleDir
) 
  55         mainModuleDir 
= os
.path
.normpath(os
.path
.join(utilModuleDir
, os
.path
.join(os
.path
.pardir
, os
.path
.pardir
))) 
  56         if mainModuleDir
.endswith('.zip'): 
  57             mainModuleDir 
= os
.path
.dirname(mainModuleDir
) # Get rid of library.zip 
  59         mainModuleDir 
= os
.path
.dirname(sys
.executable
) 
  61     os
.environ
[MAINMODULE_DIR
] = mainModuleDir  
# pythonBug: os.putenv doesn't work, set environment variable 
  65 mainModuleDir 
= _generateMainModuleDir() 
  67 def _generatePythonExecPath(): 
  68     # On Mac, the python executable sometimes has a capital "P" so we need to  
  69     # lower the string first 
  70     sysExecLower 
= sys
.executable
.lower() 
  71     if sysExecLower
.find('python') != -1 or sysExecLower
.find('apache') != -1: 
  72         pythonExecPath 
= sys
.executable
 
  74         # this is where py2app puts the Python executable 
  75         if sys
.platform 
== "darwin": 
  76             pythonExecPath 
= os
.path
.join(os
.path
.dirname(sys
.executable
), "../Frameworks/Python.Framework/Versions/2.4/Python/bin") 
  78             pythonExecPath 
= os
.path
.join(os
.path
.dirname(sys
.executable
), '3rdparty\python2.4\python') 
  81 pythonExecPath 
= _generatePythonExecPath() 
  83 def getCommandNameForExecPath(execPath
): 
  85         return '"%s"' % execPath