]> git.saurik.com Git - wxWidgets.git/blame - wxPython/samples/ide/activegrid/util/sysutils.py
removed code inside USE_SIZABLE_CALENDAR, we should allow making the main calendar...
[wxWidgets.git] / wxPython / samples / ide / activegrid / util / sysutils.py
CommitLineData
02b800ce
RD
1#----------------------------------------------------------------------------
2# Name: sysutils.py
3# Purpose: System Utilities
4#
5# Author: Joel Hare
6#
7# Created: 7/28/04
8# CVS-ID: $Id$
9# Copyright: (c) 2004-2005 ActiveGrid, Inc.
10# License: wxWindows License
11#----------------------------------------------------------------------------
12
13import sys
14import os
aca310e5 15import time
02b800ce
RD
16
17# this will be set to true in IDE.py when we are running release builds.
18isRelease = False
19
20# Commented out for now.....
21# Required for Unicode support with python
22# Put over here because of py2exe problems
23# Python suggests modifying site.py
24#if hasattr(sys,"setdefaultencoding"):
25# sys.setdefaultencoding("UTF-8")
26
27
28MAINMODULE_DIR = "AG_MAINMODULE_DIR"
29IS_RELEASE = "AG_IS_RELEASE"
aca310e5
RD
30IS_COMMERCIAL = "AG_IS_COMMERCIAL"
31AG_SYSTEM_START_TIME_ENV_NAME = "AG_SYSTEM_START_TIME"
32
33def isCommercial():
34
35 return os.path.exists(os.path.join(mainModuleDir,"commercial.txt")) or 'true' == (str(os.getenv(IS_COMMERCIAL)).lower())
02b800ce
RD
36
37def isRelease():
38 return 'true' == (str(os.getenv(IS_RELEASE)).lower())
39
40def setRelease(value):
41 if value:
42 os.environ[IS_RELEASE]= "TRUE"
43 else:
44 os.environ[IS_RELEASE]= "FALSE"
45
46def isWindows():
47 return os.name == 'nt'
48
aca310e5 49__isServer = False
02b800ce 50
aca310e5
RD
51def setServerMode(isServer):
52 global __isServer
53 __isServer = isServer
54
55def isServer():
56 global __isServer
57 return __isServer
58
02b800ce
RD
59def _generateMainModuleDir():
60 mainModuleDir = os.getenv(MAINMODULE_DIR)
61 if mainModuleDir: # if environment variable set, return it
62 return mainModuleDir
63
64 # On Mac, the python executable sometimes has a capital "P" so we need to
65 # lower the string first
66 sysExecLower = sys.executable.lower()
67 if sysExecLower == "/" or sysExecLower.find('python') != -1 or sysExecLower.find('apache') != -1:
68 utilModuleDir = os.path.dirname(__file__)
69 if not os.path.isabs(utilModuleDir):
70 utilModuleDir = os.path.join(os.getcwd(), utilModuleDir)
71 mainModuleDir = os.path.normpath(os.path.join(utilModuleDir, os.path.join(os.path.pardir, os.path.pardir)))
72 if mainModuleDir.endswith('.zip'):
73 mainModuleDir = os.path.dirname(mainModuleDir) # Get rid of library.zip
74 else:
75 mainModuleDir = os.path.dirname(sys.executable)
76
77 os.environ[MAINMODULE_DIR] = mainModuleDir # pythonBug: os.putenv doesn't work, set environment variable
78
79 return mainModuleDir
80
81mainModuleDir = _generateMainModuleDir()
82
83def _generatePythonExecPath():
84 # On Mac, the python executable sometimes has a capital "P" so we need to
85 # lower the string first
86 sysExecLower = sys.executable.lower()
87 if sysExecLower.find('python') != -1 or sysExecLower.find('apache') != -1:
88 pythonExecPath = sys.executable
89 else:
90 # this is where py2app puts the Python executable
91 if sys.platform == "darwin":
92 pythonExecPath = os.path.join(os.path.dirname(sys.executable), "../Frameworks/Python.Framework/Versions/2.4/Python/bin")
93 else:
94 pythonExecPath = os.path.join(os.path.dirname(sys.executable), '3rdparty\python2.4\python')
95 return pythonExecPath
96
97pythonExecPath = _generatePythonExecPath()
98
99def getCommandNameForExecPath(execPath):
100 if isWindows():
101 return '"%s"' % execPath
102 return execPath
103
aca310e5
RD
104def getUserName():
105 if isWindows():
106 return os.getenv('USERNAME')
107 else:
108 # 06-Feb-06 stoens@activegrid.com --
109 # this blows up the linux cc runs with "Inappropriate ioctl for device"
110 #return os.getlogin()
111 return os.getenv('USER')
112
113def getCurrentTimeAsFloat():
114 return time.time()
115
116systemStartTime = getCurrentTimeAsFloat()