예제 #1
0
    def _load_settings(self):
        """Load global and core settings files.  Deals with old format for storing settings"""

        #load a global config that said whether to store the last user that logged in (and his password)
        self.globalSettings = GlobalSettings.load()
        #always save, so the user can more easily edit the file for starting up from the console
        self.globalSettings.save()

        #does a settings file already exist?
        settingsFile = os.path.join(Globals.USER_DATA_DIR,
                                    CoreSettings.CoreSettings.defaultFile)
        if not Files.file_exists(settingsFile):
            #if not, make the folder
            if not Files.file_exists(Globals.USER_DATA_DIR):
                os.makedirs(Globals.USER_DATA_DIR)
            #and check that this isnt an old installation (we used to store settings on a
            #per username basis, which turned out to be a stupid idea).  If that data exists,
            #copy it to the new location.
            if len(self.globalSettings.username) > 0:
                oldSettingsFilePath = os.path.join(
                    Globals.USER_DATA_DIR, self.globalSettings.username,
                    CoreSettings.CoreSettings.defaultFile)
                if os.path.exists(oldSettingsFilePath):
                    oldFolder = os.path.join(Globals.USER_DATA_DIR,
                                             self.globalSettings.username)
                    newFolder = Globals.USER_DATA_DIR
                    Files.recursive_copy_folder(oldFolder, newFolder)

        #load the core settings:
        CoreSettings.start()
        self.coreSettings = CoreSettings.get()
        self.coreSettings.load(settingsFile)
        self.coreSettings.fileName = settingsFile
예제 #2
0
 def _load_settings(self):
   """Load global and core settings files.  Deals with old format for storing settings"""
   
   #load a global config that said whether to store the last user that logged in (and his password)
   self.globalSettings = GlobalSettings.load()
   #always save, so the user can more easily edit the file for starting up from the console
   self.globalSettings.save()
   
   #does a settings file already exist?
   settingsFile = os.path.join(Globals.USER_DATA_DIR, CoreSettings.CoreSettings.defaultFile)
   if not Files.file_exists(settingsFile):
     #if not, make the folder
     if not Files.file_exists(Globals.USER_DATA_DIR):
       os.makedirs(Globals.USER_DATA_DIR)
     #and check that this isnt an old installation (we used to store settings on a 
     #per username basis, which turned out to be a stupid idea).  If that data exists,
     #copy it to the new location.
     if len(self.globalSettings.username) > 0:
       oldSettingsFilePath = os.path.join(Globals.USER_DATA_DIR, self.globalSettings.username, CoreSettings.CoreSettings.defaultFile)
       if os.path.exists(oldSettingsFilePath):
         oldFolder = os.path.join(Globals.USER_DATA_DIR, self.globalSettings.username)
         newFolder = Globals.USER_DATA_DIR
         Files.recursive_copy_folder(oldFolder, newFolder)
       
   #load the core settings:
   CoreSettings.start()
   self.coreSettings = CoreSettings.get()
   self.coreSettings.load(settingsFile)
   self.coreSettings.fileName = settingsFile