Esempio n. 1
0
 def save_option(self, path, section, option, value):
     """
     Write the specified Section.Option to the config file specified by path.
     Replace any previous value.  If the path doesn't exist, create it.
     Also add the option the the in-memory config.
     """
     config = SafeConfigParser()
     config.read(path)
     if not config.has_section(section):
         config.add_section(section)
     config.set(section, option, value)
     fp = open(path, 'w')
     config.write(fp)
     fp.close()
     if not self.has_section(section):
         self.add_section(section)
     self.set(section, option, value)
Esempio n. 2
0
 def __init__(self, path=None, fp=None, do_load=True):
     # We don't use ``super`` here, because ``ConfigParser`` still uses
     # old-style classes.
     SafeConfigParser.__init__(self, {'working_dir': '/mnt/pyami',
                                      'debug': '0'})
     if do_load:
         if path:
             self.load_from_path(path)
         elif fp:
             self.readfp(fp)
         else:
             self.read(BotoConfigLocations)
         if "AWS_CREDENTIAL_FILE" in os.environ:
             full_path = expanduser(os.environ['AWS_CREDENTIAL_FILE'])
             try:
                 self.load_credential_file(full_path)
             except IOError:
                 warnings.warn('Unable to load AWS_CREDENTIAL_FILE (%s)' % full_path)
Esempio n. 3
0
 def __init__(self, path=None, fp=None, do_load=True):
     # We don't use ``super`` here, because ``ConfigParser`` still uses
     # old-style classes.
     SafeConfigParser.__init__(self, {
         'working_dir': '/mnt/pyami',
         'debug': '0'
     })
     if do_load:
         if path:
             self.load_from_path(path)
         elif fp:
             self.readfp(fp)
         else:
             self.read(BotoConfigLocations)
         if "AWS_CREDENTIAL_FILE" in os.environ:
             full_path = expanduser(os.environ['AWS_CREDENTIAL_FILE'])
             try:
                 self.load_credential_file(full_path)
             except IOError:
                 warnings.warn('Unable to load AWS_CREDENTIAL_FILE (%s)' %
                               full_path)
Esempio n. 4
0
 def getfloat(self, section, name, default=0.0):
     try:
         val = SafeConfigParser.getfloat(self, section, name)
     except:
         val = float(default)
     return val
Esempio n. 5
0
 def get(self, section, name, default=None):
     try:
         val = SafeConfigParser.get(self, section, name)
     except:
         val = default
     return val
Esempio n. 6
0
 def save_option(self, path, section, option, value):
     """
     Write the specified Section.Option to the config file specified by path.
     Replace any previous value.  If the path doesn't exist, create it.
     Also add the option the the in-memory config.
     """
     config = SafeConfigParser()
     config.read(path)
     if not config.has_section(section):
         config.add_section(section)
     config.set(section, option, value)
     fp = open(path, 'w')
     config.write(fp)
     fp.close()
     if not self.has_section(section):
         self.add_section(section)
     self.set(section, option, value)
Esempio n. 7
0
 def getfloat(self, section, name, default=0.0):
     try:
         val = SafeConfigParser.getfloat(self, section, name)
     except:
         val = float(default)
     return val
Esempio n. 8
0
 def get(self, section, name, default=None):
     try:
         val = SafeConfigParser.get(self, section, name)
     except:
         val = default
     return val