def InitConfig(): """Initializes the configuration data @postcondition: all configuration data is set """ ed_glob.CONFIG['PROFILE_DIR'] = util.ResolvConfigDir("profiles") import profiler profile_updated = False if util.HasConfigDir(): if profiler.ProfileIsCurrent(): profiler.Profile().Load(profiler.GetProfileStr()) else: dev_tool.DEBUGP("[main_info] Updating Profile to current version") pstr = profiler.GetProfileStr() # upgrade earlier profiles to current if len(pstr) > 3 and pstr[-2:] == "pp": pstr = pstr + u'b' profiler.Profile().LoadDefaults() if wx.Platform == '__WXGTK__': Profile_Set('ICONS', 'Default') profiler.Profile().Write(pstr) # Write out defaults profiler.Profile().Load(pstr) # Test reload profile # When upgrading from an older version make sure all # config directories are available. for cfg in ["cache", "styles", "plugins", "profiles"]: if not util.HasConfigDir(cfg): util.MakeConfigDir(cfg) profile_updated = True else: util.CreateConfigDir() if 'DEBUG' in Profile_Get('MODE'): ed_glob.DEBUG = True ed_glob.CONFIG['CONFIG_DIR'] = util.ResolvConfigDir("") ed_glob.CONFIG['PIXMAPS_DIR'] = util.ResolvConfigDir("pixmaps") ed_glob.CONFIG['SYSPIX_DIR'] = util.ResolvConfigDir("pixmaps", True) ed_glob.CONFIG['PLUGIN_DIR'] = util.ResolvConfigDir("plugins") ed_glob.CONFIG['THEME_DIR'] = util.ResolvConfigDir(os.path.join("pixmaps", \ "theme")) ed_glob.CONFIG['LANG_DIR'] = util.ResolvConfigDir("locale", True) ed_glob.CONFIG['STYLES_DIR'] = util.ResolvConfigDir("styles") ed_glob.CONFIG['SYS_PLUGIN_DIR'] = util.ResolvConfigDir("plugins", True) ed_glob.CONFIG['SYS_STYLES_DIR'] = util.ResolvConfigDir("styles", True) ed_glob.CONFIG['TEST_DIR'] = util.ResolvConfigDir("tests", True) if not util.HasConfigDir("cache"): util.MakeConfigDir("cache") ed_glob.CONFIG['CACHE_DIR'] = util.ResolvConfigDir("cache") return profile_updated
def InitConfig(): """Initializes the configuration data @postcondition: all configuration data is set """ ed_glob.CONFIG['PROFILE_DIR'] = util.ResolvConfigDir("profiles") profile_updated = False if util.HasConfigDir(): if profiler.ProfileIsCurrent(): profiler.Profile().Load(profiler.GetProfileStr()) else: dev_tool.DEBUGP( "[InitConfig][info] Updating Profile to current version") # Load and update profile pstr = profiler.GetProfileStr() profiler.Profile().Load(pstr) profiler.Profile().Update() #---- Temporary Profile Adaptions ----# # GUI_DEBUG mode removed in 0.2.5 mode = profiler.Profile_Get('MODE') if mode == 'GUI_DEBUG': profiler.Profile_Set('MODE', 'DEBUG') profiler.Profile_Del('LASTCHECK') #---- End Temporary Profile Adaptions ----# # Write out updated profile profiler.Profile().Write(pstr) # When upgrading from an older version make sure all # config directories are available. for cfg in ["cache", "styles", "plugins", "profiles"]: if not util.HasConfigDir(cfg): util.MakeConfigDir(cfg) profile_updated = True else: # Fresh install util.CreateConfigDir() # Set default eol for windows if wx.Platform == '__WXMSW__': profiler.Profile_Set('EOL', 'Windows (\\r\\n)') # Set debug mode if 'DEBUG' in profiler.Profile_Get('MODE'): ed_glob.DEBUG = True # Resolve resource locations ed_glob.CONFIG['CONFIG_DIR'] = util.ResolvConfigDir("") ed_glob.CONFIG['SYSPIX_DIR'] = util.ResolvConfigDir("pixmaps", True) ed_glob.CONFIG['PLUGIN_DIR'] = util.ResolvConfigDir("plugins") ed_glob.CONFIG['THEME_DIR'] = util.ResolvConfigDir( os.path.join("pixmaps", "theme")) ed_glob.CONFIG['LANG_DIR'] = util.ResolvConfigDir("locale", True) ed_glob.CONFIG['STYLES_DIR'] = util.ResolvConfigDir("styles") ed_glob.CONFIG['SYS_PLUGIN_DIR'] = util.ResolvConfigDir("plugins", True) ed_glob.CONFIG['SYS_STYLES_DIR'] = util.ResolvConfigDir("styles", True) ed_glob.CONFIG['TEST_DIR'] = util.ResolvConfigDir( os.path.join("tests", "syntax"), True) if not util.HasConfigDir("cache"): util.MakeConfigDir("cache") ed_glob.CONFIG['CACHE_DIR'] = util.ResolvConfigDir("cache") return profile_updated
def InitConfig(): """Initializes the configuration data @postcondition: all configuration data is set """ # Look for a profile directory on the system level. If this directory exists # Use it instead of the user one. This will allow for running Editra from # a portable drive or for system administrators to enforce settings on a # system installed version. config_base = util.ResolvConfigDir(u'.Editra', True) if os.path.exists(config_base): ed_glob.CONFIG['CONFIG_BASE'] = config_base ed_glob.CONFIG['PROFILE_DIR'] = os.path.join(config_base, u"profiles") ed_glob.CONFIG['PROFILE_DIR'] += os.sep else: config_base = wx.StandardPaths.Get().GetUserDataDir() ed_glob.CONFIG['PROFILE_DIR'] = util.ResolvConfigDir("profiles") # Check for if config directory exists and if profile is from the current # running version of Editra. profile_updated = False if util.HasConfigDir() and os.path.exists(ed_glob.CONFIG['PROFILE_DIR']): if profiler.ProfileIsCurrent(): profiler.Profile().Load(profiler.GetProfileStr()) else: dev_tool.DEBUGP( "[InitConfig][info] Updating Profile to current version") # Load and update profile pstr = profiler.GetProfileStr() profiler.Profile().Load(pstr) profiler.Profile().Update() #---- Temporary Profile Adaptions ----# # GUI_DEBUG mode removed in 0.2.5 mode = profiler.Profile_Get('MODE') if mode == 'GUI_DEBUG': profiler.Profile_Set('MODE', 'DEBUG') # This key has been removed so clean it from old profiles profiler.Profile_Del('LASTCHECK') # Print modes don't use strings anymore if isinstance(profiler.Profile_Get('PRINT_MODE'), basestring): profiler.Profile_Set('PRINT_MODE', ed_glob.PRINT_BLACK_WHITE) # Simplifications to eol mode persistance (0.4.0) TranslateEOLMode() #---- End Temporary Profile Adaptions ----# # Write out updated profile profiler.Profile().Write(pstr) # When upgrading from an older version make sure all # config directories are available. for cfg in ["cache", "styles", "plugins", "profiles"]: if not util.HasConfigDir(cfg): util.MakeConfigDir(cfg) profile_updated = True else: # Fresh install util.CreateConfigDir() # Check and upgrade installs from old location success = True try: success = UpgradeOldInstall() except Exception, msg: dev_tool.DEBUGP("[InitConfig][err] %s" % msg) success = False if not success: old_cdir = u"%s%s.%s%s" % (wx.GetHomeDir(), os.sep, ed_glob.PROG_NAME, os.sep) msg = ( "Failed to upgrade your old installation\n" "To retain your old settings you may need to copy some files:\n" "\nFrom: %s\n\nTo: %s") % (old_cdir, config_base) wx.MessageBox(msg, "Upgrade Failed", style=wx.ICON_WARNING | wx.OK) # Set default eol for windows if wx.Platform == '__WXMSW__': profiler.Profile_Set('EOL', 'CRLF') profiler.Profile_Set('ICONSZ', (16, 16))
def InitConfig(): """Initializes the configuration data @postcondition: all configuration data is set """ # Look for a profile directory on the system level. If this directory exists # Use it instead of the user one. This will allow for running Editra from # a portable drive or for system administrators to enforce settings on a # system installed version. config_base = util.ResolvConfigDir(u'.Editra', True) if os.path.exists(config_base): ed_glob.CONFIG['CONFIG_BASE'] = config_base ed_glob.CONFIG['PROFILE_DIR'] = os.path.join(config_base, u"profiles") ed_glob.CONFIG['PROFILE_DIR'] += os.sep else: ed_glob.CONFIG['PROFILE_DIR'] = util.ResolvConfigDir("profiles") # Check for if config directory exists and if profile is from the current # running version of Editra. profile_updated = False if util.HasConfigDir() and os.path.exists(ed_glob.CONFIG['PROFILE_DIR']): if profiler.ProfileIsCurrent(): profiler.Profile().Load(profiler.GetProfileStr()) else: dev_tool.DEBUGP( "[InitConfig][info] Updating Profile to current version") # Load and update profile pstr = profiler.GetProfileStr() profiler.Profile().Load(pstr) profiler.Profile().Update() #---- Temporary Profile Adaptions ----# # GUI_DEBUG mode removed in 0.2.5 mode = profiler.Profile_Get('MODE') if mode == 'GUI_DEBUG': profiler.Profile_Set('MODE', 'DEBUG') # This key has been removed so clean it from old profiles profiler.Profile_Del('LASTCHECK') # Print modes don't use strings anymore if isinstance(profiler.Profile_Get('PRINT_MODE'), basestring): profiler.Profile_Set('PRINT_MODE', ed_glob.PRINT_BLACK_WHITE) #---- End Temporary Profile Adaptions ----# # Write out updated profile profiler.Profile().Write(pstr) # When upgrading from an older version make sure all # config directories are available. for cfg in ["cache", "styles", "plugins", "profiles"]: if not util.HasConfigDir(cfg): util.MakeConfigDir(cfg) profile_updated = True else: # Fresh install util.CreateConfigDir() # Set default eol for windows if wx.Platform == '__WXMSW__': profiler.Profile_Set('EOL', 'Windows (\\r\\n)') # Set debug mode if 'DEBUG' in profiler.Profile_Get('MODE'): ed_glob.DEBUG = True # Resolve resource locations ed_glob.CONFIG['CONFIG_DIR'] = util.ResolvConfigDir("") ed_glob.CONFIG['SYSPIX_DIR'] = util.ResolvConfigDir("pixmaps", True) ed_glob.CONFIG['PLUGIN_DIR'] = util.ResolvConfigDir("plugins") ed_glob.CONFIG['THEME_DIR'] = util.ResolvConfigDir( os.path.join("pixmaps", "theme")) ed_glob.CONFIG['LANG_DIR'] = util.ResolvConfigDir("locale", True) ed_glob.CONFIG['STYLES_DIR'] = util.ResolvConfigDir("styles") ed_glob.CONFIG['SYS_PLUGIN_DIR'] = util.ResolvConfigDir("plugins", True) ed_glob.CONFIG['SYS_STYLES_DIR'] = util.ResolvConfigDir("styles", True) ed_glob.CONFIG['TEST_DIR'] = util.ResolvConfigDir( os.path.join("tests", "syntax"), True) if not util.HasConfigDir("cache"): util.MakeConfigDir("cache") ed_glob.CONFIG['CACHE_DIR'] = util.ResolvConfigDir("cache") return profile_updated
ed_glob.CONFIG['CONFIG_DIR'] = util.ResolvConfigDir("") ed_glob.CONFIG['SYSPIX_DIR'] = util.ResolvConfigDir("pixmaps", True) ed_glob.CONFIG['PLUGIN_DIR'] = util.ResolvConfigDir("plugins") ed_glob.CONFIG['THEME_DIR'] = util.ResolvConfigDir( os.path.join("pixmaps", "theme")) ed_glob.CONFIG['LANG_DIR'] = util.ResolvConfigDir("locale", True) ed_glob.CONFIG['STYLES_DIR'] = util.ResolvConfigDir("styles") ed_glob.CONFIG['SYS_PLUGIN_DIR'] = util.ResolvConfigDir("plugins", True) ed_glob.CONFIG['SYS_STYLES_DIR'] = util.ResolvConfigDir("styles", True) ed_glob.CONFIG['TEST_DIR'] = util.ResolvConfigDir( os.path.join("tests", "syntax"), True) # Make sure all standard config directories are there for cfg in ["cache", "styles", "plugins", "profiles"]: if not util.HasConfigDir(cfg): util.MakeConfigDir(cfg) ed_glob.CONFIG['CACHE_DIR'] = util.ResolvConfigDir("cache") return profile_updated #--------------------------------------------------------------------------# def UpgradeOldInstall(): """Upgrade an old installation and transfer all files if they exist @note: FOR INTERNAL USE ONLY @return: bool (True if success, False if failure) """ old_cdir = u"%s%s.%s%s" % (wx.GetHomeDir(), os.sep, ed_glob.PROG_NAME,