def ProcessAppFile(appFile): """ Process the Application File returning the appinfo and the command dictionary. """ commands = dict() # Read in .app file appInfo = LoadConfig(appFile) # Build command list for key in appInfo.keys(): spList = key.split('.') if len(spList) > 1: (section, option) = spList if section == "commands": verb = option cmd = appInfo[key] # If the named argument python is used, replace it if cmd.find("%(python)s") != -1: if sys.platform == 'darwin': cmd = cmd.replace("%(python)s", '/usr/bin/pythonw') else: cmd = cmd.replace("%(python)s", sys.executable) commands[verb] = cmd return appInfo, commands
def ProcessPluginFile(pluginFile): """ Process the Plugin File returning the plugininfo and the command dictionary. """ command = None # Read in .plugin file pluginInfo = LoadConfig(pluginFile) return pluginInfo, command
def Load(self, fileName=None): if fileName == None: fileName = self.fileName try: self.PluginDb = LoadConfig(fileName, separator=self.defaultSeparator) except: print sys.exc_info() print 'Couldn\'t open Plugin Database: %s' % fileName
def Load(self, fileName, loadDnDetails=0): """ loadDnDetails is used by the cache to include the reading of a DN when reading from the stored profile. """ profile = ClientProfile.defaultProfile.copy() self.profile = LoadConfig(fileName, profile) self._SetFromConfig() # Get the values from the config if loadDnDetails: # DN used with profileCache, not in standard profile. if 'ClientProfile.distinguishedname' in self.profile: self.distinguishedName = self.profile[ 'ClientProfile.distinguishedname']
def Load(self, fileName=None): """ Load the app db from the file it's stored in. """ if fileName == None: fileName = self.fileName try: self.AppDb = LoadConfig(fileName, separator=self.defaultSeparator) # update the file modification time self._UpdateModTime() except: print sys.exc_info() print "Couldn't open application database: %s" % fileName
def LoadPreferences(self): ''' Read preferences from configuration file. ''' try: log.debug("Preferences.LoadPreferences: open file") preferences = LoadConfig(self.config.GetPreferences()) # Remove category from preference for p in preferences.keys(): category = p.split(".")[0] pref = p.split(".")[1] if category == "Preferences": self.preferences[pref] = preferences[p] # Add any default preferences that are missing for key in self.default: if not self.preferences.has_key(key): # set the initial value of the proxy enabled preference based on whether # the user has specified a proxy host previously # note: this only happens the first time a preferences file is loaded that # is missing the PROXY_ENABLED preference if key == self.PROXY_ENABLED: if self.preferences.has_key(self.PROXY_HOST) and len( self.preferences[self.PROXY_HOST]) > 0: self.preferences[key] = 1 continue self.preferences[key] = self.default[key] except: log.exception("Preferences.LoadPreferences: open file error") self.preferences = {} # Load client profile separately try: profileFile = os.path.join(self.config.GetConfigDir(), "profile") self.profile = ClientProfile(profileFile) except IOError: log.exception("Preferences.LoadPreferences: open file io error") # Load bridges separately for b in self.bridgeCache.GetBridges(): self.__bridges[b.GetKey()] = b
def GetBridges(self): # Get bridges from the local config directory self.bridges = [] bridges = {} if os.path.exists(self.configPath): config = LoadConfig(self.config.GetBridges()) else: # Cache does not exist, return return self.bridges # Parse config dict and create bridge descriptions for key in config.keys(): bridgeid = key.split(".")[0] val = key.split(".")[1] if not bridges.has_key(bridgeid): bridges[bridgeid] = BridgeDescription(bridgeid, "", "", "", "", "") if val == "name": bridges[bridgeid].name = config[key] elif val == "host": bridges[bridgeid].host = config[key] elif val == "port": bridges[bridgeid].port = config[key] elif val == "serverType": bridges[bridgeid].serverType = config[key] elif val == "description": bridges[bridgeid].description = config[key] elif val == "status": bridges[bridgeid].status = config[key] elif val == "rank": bridges[bridgeid].rank = float(config[key]) elif val == "portMin": bridges[bridgeid].portMin = int(config[key]) elif val == "portMax": bridges[bridgeid].portMax = int(config[key]) elif val == "userRank": bridges[bridgeid].userRank = float(config[key]) for b in bridges.values(): self.bridges.append(b) return self.bridges