当前位置: 首页>>代码示例>>Python>>正文


Python KSOptionParser.add_option方法代码示例

本文整理汇总了Python中pykickstart.options.KSOptionParser.add_option方法的典型用法代码示例。如果您正苦于以下问题:Python KSOptionParser.add_option方法的具体用法?Python KSOptionParser.add_option怎么用?Python KSOptionParser.add_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pykickstart.options.KSOptionParser的用法示例。


在下文中一共展示了KSOptionParser.add_option方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_header

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
    def handle_header(self, lineno, args):
        """
        The handle_header method is called to parse additional arguments in the
        %addon section line.

        args is a list of all the arguments following the addon ID. For
        example, for the line:
        
            %addon org_fedora_hello_world --reverse --arg2="example"

        handle_header will be called with args=['--reverse', '--arg2="example"']

        :param lineno: the current line number in the kickstart file
        :type lineno: int
        :param args: the list of arguments from the %addon line
        :type args: list
        """

        op = KSOptionParser()
        op.add_option("--reverse", action="store_true", default=False,
                dest="reverse", help="Reverse the display of the addon text")
        (opts, extra) = op.parse_args(args=args, lineno=lineno)
        
        # Reject any additional arguments. Since AddonData.handle_header
        # rejects any arguments, we can use it to create an error message
        # and raise an exception.
        if extra:
            AddonData.handle_header(self, lineno, args)

        # Store the result of the option parsing
        self.reverse = opts.reverse
开发者ID:dashea,项目名称:hello-world-anaconda-addon,代码行数:33,代码来源:hello_world.py

示例2: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
    def _getParser(self):
        op = KSOptionParser()
        # people would struggle remembering the exact word
        op.add_option("--agreed", "--agree", "--accepted", "--accept",
                      dest="agreed", action="store_true", default=False)

        return op
开发者ID:autotune,项目名称:pykickstart,代码行数:9,代码来源:eula.py

示例3: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
 def _getParser(self):
     op = KSOptionParser()
     op.add_option("--name", dest="name", action="store", type="string",
                   required=1)
     op.add_option("--dev", dest="devices", action="append", type="string",
                   required=1)
     return op
开发者ID:kenelite,项目名称:pykickstart,代码行数:9,代码来源:dmraid.py

示例4: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
    def _getParser(self):
        op = KSOptionParser()
        op.add_option("--biospart", dest="biospart")
        op.add_option("--partition", dest="partition")
        op.add_option("--dir", dest="dir", required=1)

        return op
开发者ID:autotune,项目名称:pykickstart,代码行数:9,代码来源:harddrive.py

示例5: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
    def _getParser(self):
        def drive_cb (option, opt_str, value, parser):
            for d in value.split(','):
                parser.values.ensure_value(option.dest, []).append(d)

        op = KSOptionParser()
        op.add_option("--drives", dest="ignoredisk", action="callback",
                      callback=drive_cb, nargs=1, type="string", required=1)
        return op
开发者ID:tradej,项目名称:pykickstart-old,代码行数:11,代码来源:ignoredisk.py

示例6: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
    def _getParser(self):
        def services_cb (option, opt_str, value, parser):
            for d in value.split(','):
                parser.values.ensure_value(option.dest, []).append(d.strip())

        op = KSOptionParser()
        op.add_option("--disabled", dest="disabled", action="callback",
                      callback=services_cb, nargs=1, type="string")
        op.add_option("--enabled", dest="enabled", action="callback",
                      callback=services_cb, nargs=1, type="string")
        return op
开发者ID:tradej,项目名称:pykickstart-old,代码行数:13,代码来源:services.py

示例7: handle_header

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
    def handle_header(self, lineno, args):

        op = KSOptionParser()
        op.add_option("--enable", "-e", action="store_true", default=False,
                      dest="state", help="Enable Cloud Support")
        op.add_option("--disable", "-d", action="store_false",
                      dest="state", help="(Default) Disable Cloud Support")
        op.add_option("--allinone", "-a", action="store_true", default=False,
                      dest="mode", help="Specify the mode of Packstack Installation")
        op.add_option("--answer-file", "-f", action="store", type="string",
                      dest="file", help="Specify URL of answers file")
        (options, extra) = op.parse_args(args=args, lineno=lineno)

        # Error Handling
        if str(options.state) == "True":
            self.state = str(options.state)
            if options.file and options.mode:
                msg = "options --allinone and --answer-file are mutually exclusive"
                raise KickstartParseError(msg)
            elif options.file:
                try:
                    response = urllib2.urlopen(options.file)
                    for line in response:
                        self.lines += line
                except urllib2.HTTPError, e:
                    msg = "Kickstart Error:: HTTPError: " + str(e.code)
                    raise KickstartParseError, formatErrorMsg(lineno, msg=msg)
                except urllib2.URLError, e:
                    msg = "Kickstart Error: HTTPError: " + str(e.reason)
                    raise KickstartParseError, formatErrorMsg(lineno, msg=msg)
                except:
开发者ID:gbraad,项目名称:anaconda-packstack-addon,代码行数:33,代码来源:cloud_ks.py

示例8: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
 def _getParser(self):
     op = KSOptionParser()
     op.add_option("--url", required=1)
     op.add_option("--proxy")
     op.add_option("--noverifyssl", action="store_true", default=False)
     op.add_option("--checksum")
     return op
开发者ID:autotune,项目名称:pykickstart,代码行数:9,代码来源:liveimg.py

