def __init__(self): wx.App.__init__(self, redirect=False) self.SetAppName('fr0st') self.standard_paths = wx.StandardPaths.Get() # AppBaseDir needs to be set before any path manipulation so abspath # works as expected. if self.Frozen: self.AppBaseDir = os.path.abspath(os.path.dirname(sys.executable)) else: self.AppBaseDir = os.path.abspath(os.path.dirname(sys.argv[0])) if 'win32' in sys.platform: # On windows, GetResourcesDir returns something like # "c:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\" # Grab the base directory instead self.resource_dir = self.AppBaseDir else: self.resource_dir = self.standard_paths.GetResourcesDir() # On *nix, GetDocumentsDir returns ~. use .fr0st rather than fr0st user_dir = self.standard_paths.GetDocumentsDir() if os.path.realpath(os.path.expanduser('~')) == os.path.realpath(user_dir): self.user_dir = os.path.join(user_dir, '.fr0st') else: self.user_dir = os.path.join(user_dir, 'fr0st') init_config(os.path.join(self.ConfigDir, 'config.cfg')) self.SyncUserDirectory() # set the cwd to user dir so relative paths will work as expected and # not depend on the platform. os.chdir(self.user_dir)
def __init__(self): wx.App.__init__(self, redirect=False) self.SetAppName('fr0st') self.standard_paths = wx.StandardPaths.Get() self.config_dir = os.path.join(self.standard_paths.GetUserConfigDir(), '.fr0st') if 'win32' in sys.platform: # On windows, GetResourcesDir returns something like # "c:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\" # Grab the base directory instead self.resource_dir = self.AppBaseDir else: self.resource_dir = self.standard_paths.GetResourcesDir() self.user_dir = self.standard_paths.GetDocumentsDir() # On *nix, GetDocumentsDir returns ~. use .fr0st rather than fr0st if os.path.realpath(os.path.expanduser('~')) == os.path.realpath(self.user_dir): self.user_dir = os.path.join(self.user_dir, '.fr0st') else: self.user_dir = os.path.join(self.user_dir, 'fr0st') paths_to_check = [ self.ConfigDir, self.RendersDir, self.UserScriptsDir, self.UserParametersDir, ] for path in paths_to_check: if not os.path.isdir(path): os.makedirs(path) init_config()