def CreateConfigDir(): """ Creates the user config directory its default sub directories and any of the default config files. @postcondition: all default configuration files/folders are created """ #---- Resolve Paths ----# config_dir = ed_glob.CONFIG['CONFIG_BASE'] if config_dir is None: config_dir = wx.StandardPaths_Get().GetUserDataDir() + os.sep profile_dir = os.path.join(config_dir, u"profiles") dest_file = os.path.join(profile_dir, u"default.ppb") ext_cfg = [u"cache", u"styles", u"plugins"] #---- Create Directories ----# if not os.path.exists(config_dir): os.mkdir(config_dir) if not os.path.exists(profile_dir): os.mkdir(profile_dir) for cfg in ext_cfg: if not HasConfigDir(cfg): MakeConfigDir(cfg) import profiler profiler.Profile().LoadDefaults() profiler.Profile_Set("MYPROFILE", dest_file) profiler.Profile().Write(dest_file) profiler.UpdateProfileLoader()
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, os.sep) base = ed_glob.CONFIG['CONFIG_BASE'] if base is None: base = wx.StandardPaths.Get().GetUserDataDir() + os.sep err = 0 if os.path.exists(old_cdir) and \ base.lower().rstrip(os.sep) != old_cdir.lower().rstrip(os.sep): for item in os.listdir(old_cdir): print item try: dest = os.path.join(base, item) item = os.path.join(old_cdir, item) if os.path.exists(dest): if os.path.isdir(dest): shutil.rmtree(dest, True) else: os.remove(dest) shutil.move(item, dest) except Exception, msg: util.Log("[Upgrade][err] %s" % msg) err += 1 continue os.rmdir(old_cdir) # Load the copied over profile pstr = profiler.GetProfileStr() prof = os.path.basename(pstr) pstr = os.path.join(base, u"profiles", prof) if os.path.exists(pstr): profiler.Profile().Load(pstr) profiler.Profile().Update() profiler.UpdateProfileLoader() if not err: wx.MessageBox(_("Your profile has been updated to the latest " "version") + u"\n" + \ _("Please check the preferences dialog to check " "your preferences"), _("Profile Updated"))
def CreateConfigDir(): """ Creates the user config directory its default sub directories and any of the default config files. @postcondition: all default configuration files/folders are created """ #---- Resolve Paths ----# config_dir = u"%s%s.%s" % (wx.GetHomeDir(), os.sep, ed_glob.PROG_NAME) profile_dir = u"%s%sprofiles" % (config_dir, os.sep) dest_file = u"%s%sdefault.ppb" % (profile_dir, os.sep) ext_cfg = ["cache", "styles", "plugins"] #---- Create Directories ----# if not os.path.exists(config_dir): os.mkdir(config_dir) if not os.path.exists(profile_dir): os.mkdir(profile_dir) for cfg in ext_cfg: if not HasConfigDir(cfg): MakeConfigDir(cfg) import profiler profiler.Profile().LoadDefaults() profiler.Profile_Set("MYPROFILE", dest_file) profiler.UpdateProfileLoader()
def testSingleton(self): """Test that only the single instance of the Profile can be used""" self._profile.Set('UNIQUEVALUE', 'MYVALUE!!') new_profile = profiler.Profile() val = new_profile.Get('UNIQUEVALUE') self.assertEquals(val, 'MYVALUE!!') self.assertTrue(self._profile is new_profile)
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 __init__(self, *args, **kargs): """Initialize that main app and its attributes @postcondition: application is created and ready to be run in mainloop """ wx.App.__init__(self, *args, **kargs) events.AppEventHandlerMixin.__init__(self) self.SetAppName(ed_glob.PROG_NAME) # Attributes self.profile_updated = InitConfig() self._log = dev_tool.DEBUGP self._lock = False self._windows = dict() if ed_glob.SINGLE: # Setup the instance checker instance_name = u"%s-%s" % (self.GetAppName(), wx.GetUserId()) self._instance = wx.SingleInstanceChecker(instance_name) if self._instance.IsAnotherRunning(): try: opts, args = getopt.getopt(sys.argv[1:], "dhv", ['debug', 'help', 'version']) except getopt.GetoptError, msg: self._log("[app][err] %s" % str(msg)) args = list() if not len(args): args.append(APP_CMD_OPEN_WINDOW) rval = ed_ipc.SendCommands(args, profiler.Profile_Get('SESSION_KEY')) # If sending the command failed then let the editor startup # a new instance if not rval: self._isfirst = True else: self._log("[app][info] Starting Ipc server...") # Set the session key and save it to the users profile so # that other instances can access the server key = unicode(base64.b64encode(os.urandom(8), 'zZ')) key = wx.GetUserName() + key profiler.Profile_Set('SESSION_KEY', key) profiler.Profile_Set('ISBINARY', hasattr(sys, 'frozen')) path = profiler.Profile_Get('MYPROFILE') profiler.Profile().Write(path) try: self._server = ed_ipc.EdIpcServer( self, profiler.Profile_Get('SESSION_KEY')) self._server.start() except Exception, msg: self._log("[app][err] Failed to start ipc server") self._log("[app][err] %s" % str(msg)) self._server = None self._isfirst = True
def Exit(self, force=False): """Exit the program @postcondition: If no toplevel windows are present program will exit. @postcondition: Program may remain open if an open window is locking. """ self._pluginmgr.WritePluginConfig() profiler.Profile().Write(profiler.Profile_Get('MYPROFILE')) if not self._lock or force: wx.App.Exit(self)
def OnInit(self): """Initialize the Editor @note: this gets called before __init__ @postcondition: custom artprovider and plugins are loaded """ self.SetAppName(ed_glob.PROG_NAME) self._log = dev_tool.DEBUGP self._log("[app][info] Editra is Initializing") self._isfirst = False # Is the first instance self._instance = None if ed_glob.SINGLE: # Setup the instance checker instance_name = u"%s-%s" % (self.GetAppName(), wx.GetUserId()) self._instance = wx.SingleInstanceChecker(instance_name) if self._instance.IsAnotherRunning(): try: opts, args = getopt.getopt(sys.argv[1:], "dhv", ['debug', 'help', 'version']) except getopt.GetoptError, msg: self._log("[app][err] %s" % str(msg)) args = list() if not len(args): args.append(APP_CMD_OPEN_WINDOW) rval = ed_ipc.SendCommands(args, profiler.Profile_Get('SESSION_KEY')) # If sending the command failed then let the editor startup # a new instance if not rval: self._isfirst = True else: self._log("[app][info] Starting Ipc server...") # Set the session key and save it to the users profile so # that other instances can access the server key = unicode(base64.b64encode(os.urandom(8), 'zZ')) key = wx.GetUserName() + key profiler.Profile_Set('SESSION_KEY', key) profiler.Profile_Set('ISBINARY', hasattr(sys, 'frozen')) path = profiler.Profile_Get('MYPROFILE') profiler.Profile().Write(path) try: self._server = ed_ipc.EdIpcServer( self, profiler.Profile_Get('SESSION_KEY')) self._server.start() except Exception, msg: self._log("[app][err] Failed to start ipc server") self._log("[app][err] %s" % str(msg)) self._server = None self._isfirst = True
def OnSaveProfile(self, evt): """Saves current settings as a profile @param evt: Event fired that called this handler @type evt: wxMenuEvent """ if evt.GetId() == ID_SAVE_PROFILE: dlg = wx.FileDialog(self, _("Where to Save Profile?"), \ CONFIG['PROFILE_DIR'], "default.ppb", \ _("Profile") + " (*.ppb)|*.ppb", wx.SAVE | wx.OVERWRITE_PROMPT) if dlg.ShowModal() == wx.ID_OK: profiler.Profile().Write(dlg.GetPath()) self.PushStatusText(_("Profile Saved as: %s") % \ dlg.GetFilename(), SB_INFO) dlg.Destroy() else: evt.Skip()
def Exit(self, force=False): """Exit the program @postcondition: If no toplevel windows are present program will exit. @postcondition: Program may remain open if an open window is locking. """ self._pluginmgr.WritePluginConfig() profiler.Profile().Write(profiler.Profile_Get('MYPROFILE')) if not self._lock or force: if hasattr(self, 'server'): self.server.ShutDown() try: # Cleanup the instance checker del self._instance except AttributeError: pass # Exit the app wx.App.ExitMainLoop(self)
def OnLoadProfile(self, evt): """Loads a profile and refreshes the editors state to match the settings found in the profile file. @param evt: Event fired that called this handler @type evt: wxMenuEvent """ if evt.GetId() == ID_LOAD_PROFILE: dlg = wx.FileDialog(self, _("Load a Custom Profile"), CONFIG['PROFILE_DIR'], "default.ppb", _("Profile") + " (*.ppb)|*.ppb", wx.OPEN) result = dlg.ShowModal() if result == wx.ID_OK: profiler.Profile().Load(dlg.GetPath()) self.PushStatusText(_("Loaded Profile: %s") % \ dlg.GetFilename(), SB_INFO) dlg.Destroy() # Update editor to reflect loaded profile for win in wx.GetApp().GetMainWindows(): win.nb.UpdateTextControls() else: evt.Skip()
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 OnClose(self, evt=None): """Close this frame and unregister it from the applications mainloop. @note: Closing the frame will write out all session data to the users configuration directory. @keyword evt: Event fired that called this handler @type evt: wxMenuEvent @return: None on destroy, or True on cancel """ # Cleanup Controls _PSET('LAST_SESSION', self.nb.GetFileNames()) self._exiting = True controls = self.nb.GetPageCount() self.LOG("[ed_main][evt] OnClose: Number of controls: %d" % controls) while controls: if controls <= 0: self.Close(True) # Force exit since there is a problem self.LOG("[ed_main][evt] OnClose: Requesting Page Close") result = self.nb.ClosePage() if result == wx.ID_CANCEL: self._exiting = False return True controls -= 1 ### If we get to here there is no turning back so cleanup ### additional items and save user settings # Write out saved document information self.nb.DocMgr.WriteBook() syntax.SyntaxMgr().SaveState() # Save Shelf contents _PSET('SHELF_ITEMS', self._shelf.GetItemStack()) # Save Window Size/Position for next launch self.UpdateAutoPerspective() # XXX On wxMac the window size doesnt seem to take the toolbar # into account so destroy it so that the window size is accurate. if wx.Platform == '__WXMAC__' and self.GetToolBar(): self.GetToolBar().Destroy() # Raise the window from being iconized so that the size and position is # correct for the next launch (msw). if self.IsIconized(): self.Iconize(False) _PSET('WSIZE', self.GetSizeTuple()) _PSET('MAXIMIZED', self.IsMaximized()) _PSET('WPOS', self.GetPositionTuple()) self.LOG("[ed_main][evt] OnClose: Closing editor at pos=%s size=%s" % \ (_PGET('WPOS', 'str'), _PGET('WSIZE', 'str'))) # Update profile profiler.AddFileHistoryToProfile(self.filehistory) profiler.Profile().Write(_PGET('MYPROFILE')) # Cleanup file history try: del self.filehistory except AttributeError: self.LOG("[ed_main][err] OnClose: Trapped AttributeError OnExit") # Post exit notice to all aui panes panes = self._mgr.GetAllPanes() exit_evt = ed_event.MainWindowExitEvent(ed_event.edEVT_MAINWINDOW_EXIT, wx.ID_ANY) for pane in panes: wx.PostEvent(pane.window, exit_evt) # Finally close the window self.LOG("[ed_main][evt] OnClose: Closing Main Frame") wx.GetApp().UnRegisterWindow(repr(self)) self.Destroy()
def get(self): self.response.headers['Content-Type'] = 'text/html' self.response.out.write( """ <html>\n <head>\n <title>League Table</title>\n <link rel=\"stylesheet\" type=\"text/css\" href="style.css"/>\n </head>\n<body class="claro">""" ) self.response.out.write( """<div class ="bar" id="nav"><div class="gbar"><b>League Table</b></div>""" ) if users.get_current_user(): myUser = users.get_current_user() self.response.out.write('<div class="user"><b>%s</b>' % (myUser.email())) self.response.out.write( ' | <a href="%s"> Sign out</a></div>' % (users.create_logout_url('http://%s/' % settings.HOST_NAME))) else: self.response.out.write( '<div class="user"><a href="%s">Sign in</a></div>' % (users.create_login_url('http://%s/' % settings.HOST_NAME))) self.response.out.write('</div>') # Initialize a client to talk to Google Data API services. client = gdata.service.GDataService() gdata.alt.appengine.run_on_appengine(client) session_token = None # Find the AuthSub token and upgrade it to a session token. auth_token = gdata.auth.extract_auth_sub_token_from_url( self.request.uri) if auth_token: # Upgrade the single-use AuthSub token to a multi-use session token. session_token = client.upgrade_to_session_token(auth_token) if session_token and users.get_current_user(): # If there is a current user, store the token in the datastore and # associate it with the current user. Since we told the client to # run_on_appengine, the add_token call will automatically store the # session token if there is a current_user. client.token_store.add_token(session_token) elif session_token: # Since there is no current user, we will put the session token # in a property of the client. We will not store the token in the # datastore, since we wouldn't know which user it belongs to. # Since a new client object is created with each get call, we don't # need to worry about the anonymous token being used by other users. client.current_token = session_token # Get the URL for the desired feed and get the display option. feed_url = self.request.get('feed_url') erase_tokens = self.request.get('erase_tokens') if erase_tokens: self.EraseStoredTokens() show_xml = self.request.get('xml') if show_xml: checked_string = 'checked' else: checked_string = '' if users.get_current_user(): feed_url = self.request.get('feed_url') next = atom.url.Url('http', settings.HOST_NAME, params={'feed_url': feed_url}) tokens = gdata.alt.appengine.load_auth_tokens() spreadsheets = False contacts = False for token_scope in tokens: logging.debug('TOKEN: %s' % token_scope) variable = token_scope.split("/") for v in variable: logging.debug('TOKEN: %s' % v) if variable[2] == "spreadsheets.google.com": spreadsheets = True self.response.out.write( '<script language=\"javascript\" type=\"text/javascript\">') if spreadsheets == False: self.response.out.write( 'document.location.href = \"%s"' % (self.GenerateScopeRequestLink( client, 'http://spreadsheets.google.com/feeds/'))) self.response.out.write('</script>') newaccount = True profiles = db.GqlQuery("SELECT * FROM Profile WHERE account = :1", users.get_current_user().email()) for p in profiles: newaccount = False if newaccount == True: newprofile = profiler.Profile() newprofile.account = users.get_current_user().email() newprofile.put() # twitter.log( "Created a new account for %s" % users.get_current_user().nickname() ) template_values = {} path = os.path.join(os.path.dirname(__file__), 'index.html') self.response.out.write(template.render(path, template_values)) #self.response.out.write( '<div id="myContent"><p>Alternative content</p></div></body></html>') #if users.get_current_user(): # twitter.log( "%s logged into leaguetable." % users.get_current_user().nickname() ) else: self.response.out.write("""<div id="wrap"> """) if not feed_url: self.writeContent() else: self.FetchFeed(client, feed_url, show_xml)
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
def testIdentity(self): """Test that only one profile object can be created.""" self.assertTrue(self._profile is profiler.Profile())