本文整理汇总了Python中pykickstart.version.makeVersion函数的典型用法代码示例。如果您正苦于以下问题:Python makeVersion函数的具体用法?Python makeVersion怎么用?Python makeVersion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makeVersion函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
opts = parse_args()
if not opts.kscfg:
print(_("Need to specify a config to flatten"), file=sys.stderr)
sys.exit(1)
ksversion = makeVersion(opts.version)
ksparser = pykickstart.parser.KickstartParser(ksversion)
try:
ksparser.readKickstart(opts.kscfg)
except IOError as msg:
print(_("Failed to read kickstart file '%(filename)s' : %(error_msg)s") % {"filename": opts.kscfg, "error_msg": msg}, file=sys.stderr)
sys.exit(1)
except pykickstart.errors.KickstartError as e:
print(_("Failed to parse kickstart file '%(filename)s' : %(error_msg)s") % {"filename": opts.kscfg, "error_msg": e}, file=sys.stderr)
sys.exit(1)
if opts.output:
try:
f = open(opts.output, 'w')
except IOError as msg:
print(_("Failed to open output file '%(filename)s' : %(error_msg)s") % {"filename": opts.output, "error_msg": msg}, file=sys.stderr)
sys.exit(1)
else:
f = sys.stdout
f.write("%s" % ksparser.handler)
f.close()
开发者ID:cathywife,项目名称:pykickstart,代码行数:28,代码来源:ksflatten.py
示例2: read_kickstart
def read_kickstart(path):
"""Parse a kickstart file and return a KickstartParser instance.
This is a simple utility function which takes a path to a kickstart file,
parses it and returns a pykickstart KickstartParser instance which can
be then passed to an ImageCreator constructor.
If an error occurs, a CreatorError exception is thrown.
"""
version = ksversion.makeVersion()
ks = ksparser.KickstartParser(version)
try:
if "://" not in path:
path = "file://%s" % (urllib.request.pathname2url(os.path.abspath(path)))
ksdata = urllib.request.urlopen(path).read().decode("utf-8")
ks.readKickstartFromString(ksdata, reset=False)
# Fallback to e.args[0] is a workaround for bugs in urlgragger and pykickstart.
except IOError as e:
raise errors.KickstartError("Failed to read kickstart file "
"'%s' : %s" % (path, e.strerror or
e.args[0]))
except kserrors.KickstartError as e:
raise errors.KickstartError("Failed to parse kickstart file "
"'%s' : %s" % (path, e))
return ks
开发者ID:FGrose,项目名称:livecd-tools,代码行数:26,代码来源:kickstart.py
示例3: main
def main(argv=None):
opts = parse_args(argv)
if not opts.kscfg:
return (1, _("Need to specify a config to flatten"))
try:
ksversion = makeVersion(opts.version)
except KickstartVersionError:
print(_("The version %s is not supported by pykickstart") % opts.version)
sys.exit(1)
ksparser = pykickstart.parser.KickstartParser(ksversion)
try:
ksparser.readKickstart(opts.kscfg)
except IOError as msg:
return (1, _("Failed to read kickstart file '%(filename)s' : %(error_msg)s") % {"filename": opts.kscfg, "error_msg": msg})
except pykickstart.errors.KickstartError as e:
return (1, _("Failed to parse kickstart file '%(filename)s' : %(error_msg)s") % {"filename": opts.kscfg, "error_msg": e})
if opts.output:
try:
f = open(opts.output, 'w')
except IOError as msg:
return (1, _("Failed to open output file '%(filename)s' : %(error_msg)s") % {"filename": opts.output, "error_msg": msg})
else:
f = sys.stdout
f.write("%s" % ksparser.handler)
if opts.output:
f.close()
return (0, '')
开发者ID:phracek,项目名称:pykickstart,代码行数:33,代码来源:ksflatten.py
示例4: kickstart
def kickstart(ks, path=settings.KS_DIR):
"""
return parsed pykickstart object
"""
ks = "%s%s" % (path, ks)
ksparser = KickstartParser(makeVersion())
ksparser.readKickstart(ks)
return ksparser
开发者ID:firesofmay,项目名称:Dorrie,代码行数:8,代码来源:parse.py
示例5: kickstart
def kickstart(ks, uploaded, path=settings.KS_DIR):
"""
return parsed pykickstart object
"""
if not uploaded:
ks = "%s%s" % (path, ks)
ksparser = DecoratedKickstartParser(makeVersion())
ksparser.readKickstart(ks)
return ksparser
开发者ID:eartsar,项目名称:Remixerator,代码行数:10,代码来源:parse.py
示例6: kickstart
def kickstart(ks, path=settings.KS_DIR):
"""
return parsed pykickstart object
"""
ks = "%s%s" % (path, ks)
ksparser = KickstartParser(makeVersion())
if isinstance(ks, unicode):
ks = ks.encode('utf-8')
ksparser.readKickstart(ks)
return ksparser
开发者ID:aregee,项目名称:Dorrie,代码行数:10,代码来源:parse.py
示例7: process_kickstart
def process_kickstart(ksfile):
# pykickstart refs
# https://jlaska.fedorapeople.org/pykickstart-doc/pykickstart.commands.html
ksparser = KickstartParser(makeVersion())
try:
ksparser.readKickstart(ksfile)
except KickstartError as e:
sys.stderr.write(str(e))
sys.exit(1)
user_data = '#!/bin/bash'
# repo
for repo in ksparser.handler.repo.repoList:
if repo.mirrorlist:
repo_url = 'metalink=%s' % repo.mirrorlist
else:
repo_url = 'baseurl=%s' % repo.baseurl
user_data += """
cat <<"EOF" >/etc/yum.repos.d/%s.repo
[%s]
name=%s
%s
enabled=1
gpgcheck=0
EOF
""" % (repo.name,
repo.name,
repo.name,
repo_url)
# rootpw
if ksparser.handler.rootpw.isCrypted:
user_data += 'echo "root:%s" | chpasswd -e\n' % ksparser.handler.rootpw.password
else:
user_data += 'echo "root:%s" | chpasswd\n' % ksparser.handler.rootpw.password
# selinux
if ksparser.handler.selinux.selinux is 0:
selinux_status = 'disabled'
elif ksparser.handler.selinux.selinux is 2:
selinux_status = 'enforcing'
else:
selinux_status = 'enforcing'
user_data += "sed -i 's/SELINUX=.*/SELINUX=%s/' /etc/selinux/config\n" % selinux_status
# %packages
packages = []
for group in ksparser.handler.packages.groupList:
packages.append("@%s" % group.name)
for package in ksparser.handler.packages.packageList:
packages.append(package)
if packages:
user_data += "yum -y install %s\n" % ' '.join(packages)
# skip %prep
# %post
user_data += ksparser.handler.scripts[1].script
# remove cloud-init package and reboot
user_data += 'yum -y remove cloud-init\nreboot'
print user_data
开发者ID:beaker-project,项目名称:beaker-core-tasks,代码行数:55,代码来源:get_user_data.py
示例8: __init__
def __init__(self, main_window, kickstart=False):
if kickstart:
self.ksparser = pykickstart.parser.KickstartParser(makeVersion())
self.storage = Blivet(ksdata=self.ksparser.handler)
else:
self.storage = Blivet()
self.storage.reset()
self.main_window = main_window
开发者ID:CSRedRat,项目名称:blivet-gui,代码行数:11,代码来源:utils.py
示例9: __init__
def __init__(self, ks_path, blacklist=None):
self.ks_path = ks_path
if blacklist is None:
self.blacklist = []
else:
self.blacklist = blacklist
# create a kickstart parser from the latest version
self.ksparser = KickstartParser(makeVersion())
self.yb = yum.YumBase()
self._repo_problems = False
开发者ID:QuarkSecurity,项目名称:CLIP,代码行数:12,代码来源:kickstart-parser.py
示例10: kickstart
def kickstart(ks, path=settings.KS_DIR):
"""
return parsed pykickstart object
"""
ks = "%s%s" % (path, ks)
ksparser = DecoratedKickstartParser(makeVersion())
ksparser.readKickstart(ks)
# add the RIT stuff
ritPostContents = get_rit_post()
ksparser.addScript(ritPostContents, constants.KS_SCRIPT_POST)
return ksparser
开发者ID:gregjurman,项目名称:RITRemixerator,代码行数:12,代码来源:parse.py
示例11: split
def split(self, path):
"""Split the kickstart given by path into elements."""
self._elements = None
self._kickstart_path = path
handler = makeVersion()
ksparser = SplitKickstartParser(handler, valid_sections=VALID_SECTIONS_ANACONDA)
try:
result = ksparser.split(path)
except KickstartParseError as e:
raise SplitKickstartSectionParsingError(e)
except KickstartError as e:
raise SplitKickstartMissingIncludeError(e)
self._elements = result
开发者ID:rvykydal,项目名称:anaconda,代码行数:13,代码来源:kickstart_manager.py
示例12: __init__
def __init__(self, kickstart=False):
if kickstart:
self.ksparser = pykickstart.parser.KickstartParser(makeVersion())
self.storage = blivet.Blivet(ksdata=self.ksparser.handler)
else:
self.storage = blivet.Blivet()
blivet.formats.fs.NTFS._formattable = True
self.storage.reset()
self.storage.devicetree.populate()
self.storage.devicetree.getActiveMounts()
self.update_min_sizes_info()
开发者ID:vojtechtrefny,项目名称:blivet-gui,代码行数:14,代码来源:utils.py
示例13: runTest
def runTest(self):
for version, command_map in control.commandMap.items():
handler = makeVersion(version)
parser = KickstartParser(handler)
for command_name, command_class in command_map.items():
if not issubclass(command_class, DeprecatedCommand):
continue
with warnings.catch_warnings(record=True):
# The deprecated commands should be ignored with
# a warning when they are parsed. Make sure that
# they will not cause any errors.
parser.readKickstartFromString(command_name)
开发者ID:atodorov,项目名称:pykickstart,代码行数:15,代码来源:misc.py
示例14: load_or_default
def load_or_default(system_ks_path):
"""load system ks or default ks"""
ksparser = KickstartParser(makeVersion())
try:
ksparser.readKickstart(system_ks_path)
except (KickstartError, IOError):
log_message("Can't read system kickstart at {0}".format(system_ks_path))
try:
ksparser.readKickstart(settings.KS_TEMPLATE)
except AttributeError:
log_message("There is no KS_TEMPLATE_POSTSCRIPT specified in settings.py")
except IOError:
log_message("Can't read kickstart template {0}".format(settings.KS_TEMPLATE))
return None
return ksparser
开发者ID:jmazanek,项目名称:preupgrade-assistant,代码行数:15,代码来源:kickstart.py
示例15: test_biosboot_bootloader_in_kickstart
def test_biosboot_bootloader_in_kickstart(self, mock_mountpoints, mock_devices, dbus):
"""Test that a biosboot bootloader shows up in the ks data."""
# set up biosboot partition
biosboot_device_obj = PartitionDevice("biosboot_partition_device")
biosboot_device_obj.size = Size('1MiB')
biosboot_device_obj.format = formats.get_format("biosboot")
# mountpoints must exist for updateKSData to run
mock_devices.return_value = [biosboot_device_obj]
mock_mountpoints.values.return_value = []
# initialize ksdata
biosboot_blivet_obj = InstallerStorage(makeVersion())
biosboot_blivet_obj.update_ksdata()
self.assertIn("part biosboot", str(biosboot_blivet_obj.ksdata))
开发者ID:zhangsju,项目名称:anaconda,代码行数:16,代码来源:ksdata_test.py
示例16: setUp
def setUp(self):
self.setupModules(["_isys", "logging"])
import pyanaconda
pyanaconda.anaconda_log = mock.Mock()
from pykickstart.version import makeVersion
from pyanaconda.flags import flags
# set some things specially since we're just testing
flags.testing = True
# set up ksdata
self.ksdata = makeVersion()
from pyanaconda.packaging import Payload
self.payload = Payload(self.ksdata)
开发者ID:Sabayon,项目名称:anaconda,代码行数:17,代码来源:packaging_test.py
示例17: read_kickstart
def read_kickstart(path):
"""Parse a kickstart file and return a KickstartParser instance.
This is a simple utility function which takes a path to a kickstart file,
parses it and returns a pykickstart KickstartParser instance which can
be then passed to an ImageCreator constructor.
If an error occurs, a CreatorError exception is thrown.
"""
version = ksversion.makeVersion()
ks = ksparser.KickstartParser(version)
try:
ksfile = urlgrabber.urlgrab(path)
ks.readKickstart(ksfile)
# Fallback to e.args[0] is a workaround for bugs in urlgragger and pykickstart.
except IOError, e:
raise errors.KickstartError("Failed to read kickstart file " "'%s' : %s" % (path, e.strerror or e.args[0]))
开发者ID:ccoss,项目名称:image-creator,代码行数:18,代码来源:kickstart.py
示例18: add_repo
def add_repo(self, ksfile, siderepo):
""" Add a repository to an existing KS file """
# read
ksparser = KickstartParser(makeVersion())
ksparser.readKickstart(ksfile)
#obtain the handler dump
kshandlers = ksparser.handler
# add a repository
kshandlers.repo.repoList.extend(['repo --name="siderepo" --baseurl={0:s}\n'.format(siderepo)])
# Write a new ks file
outfile = open(ksfile, 'w')
outfile.write(kshandlers.__str__())
outfile.close()
return
开发者ID:tflink,项目名称:gsoc2012_fbs,代码行数:19,代码来源:worker.py
示例19: test_prepboot_bootloader_in_kickstart
def test_prepboot_bootloader_in_kickstart(self, mock_mountpoints, dbus):
"""Test that a prepboot bootloader shows up in the ks data."""
# disable other partitioning modules
dbus.return_value.Enabled = False
# set up prepboot partition
bootloader_device_obj = PartitionDevice("test_partition_device")
bootloader_device_obj.size = Size('5 MiB')
bootloader_device_obj.format = formats.get_format("prepboot")
# mountpoints must exist for update_ksdata to run
mock_mountpoints.values.return_value = []
# set up the storage
prepboot_blivet_obj = InstallerStorage()
prepboot_blivet_obj.bootloader.stage1_device = bootloader_device_obj
# initialize ksdata
ksdata = makeVersion()
update_storage_ksdata(prepboot_blivet_obj, ksdata)
self.assertIn("part prepboot", str(ksdata))
开发者ID:rvykydal,项目名称:anaconda,代码行数:22,代码来源:ksdata_test.py
示例20: main
def main(argv):
op = argparse.ArgumentParser(usage="%(prog)s [options] ksfile", add_help=False)
op.add_argument("ksfile", nargs="?",
help=_("filename or URL to read from"))
op.add_argument("-e", "--firsterror", dest="firsterror", action="store_true",
default=False, help=_("halt after the first error or warning"))
op.add_argument("-i", "--followincludes", dest="followincludes",
action="store_true", default=False,
help=_("parse include files when %%include is seen"))
op.add_argument("-l", "--listversions", dest="listversions", action="store_true",
default=False,
help=_("list the available versions of kickstart syntax"))
op.add_argument("-v", "--version", dest="version", default=DEVEL,
help=_("version of kickstart syntax to validate against"))
op.add_argument("-h", "--help", dest="help", action="store_true", default=False,
help=_("show this help message and exit"))
opts = op.parse_args(argv)
# parse --help manually b/c we don't want to sys.exit before the
# tests have finished
if opts.help:
return (0, op.format_help().split("\n"))
if opts.listversions:
versions = []
for key in sorted(versionMap.keys()):
versions.append(key)
return (0, versions)
if not opts.ksfile:
return (1, op.format_usage().split("\n"))
destdir = tempfile.mkdtemp("", "ksvalidator-tmp-", "/tmp")
try:
f = load_to_file(opts.ksfile, "%s/ks.cfg" % destdir)
except KickstartError as e:
return (cleanup(destdir),
[_("Error reading %(filename)s:\n%(version)s") % {"filename": opts.ksfile, "version": e}])
try:
handler = makeVersion(opts.version)
except KickstartVersionError:
return (cleanup(destdir),
[_("The version %s is not supported by pykickstart") % opts.version])
ksparser = KickstartParser(handler, followIncludes=opts.followincludes,
errorsAreFatal=opts.firsterror)
# turn DeprecationWarnings into errors
warnings.filterwarnings("error")
processedFile = None
try:
processedFile = preprocessKickstart(f)
ksparser.readKickstart(processedFile)
return (cleanup(destdir, processedFile, exitval=ksparser.errorsCount), [])
except DeprecationWarning as err:
return (cleanup(destdir, processedFile),
[_("File uses a deprecated option or command.\n%s") % err])
except KickstartParseError as err:
return (cleanup(destdir, processedFile), [str(err)])
except KickstartError:
return (cleanup(destdir, processedFile),
[_("General kickstart error in input file")])
except Exception as e:
return (cleanup(destdir, processedFile),
[_("General error in input file: %s") % e])
开发者ID:dustymabe,项目名称:pykickstart,代码行数:69,代码来源:ksvalidator.py
注:本文中的pykickstart.version.makeVersion函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论