def get_koji_session(self, login=True): """ Return an authenticated koji session """ import koji from iniparse.compat import ConfigParser config = ConfigParser() if exists(join(expanduser('~'), '.koji', 'config')): config.readfp(open(join(expanduser('~'), '.koji', 'config'))) else: config.readfp(open('/etc/koji.conf')) cert = expanduser(config.get('koji', 'cert')) ca = expanduser(config.get('koji', 'ca')) serverca = expanduser(config.get('koji', 'serverca')) session = koji.ClientSession(config.get('koji', 'server')) if login: session.ssl_login(cert=cert, ca=ca, serverca=serverca) return session
def get_koji_session(self, login=True): """ Return an authenticated koji session """ import koji from iniparse.compat import ConfigParser config = ConfigParser() if exists(join(expanduser('~'), '.koji', 'config')): config.readfp(open(join(expanduser('~'), '.koji', 'config'))) else: config.readfp(open('/etc/koji.conf')) cert = expanduser(config.get('koji', 'cert')) ca = expanduser(config.get('koji', 'ca')) serverca = expanduser(config.get('koji', 'serverca')) session = koji.ClientSession(config.get('koji', 'server')) if login: session.ssl_login(cert=cert, ca=ca, serverca=serverca) return session
def parse_file(self, input_file): """ Parse an update template file. :arg input_file: The filename of the update template. Returns an array of dictionaries of parsed update values which can be directly passed to the ``save`` method. """ from iniparse.compat import ConfigParser self.log.info('Reading from %s ' % input_file) input_file = os.path.expanduser(input_file) if os.path.exists(input_file): defaults = { 'type': 'bugfix', 'request': 'testing', 'notes': '', 'bugs': '', 'close_bugs': 'True', 'autokarma': 'True', 'stable_karma': 3, 'unstable_karma': -3, 'suggest_reboot': 'False', } config = ConfigParser(defaults) template_file = open(input_file) config.readfp(template_file) template_file.close() updates = [] for section in config.sections(): update = {} update['builds'] = section update['type_'] = config.get(section, 'type') update['request'] = config.get(section, 'request') update['bugs'] = config.get(section, 'bugs') update['close_bugs'] = config.getboolean(section, 'close_bugs') update['notes'] = config.get(section, 'notes') update['autokarma'] = config.getboolean(section, 'autokarma') update['stable_karma'] = config.getint(section, 'stable_karma') update['unstable_karma'] = config.getint( section, 'unstable_karma') update['suggest_reboot'] = config.getboolean( section, 'suggest_reboot') updates.append(update) return updates
def parse_file(self, input_file): """ Parse an update template file. :arg input_file: The filename of the update template. Returns an array of dictionaries of parsed update values which can be directly passed to the ``save`` method. """ from iniparse.compat import ConfigParser self.log.info(_('Reading from %s ') % input_file) input_file = expanduser(input_file) if exists(input_file): defaults = { 'type': 'bugfix', 'request': 'testing', 'notes': '', 'bugs': '', 'close_bugs': 'True', 'autokarma': 'True', 'stable_karma': 3, 'unstable_karma': -3, 'suggest_reboot': 'False', } config = ConfigParser(defaults) template_file = open(input_file) config.readfp(template_file) template_file.close() updates = [] for section in config.sections(): update = {} update['builds'] = section update['type_'] = config.get(section, 'type') update['request'] = config.get(section, 'request') update['bugs'] = config.get(section, 'bugs') update['close_bugs'] = config.getboolean(section, 'close_bugs') update['notes'] = config.get(section, 'notes') update['autokarma'] = config.getboolean(section, 'autokarma') update['stable_karma'] = config.getint(section, 'stable_karma') update['unstable_karma'] = config.getint(section, 'unstable_karma') update['suggest_reboot'] = config.getboolean(section, 'suggest_reboot') updates.append(update) return updates
def get_koji_session(self): """ Return an authenticated koji session """ config = ConfigParser() if os.path.exists(os.path.join(os.path.expanduser('~'), '.koji', 'config')): config.readfp(open(os.path.join(os.path.expanduser('~'), '.koji', 'config'))) else: config.readfp(open('/etc/koji.conf')) session = koji.ClientSession(config.get('koji', 'server')) return session