1.change file() to open() to open a file.
2.fix Value 'filter(lambda r: r.name == name, self.repos)' is unsubscriptable
Change-Id: Ieec8e179a9b54a5acbd0edaedcb9ed1595ba5f1e
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
KS_SCRIPT_PREINSTALL, KS_SCRIPT_ONERROR, \
KS_MISSING_IGNORE, KS_MISSING_PROMPT, \
KS_BROKEN_IGNORE, KS_BROKEN_REPORT, KS_SCRIPT_RUN, KS_SCRIPT_UMOUNT
-from pykickstart.errors import KickstartParseError, KickstartDeprecationWarning
+from pykickstart.errors import KickstartError, KickstartParseError, KickstartDeprecationWarning
from pykickstart.options import KSOptionParser
from pykickstart.version import FC4, F7, F9, F18, F21, F22, F24, F32, F34, RHEL6, RHEL7, RHEL9, \
isRHEL
def write_ifcfg(self, network):
p = self.path("/etc/sysconfig/network-scripts/ifcfg-" + network.device)
- f = file(p, "w+")
+ f = open(p, "w+")
os.chmod(p, 0o644)
f.write("DEVICE=%s\n" % network.device)
return
p = self.path("/etc/sysconfig/network-scripts/keys-" + network.device)
- f = file(p, "w+")
+ f = open(p, "w+")
os.chmod(p, 0o600)
f.write("KEY=%s\n" % network.wepkey)
f.close()
def write_sysconfig(self, useipv6, hostname, gateway):
path = self.path("/etc/sysconfig/network")
- f = file(path, "w+")
+ f = open(path, "w+")
os.chmod(path, 0o644)
f.write("NETWORKING=yes\n")
localline += "localhost.localdomain localhost"
path = self.path("/etc/hosts")
- f = file(path, "w+")
+ f = open(path, "w+")
os.chmod(path, 0o644)
f.write("127.0.0.1\t\t%s\n" % localline)
f.write("::1\t\tlocalhost6.localdomain6 localhost6\n")
return
path = self.path("/etc/resolv.conf")
- f = file(path, "w+")
+ f = open(path, "w+")
os.chmod(path, 0o644)
for ns in (nameservers):
def _writeConf(self, confpath, installroot):
conf = Template(YUMCONF_TEMP).safe_substitute(installroot=installroot)
- f = file(confpath, "w+")
+ f = open(confpath, "w+")
f.write(conf)
f.close()
msger.info("\nChecking packages cached ...")
for po in dlpkgs:
local = po.localPkg()
- repo = filter(lambda r: r.id == po.repoid, self.repos.listEnabled())[0]
+ repo = list(filter(lambda r: r.id == po.repoid, self.repos.listEnabled()))[0]
if repo.nocache and os.path.exists(local):
os.unlink(local)
if not os.path.exists(local):
local = self.getLocalPkgPath(po)
name = str(po.repoInfo().name())
try:
- repo = filter(lambda r: r.name == name, self.repos)[0]
+ repo = list(filter(lambda r: r.name == name, self.repos))[0]
except IndexError:
repo = None
nocache = repo.nocache if repo else False
name = str(pobj.repoInfo().name())
try:
- repo = filter(lambda r: r.name == name, self.repos)[0]
+ repo = list(filter(lambda r: r.name == name, self.repos))[0]
except IndexError:
return None