spacepaste

  1.  
  2. class PMAConfigGenerator():
  3. def __init__(self, instname=''):
  4. self.log = logging.getLogger('sflog')
  5. if not instname:
  6. raise ValueError('instname cannot be empty')
  7. if not os.path.isfile('pma-' + instname + '.ini'):
  8. raise FileNotFoundError('Could not find instance configuration file')
  9. else:
  10. self.instname = 'pma-' + instname
  11. self.cfgfile = self.instname + '.ini'
  12. self.log.debug('PMAConfigGenerator instance for %s initiated' % self.instname)
  13. try:
  14. self.cfg = ConfigParser()
  15. self.cfg.read(self.cfgfile)
  16. except Exception, e:
  17. self.log.critical('Unable to parse config file %s (%s)' % (self.cfgfile, e))
  18. sys.exit(0)
  19. def __str__(self):
  20. return u'PMAConfigGenerator instance for %s' % self.instname
  21. def __repr__(self):
  22. return u'PMAConfigGenerator instance for %s' % self.instname
  23.