示例9: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
    def _getParser(self):
        try:
            op = KSOptionParser(lineno=self.lineno)
        except TypeError:
            # the latest version has not lineno argument
            op = KSOptionParser()
            self.__new_version = True

        op.add_option(
            "--defaultdesktop",
            dest="defaultdesktop",
            action="store",
            type="string",
            nargs=1)
        op.add_option(
            "--autologinuser",
            dest="autologinuser",
            action="store",
            type="string",
            nargs=1)
        op.add_option(
            "--defaultdm",
            dest="defaultdm",
            action="store",
            type="string",
            nargs=1)
        op.add_option(
            "--session",
            dest="session",
            action="store",
            type="string",
            nargs=1)
        return op
开发者ID:MeeGoIntegration,项目名称:imager,代码行数:35,代码来源:build_ks.py

示例10: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
 def _getParser(self):
     op = KSOptionParser()
     op.add_option("--username", dest="username", required=True)
     op.add_option("--iscrypted", dest="isCrypted", action="store_true",
                   default=False)
     op.add_option("--plaintext", dest="isCrypted", action="store_false")
     op.add_option("--lock", dest="lock", action="store_true", default=False)
     return op
开发者ID:autotune,项目名称:pykickstart,代码行数:10,代码来源:sshpw.py

示例11: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
 def _getParser(self):
     op = KSOptionParser()
     op.add_option("--osname", dest="osname", required=1)
     op.add_option("--remote", dest="remote")
     op.add_option("--url", dest="url", required=1)
     op.add_option("--ref", dest="ref", required=1)
     op.add_option("--nogpg", action="store_true")
     return op
开发者ID:autotune,项目名称:pykickstart,代码行数:10,代码来源:ostreesetup.py

示例12: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
 def _getParser(self):
     op = KSOptionParser()
     op.add_option("--devnum", dest="devnum", required=1)
     op.add_option("--fcplun", dest="fcplun", required=1)
     op.add_option("--scsiid", dest="scsiid", required=1)
     op.add_option("--scsilun", dest="scsilun", required=1)
     op.add_option("--wwpn", dest="wwpn", required=1)
     return op
开发者ID:autotune,项目名称:pykickstart,代码行数:10,代码来源:zfcp.py

示例13: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
    def _getParser(self):
        def drive_cb (option, opt_str, value, parser):
            for d in value.split(','):
                parser.values.ensure_value(option.dest, []).append(d)

        op = KSOptionParser()
        op.add_option("--all", dest="type", action="store_const",
                      const=CLEARPART_TYPE_ALL)
        op.add_option("--drives", dest="drives", action="callback",
                      callback=drive_cb, nargs=1, type="string")
        op.add_option("--initlabel", dest="initAll", action="store_true",
                      default=False)
        op.add_option("--linux", dest="type", action="store_const",
                      const=CLEARPART_TYPE_LINUX)
        op.add_option("--none", dest="type", action="store_const",
                      const=CLEARPART_TYPE_NONE)
        return op
开发者ID:autotune,项目名称:pykickstart,代码行数:19,代码来源:clearpart.py

示例14: _getParser

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
 def _getParser(self):
     op = KSOptionParser()
     op.add_option("--target", dest="target", action="store", type="string")
     op.add_option("--ipaddr", dest="ipaddr", action="store", type="string",
                   required=1)
     op.add_option("--port", dest="port", action="store", type="string")
     op.add_option("--user", dest="user", action="store", type="string")
     op.add_option("--password", dest="password", action="store",
                   type="string")
     return op
开发者ID:autotune,项目名称:pykickstart,代码行数:12,代码来源:iscsi.py

示例15: handle_header

# 需要导入模块: from pykickstart.options import KSOptionParser [as 别名]
# 或者: from pykickstart.options.KSOptionParser import add_option [as 别名]
    def handle_header(self, lineno, args):
        """ Handle the kickstart addon header

        :param lineno: Line number
        :param args: arguments from %addon line
        """
        # This gets called after __init__, very early in the installation.
        op = KSOptionParser()
        op.add_option("--vgname",
                      help="Name of the VG that contains a thinpool named docker-pool")
        op.add_option("--fstype",
                      help="Type of filesystem for docker to use with the docker-pool")
        op.add_option("--overlay", action="store_true",
                      help="Use the overlay driver")
        op.add_option("--btrfs", action="store_true",
                      help="Use the BTRFS driver")
        op.add_option("--save-args", action="store_true", default=False,
                      help="Save all extra args to the OPTIONS variable in /etc/sysconfig/docker")
        (opts, extra) = op.parse_args(args=args, lineno=lineno)

        if sum(1 for v in [opts.overlay, opts.btrfs, opts.vgname] if bool(v)) != 1:
            raise KickstartParseError(formatErrorMsg(lineno,
                                                     msg=_("%%addon com_redhat_docker must choose one of --overlay, --btrfs, or --vgname")))

        self.enabled = True
        self.extra_args = extra
        self.save_args = opts.save_args

        if opts.overlay:
            self.storage = OverlayStorage(self)
        elif opts.btrfs:
            self.storage = BTRFSStorage(self)
        elif opts.vgname:
            fmt = blivet.formats.get_format(opts.fstype)
            if not fmt or fmt.type is None:
                raise KickstartParseError(formatErrorMsg(lineno,
                                                         msg=_("%%addon com_redhat_docker fstype of %s is invalid.")) % opts.fstype)

            self.vgname = opts.vgname
            self.fstype = opts.fstype
            self.storage = LVMStorage(self)
开发者ID:rhinstaller,项目名称:docker-anaconda-addon,代码行数:43,代码来源:docker.py


注:本文中的pykickstart.options.KSOptionParser.add_option方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。