pc.disabled_plugins = self.optparser._splitArg(opts.disableplugins)
pc.enabled_plugins = self.optparser._splitArg(opts.enableplugins)
pc.releasever = opts.releasever
- self.conf
# now set all the non-first-start opts from main from our setopts
if self.main_setopts:
def usage(self):
''' Print out command line usage '''
- sys.stdout.write(self.optparser.format_help())
+ print(self.optparser.format_help(), file=sys.stderr)
def shellUsage(self):
''' Print out the shell usage '''
- sys.stdout.write(self.optparser.get_usage())
+ print(self.optparser.get_usage(), file=sys.stderr)
def _installable(self, pkg, ematch=False):
set_fg = self._tigetstr('setf')
if set_fg:
for (color, val) in list(self.__colors.items()):
- self.FG_COLOR[color] = curses.tparm(set_fg, val) or ''
+ self.FG_COLOR[color] = curses.tparm(set_fg.encode(), val) or b''
set_fg_ansi = self._tigetstr('setaf')
if set_fg_ansi:
for (color, val) in list(self.__ansi_colors.items()):
- self.FG_COLOR[color] = curses.tparm(set_fg_ansi, val) or ''
+ self.FG_COLOR[color] = curses.tparm(set_fg_ansi.encode(), val) or b''
set_bg = self._tigetstr('setb')
if set_bg:
for (color, val) in list(self.__colors.items()):
- self.BG_COLOR[color] = curses.tparm(set_bg, val) or ''
+ self.BG_COLOR[color] = curses.tparm(set_bg.encode(), val) or b''
set_bg_ansi = self._tigetstr('setab')
if set_bg_ansi:
for (color, val) in list(self.__ansi_colors.items()):
- self.BG_COLOR[color] = curses.tparm(set_bg_ansi, val) or ''
+ self.BG_COLOR[color] = curses.tparm(set_bg_ansi.encode(), val) or b''
def __init__(self, term_stream=None, color='auto'):
self.reinit(term_stream, color)
# String capabilities can include "delays" of the form "$<2>".
# For any modern terminal, we should be able to just ignore
# these, so strip them out.
- cap = self._ctigetstr(cap_name) or ''
- return re.sub(r'\$<\d+>[/*]?', '', cap)
+ cap = self._ctigetstr(cap_name) or b''
+ return re.sub(r'\$<\d+>[/*]?', '', cap.decode())
def sub(self, haystack, beg, end, needles, escape=None, ignore_case=False):
if not self.__enabled:
if not escape:
escape = re.escape
- render = lambda match: beg + match.group() + end
+ def render(match): return beg + match.group() + end
for needle in needles:
pat = escape(needle)
if ignore_case:
import sys
import time
-import exceptions
import yum
from cli import *
old_excepthook = sys.excepthook
def new_hook(type, value, traceback):
- if type != exceptions.KeyboardInterrupt:
+ if type != KeyboardInterrupt:
old_excepthook(type, value, traceback)
else:
pass
if os.path.exists(config_file):
confpp_obj = ConfigPreProcessor(config_file)
+ processedLines = []
+ while True:
+ line = confpp_obj.readline()
+ if not line:
+ break
+ processedLines.append(line.decode())
+ congf = open('tmp_confilgfile', 'a+')
+ congf.writelines(processedLines)
try:
- confparser.readfp(confpp_obj)
+ confparser.read_file(congf)
except ParsingError as e:
print("Error reading config file: %s" % e, file=sys.stderr)
sys.exit(1)
+ finally:
+ congf.close()
+ os.remove('tmp_confilgfile')
syslog.openlog("yum-updatesd", 0, syslog.LOG_DAEMON)
confpp_obj = ConfigPreProcessor(repofn, vars=self.conf.yumvar)
parser = ConfigParser()
+ processedLines = []
+ while True:
+ line = confpp_obj.readline()
+ if not line:
+ break
+ processedLines.append(line.decode())
+ congf = open('tmp_confilgfile', 'a+')
+ congf.writelines(processedLines)
try:
- parser.readfp(confpp_obj)
+ parser.read_file(congf)
except ParsingError as e:
msg = str(e)
raise Errors.ConfigError(msg)
+ finally:
+ congf.close()
+ os.remove('tmp_confilgfile')
# Check sections in the .repo file that was just slurped up
for section in parser.sections():
raise Errors.LockError(msg.errno, errmsg, int(contents))
return 0
else:
- os.write(fd, contents)
+ os.write(fd, contents.encode())
os.close(fd)
return 1
def __init__(self):
self._section = None
- for name in list(self.keys()):
+ for name in self.iterkeys():
option = self.optionobj(name)
option.setup(self, name)
def __str__(self):
out = []
out.append('[%s]' % self._section)
- for name, value in list(self.items()):
+ for name, value in self.iteritems():
out.append('%s: %r' % (name, value))
return '\n'.join(out)
opts = set(parser.options(section))
else:
opts = set()
- for name in list(self.keys()):
+ for name in self.iterkeys():
option = self.optionobj(name)
value = None
if name in opts:
The value returned is the parsed, validated option value.
'''
# Use dir() so that we see inherited options too
- for name in list(self.keys()):
+ for name in self.iterkeys():
yield (name, getattr(self, name))
def write(self, fileobj, section=None, always=()):
# Updated the ConfigParser with the changed values
cfgOptions = self.cfg.options(section)
- for name,value in list(self.items()):
+ for name,value in self.iteritems():
option = self.optionobj(name)
if always is None or name in always or option.default != value or name in cfgOptions :
self.cfg.set(section,name, option.tostring(value))
startupconf.config_file_path = configfile
parser = ConfigParser()
confpp_obj = ConfigPreProcessor(configfile)
+ processedLines = []
+ while True:
+ line = confpp_obj.readline()
+ if not line:
+ break
+ processedLines.append(line.decode())
+ congf = open('tmp_confilgfile', 'a+')
+ congf.writelines(processedLines)
try:
- parser.readfp(confpp_obj)
+ parser.read_file(congf)
except ParsingError as e:
raise Errors.ConfigError("Parsing file failed: %s" % e)
+ finally:
+ congf.close()
+ os.remove('tmp_confilgfile')
startupconf.populate(parser, 'main')
# Check that plugin paths are all absolute
def readVersionGroupsConfig(configfile="/etc/yum/version-groups.conf"):
parser = ConfigParser()
confpp_obj = ConfigPreProcessor(configfile)
+ processedLines = []
+ while True:
+ line = confpp_obj.readline()
+ if not line:
+ break
+ processedLines.append(line.decode())
+ congf = open('tmp_confilgfile', 'a+')
+ congf.writelines(processedLines)
try:
- parser.readfp(confpp_obj)
+ parser.read_file(congf)
except ParsingError as e:
raise Errors.ConfigError("Parsing file failed: %s" % e)
+ finally:
+ congf.close()
+ os.remove('tmp_confilgfile')
ret = {}
for section in parser.sections():
ret[section] = VersionGroupConf()
fo = self._incstack[-1]
line = fo.readline()
if len(line) > 0:
- m = re.match( r'\s*include\s*=\s*(?P<url>.*)', line )
+ m = re.match( r'\s*include\s*=\s*(?P<url>.*)', line.decode() )
if m:
url = m.group('url')
if len(url) == 0:
fo = self._pushfile( url )
else:
# check if the current line starts a new section
- secmatch = re.match( r'\s*\[(?P<section>.*)\]', line )
+ secmatch = re.match( r'\s*\[(?P<section>.*)\]', line.decode() )
if secmatch:
self._section = secmatch.group('section')
# line didn't match include=, just return it as is
# if the section is prefixed by a space then it is breaks iniparser/configparser
# so fix it
- broken_sec_match = re.match(r'\s+\[(?P<section>.*)\]', line)
+ broken_sec_match = re.match(r'\s+\[(?P<section>.*)\]', line.decode())
if broken_sec_match:
line = line.lstrip()
# at this point we have a line from the topmost file on the stack
# or EOF if the stack is empty
if self._vars:
- return varReplace(line, self._vars)
+ return varReplace(line.decode(), self._vars).encode()
return line
return None
parser = ConfigParser()
confpp_obj = ConfigPreProcessor(conffilename)
+ processedLines = []
+ while True:
+ line = confpp_obj.readline()
+ if not line:
+ break
+ processedLines.append(line.decode())
+ congf = open('tmp_confilgfile', 'a+')
+ congf.writelines(processedLines)
try:
- parser.readfp(confpp_obj)
+ parser.read_file(congf)
except ParsingError as e:
raise Errors.ConfigError("Couldn't parse %s: %s" % (conffilename,
str(e)))
+ finally:
+ congf.close()
+ os.remove('tmp_confilgfile')
return parser
def setCmdLine(self, opts, commands):