def establishAppEnvironment():
g.isWin32 = (platform.system() == 'Windows')
g.isOSX = (platform.system() == 'Darwin')
g.isFrozen = (getattr(sys, 'frozen', False)) # note for OSX isFrozen is always false because py2app only marks airnef.pyw as frozen when we're a py2app
#
# determine the directory our script resides in, in case the
# user is executing from a different working directory.
#
g.appDir = os.path.dirname(os.path.realpath(sys.argv[0]))
#
# determine directory for our APPDATA, which contains log
# and configuration files. For Win32 if we're frozen this
# goes in the dedicated OS area for application data files
#
g.appDataDir = None
if g.isFrozen and g.isWin32:
if os.getenv('LOCALAPPDATA'):
g.appDataDir = os.path.join(os.getenv('LOCALAPPDATA'), "airmtp\\appdata") # typically C:\Users\<username>\AppData\Local\airnef\appdata
elif g.isOSX: # for OSX we always try to store our app data under Application Support
userHomeDir = os.getenv('HOME')
if userHomeDir:
applicationSupportDir = os.path.join(userHomeDir, 'Library/Application Support')
if os.path.exists(applicationSupportDir): # probably not necessary to check existence since every system should have this directory
g.appDataDir = os.path.join(applicationSupportDir, 'airmtp/appdata')
if not g.appDataDir:
# none of runtime-specific cases above selected an app data directory - use directory based off our app directory
g.appDataDir = os.path.join(g.appDir, "appdata")
# create our app-specific subdirectories if necessary
if not os.path.exists(g.appDataDir):
os.makedirs(g.appDataDir)
#
# transltes a date or date+time string from the user into an
# epoch time (ie, time in seconds).
#
评论列表
文章目录