示例#1
0
 def __init__(self, name, comp_conn):
     self.wizard = wiz.PromptWizard(
         name=name,
         description="Provide values for component connection attributes",
         steps=[
             wiz.WizardStep(
                 id=json_fields.CONNECTION_DESC_DESCRIPTION_FIELD,
                 name='Description',
                 help='Connection Description.',
                 default=comp_conn.description,
                 validators=not_required_validator),
             wiz.WizardStep(id=json_fields.CONNECTION_DESC_LABEL_FIELD,
                            name='Label',
                            help='Label to be displayed in MCenter UI',
                            default=comp_conn.label),
             wiz.WizardStep(
                 id=json_fields.CONNECTION_DESC_TYPE_FIELD,
                 name='Type',
                 help='Type',
                 default=comp_conn.type if comp_conn.type else "str"),
             wiz.WizardStep(
                 id=json_fields.CONNECTION_DESC_GROUP_FIELD,
                 name='Group',
                 help='Group',
                 default=comp_conn.group if comp_conn.group else "data"),
             wiz.WizardStep(
                 id=json_fields.CONNECTION_DESC_DEFAULT_COMPONENT_FIELD,
                 name='Default Component',
                 help='Default Component',
                 default=comp_conn.default_component)
         ])
示例#2
0
 def guest_wizard(self):
     """
     Wizard to collect guest configuration
     """
     self.wiz_guest = wiz.PromptWizard(
         name="Guest Configuration for PVP and PVVP Scenarios",
         description="Guest configurations",
         steps=(
             wiz.WizardStep(
                 id='image',
                 name='Enter the Path for the iamge',
                 help='Complete path where image resides',
                 default='/home/opnfv/vloop-vnf-ubuntu-14.04_20160823.qcow2',
             ),
             wiz.WizardStep(
                 id='mode',
                 name='Enter the forwarding mode to use',
                 help='one of io|mac|mac_retry|macswap|flowgen|rxonly|....',
                 default='io',
             ),
             wiz.WizardStep(
                 id='smp',
                 name='Number of SMP to use?',
                 help='While Spawning the guest, how many SMPs to use?',
                 default='2',
             ),
             wiz.WizardStep(
                 id='cores',
                 name="Guest Core binding. For 2 cores a & b: ['a', 'b']",
                 help='Enter the cores to use in the specified format',
                 default="['8', '9']",
             ),
         )
     )
示例#3
0
def run_command_extension_wizard(core):
    """Asks the user questions needed specifially when creating a command extension."""

    from pypsi import wizard
    from pypsi.completers import choice_completer

    available_commands = {
        command.name: command
        for command in core.extension_manager.get_commands()
    }

    command_step = wizard.WizardStep(
        'command',
        'command to extend',
        validators=[
            wizard.required_validator,
            lambda _, command: available_commands[command]
        ],
        completer=choice_completer(available_commands.keys()),
        help='Name the command you would like to extend.')

    return _run_pypsi_wizard(
        wizard.PromptWizard('Command Extension Creation',
                            dedent("""
            This wizard will guide you through the creation of a K2 addon.

            Please answer the following questions about your K2 command extension:
            """),
                            steps=[
                                command_step,
                            ]))
示例#4
0
 def __init__(self, component_info, arg):
     argument_type_header = "Choose argument type:\n" + options_to_str(
         argument_type_options) + "\nType"
     argument_tag_header = "Choose argument tag:\n" + options_to_str(
         argument_tag_options) + "\nTag"
     self.wizard = wiz.PromptWizard(
         name="Argument Configuration",
         description="Provide values for argument attributes",
         steps=[
             wiz.WizardStep(id=json_fields.COMPONENT_DESC_ARGUMENT_KEY,
                            name='Key',
                            help='Key',
                            default=arg.key,
                            validators=(wiz.required_validator,
                                        no_spaces_validator,
                                        self._key_existance_validator(
                                            component_info,
                                            current_key=arg.key))),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_ARGUMENT_TYPE,
                 name=argument_type_header,
                 help='Choose value from the list.',
                 default=arg.type if arg.type else "string",
                 validators=choice_validator(argument_type_options)),
             wiz.WizardStep(id=json_fields.COMPONENT_DESC_ARGUMENT_LABEL,
                            name='Label',
                            help='Label',
                            default=arg.label),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_ARGUMENT_DESCRIPTION,
                 name='Description',
                 help='Description',
                 default=arg.description),
             wiz.WizardStep(id=json_fields.COMPONENT_DESC_ARGUMENT_ENV_VAR,
                            name='Env Var',
                            help='Env Var',
                            default=arg.env_var,
                            validators=not_required_validator),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_ARGUMENT_OPTIONAL,
                 name='Optional',
                 help='Is parameter optional',
                 default=arg.optional if arg.optional else "False",
                 validators=(choice_validator(boolean_options))),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_ARGUMENT_TAG,
                 name=argument_tag_header,
                 help='Tag',
                 default=arg.tag,
                 validators=choice_validator(argument_tag_options)),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_ARGUMENT_DEFAULT_VAL,
                 name='Default Value',
                 help='Default Value',
                 default=arg.default_value,
                 validators=not_required_validator)
         ])
示例#5
0
 def main_wizard(self):
     """
     The Main Wizard
     """
     # First get the nics.
     self.get_nicpcis()
     self.wiz_main = wiz.PromptWizard(
         name="VSPERF Common Configuration",
         description="This configuration covers Basic inputs",
         steps=(
             # The list of input prompts to ask the user.
             wiz.WizardStep(
                 # ID where the value will be stored
                 id="vswitch",
                 # Display name
                 name="VSwitch to use? - OVS or VPP?",
                 # Help message
                 help=" Enter the vswitch to use - either OVS or VPP",
                 # List of validators to run on the input
                 default='OVS'
             ),
             wiz.WizardStep(
                 id='nics',
                 name="NICs to Whitelist: " + self.devices,
                 help="Enter the list (separated by comma) of PCI-IDs",
                 validators=(wiz.required_validator),
             ),
             wiz.WizardStep(
                 id='tgen',
                 name=("What trafficgen to use: [TestCenter" +
                       " IxNet, Moongen, Trex]?"),
                 help=("Enter the trafficgen to use -" +
                       " TestCenter, IxNet, Moongen, Trex"),
                 validators=(wiz.required_validator),
                 default="Trex"
             ),
             wiz.WizardStep(
                 id='guest',
                 name=("Is Scenario either PVP or PVVP?"),
                 help=("This is ti capture guest Configuration"),
                 validators=(wiz.required_validator),
                 default="YES"
             )
         )
     )
示例#6
0
 def dut_wizard(self):
     """
     Wizard to collect DUT information
     """
     self.wiz_dut = wiz.PromptWizard(
         name="VSPERF DUT Info Collection",
         description="This collects DUT info",
         steps=(
             # The list of input prompts to ask the user.
             wiz.WizardStep(
                 # ID where the value will be stored
                 id="dutip",
                 # Display name
                 name="Enter the IP address of the DUT [local]",
                 # Help message
                 help="IP address of the DUT host",
                 # List of validators to run on the input
                 validators=(wiz.required_validator)
             ),
             wiz.WizardStep(
                 # ID where the value will be stored
                 id="dutuname",
                 # Display name
                 name="Enter the username to connect to DUT",
                 # Help message
                 help="Username for DUT host",
                 # List of validators to run on the input
                 validators=(wiz.required_validator)
             ),
             wiz.WizardStep(
                 # ID where the value will be stored
                 id="dutpwd",
                 # Display name
                 name="Enter the Password to connect to DUT",
                 # Help message
                 help="Password for the DUT host",
                 # List of validators to run on the input
                 validators=(wiz.required_validator)
             ),
         )
     )
示例#7
0
 def __init__(self, name="yesno", header=""):
     self.wizard = wiz.PromptWizard(
         name=name,
         description=
         "Provide values for component connection attributes",
         steps=[
             wiz.WizardStep(id="answer",
                            name=header,
                            help="Answer Yes or No",
                            default="Yes",
                            validators=wiz.boolean_validator)
         ])
示例#8
0
 def ovs_wizard(self):
     """
     Wizard to collect OVS Information
     """
     self.wiz_ovs = wiz.PromptWizard(
         name="Vswitch Configuration",
         description="Specific configurations of the virtual-Switch",
         steps=(
             wiz.WizardStep(
                 id='type',
                 name='OVS Type? [Vanilla or DPDK]',
                 help='Enter either Vanilla or DPDK',
                 default='Vanilla',
             ),
             wiz.WizardStep(
                 id='mask',
                 name='Enter the CPU Mask for OVS to use',
                 help='Mask for OVS PMDs',
                 default='30',
             ),
         )
     )
示例#9
0
 def traffic_wizard(self):
     """
     Wizard to collectd Traffic Info.
     """
     self.wiz_traffic = wiz.PromptWizard(
         name="Traffic Configuration",
         description="This configuration covers Traffic specifc inputs",
         steps=(
             wiz.WizardStep(
                 id='pktsizes',
                 name='Enter the Packet Sizes - comma separated',
                 help="Allowed values: (64,128,256,512,1024,1280,1518)",
                 validators=(wiz.required_validator)
             ),
             wiz.WizardStep(
                 id='duration',
                 name='Enter the Duration (in secs) for the traffic',
                 help="Enter for how long each iteration should be",
                 default='60',
             ),
             # wiz.WizardStep(
             #    id='multistream',
             #    name='Multistream preferred?',
             #    help="Multistream preference - Yes or No",
             #    default='No',
             # validators=(wiz.required_validator)
             #),
             wiz.WizardStep(
                 id='count',
                 name='Number of flows?',
                 help="Enter the number of flows - 2 - 1,000,000",
                 default='2',
                 # validators=(wiz.required_validator)
             ),
         )
     )
示例#10
0
    def __init__(self, name, default_path):

        if name.lower().startswith("save"):
            step = wiz.WizardStep(id="path",
                                  name='File path',
                                  help='File path to save component file',
                                  default=default_path,
                                  validators=(wiz.required_validator,
                                              self._save_file_validator),
                                  completer=path_completer)
            description = "Provide filepath to save component"
        elif name.lower().startswith("load"):
            step = wiz.WizardStep(id="path",
                                  name='File path',
                                  help='File path to load component',
                                  default=default_path,
                                  validators=(wiz.required_validator,
                                              self._load_file_validator),
                                  completer=path_completer)
            description = "Provide component file to load"

        self.wizard = wiz.PromptWizard(name=name,
                                       description=description,
                                       steps=[step])
示例#11
0
 def vpp_wizard(self):
     """
     Wizard to collect VPP configuration
     """
     self.wiz_vpp = wiz.PromptWizard(
         name="Vswitch Configuration",
         description="Specific configurations of the virtual-Switch",
         steps=(
             wiz.WizardStep(
                 id='mode',
                 name='L2 Connection mode xconnect|bridge|l2patch to use?',
                 help='Select the l2 connection mode',
                 default='xconnect',
             ),
         )
     )
示例#12
0
 def ixnet_wizard(self):
     """
     Wizard to collect ixnet configuration
     """
     self.wiz_ixnet = wiz.PromptWizard(
         name="Ixia IxNet Traffic Generator Configuration",
         description="Specific configurations of Ixia-Ixnet TGen",
         steps=(
             wiz.WizardStep(
                 id='card',
                 name='Card Number?',
                 help='Chassis Card Number',
                 default='1',
             ),
             wiz.WizardStep(
                 id='port1',
                 name='Port-1 Number?',
                 help='Chassis Port-1 Number',
                 default='5',
             ),
             wiz.WizardStep(
                 id='port2',
                 name='Port-2 Number?',
                 help='Chassis Port-2 Number',
                 default='6',
             ),
             wiz.WizardStep(
                 id='libp1',
                 name='IXIA Library path?',
                 help='Library path of Ixia',
                 default='/opt/ixnet/ixos-api/8.01.0.2/lib/ixTcl1.0',
             ),
             wiz.WizardStep(
                 id='libp2',
                 name='IXNET Library Path',
                 help='Library Path for the IXNET',
                 default='/opt/ixnet/ixnetwork/8.01.1029.6/lib/IxTclNetwork',
             ),
             wiz.WizardStep(
                 id='host',
                 name='IP of the CHassis?',
                 help='Chassis IP',
                 default='10.10.50.6',
             ),
             wiz.WizardStep(
                 id='machine',
                 name='IP of the API Server?',
                 help='API Server IP ',
                 default='10.10.120.6',
             ),
             wiz.WizardStep(
                 id='port',
                 name='Port of the API Server?',
                 help='API Server Port',
                 default='9127',
             ),
             wiz.WizardStep(
                 id='user',
                 name='Username for the API server?',
                 help='Username to use to connect to API Server',
                 default='vsperf_sandbox',
             ),
             wiz.WizardStep(
                 id='tdir',
                 name='Path for Results Directory on API Server',
                 help='Results Path on API Server',
                 default='c:/ixia_results/vsperf_sandbox',
             ),
             wiz.WizardStep(
                 id='rdir',
                 name='Path for Results directory on DUT',
                 help='DUT Results Path',
                 default='/mnt/ixia_results/vsperf_sandbox',
             ),
         )
     )
示例#13
0
 def stc_wizard(self):
     """
     Wizard to collect STC configuration
     """
     self.wiz_stc = wiz.PromptWizard(
         name="Spirent STC Traffic Generator Configuration",
         description="Specific configurations of Spirent-STC TGen",
         steps=(
             wiz.WizardStep(
                 id='lab',
                 name='Lab Server IP?',
                 help='Enter the IP of Lab Server',
                 default='10.10.120.244',
             ),
             wiz.WizardStep(
                 id='lisc',
                 name='License Server IP?',
                 help='Enter the IP of the License Server',
                 default='10.10.120.246',
             ),
             wiz.WizardStep(
                 id='eaddr',
                 name='East Port Chassis Address?',
                 help='IP address of the East-Port',
                 default='10.10.120.245',
             ),
             wiz.WizardStep(
                 id='eslot',
                 name='East Port Slot Number',
                 help='Slot Number of the East Port',
                 default='1',
             ),
             wiz.WizardStep(
                 id='eport',
                 name='Port Number of the East-Port',
                 help='Port Number for the East Port',
                 default='1',
             ),
             wiz.WizardStep(
                 id='eint',
                 name='East port Interface Address',
                 help='IP to use for East Port?',
                 default='192.85.1.3',
             ),
             wiz.WizardStep(
                 id='egw',
                 name='Gateway Address for East Port',
                 help='IP of the East-Port Gateway',
                 default='192.85.1.103',
             ),
             wiz.WizardStep(
                 id='waddr',
                 name='West Port Chassis Address?',
                 help='IP address of the West-Port',
                 default='10.10.120.245',
             ),
             wiz.WizardStep(
                 id='wslot',
                 name='West Port Slot Number',
                 help='Slot Number of the West Port',
                 default='1',
             ),
             wiz.WizardStep(
                 id='wport',
                 name='Port Number of the West-Port',
                 help='Port Number for the West Port',
                 default='2',
             ),
             wiz.WizardStep(
                 id='wint',
                 name='West port Interface Address',
                 help='IP to use for West Port?',
                 default='192.85.1.103',
             ),
             wiz.WizardStep(
                 id='wgw',
                 name='Gateway Address for West Port',
                 help='IP of the West-Port Gateway',
                 default='192.85.1.3',
             ),
             wiz.WizardStep(
                 id='script',
                 name='Name of the Script to use for RFC2544 Tests?',
                 help='Script Name to use for RFC 2544 Tests.',
                 default='testcenter-rfc2544-rest.py',
             ),
         )
     )
示例#14
0
 def trex_wizard(self):
     """
     Wizard to collect Trex configuration
     """
     self.wiz_trex = wiz.PromptWizard(
         name="Trex Traffic Generator Configuration",
         description="Specific configurations of Trex TGen",
         steps=(
             wiz.WizardStep(
                 id='hostip',
                 name='What is IP address of the T-Rex Host?',
                 help='Enter the IP address of host where Trex is running',
                 validators=(wiz.required_validator)
             ),
             wiz.WizardStep(
                 id='user',
                 name='What is Usernameof the T-Rex Host?',
                 help='Enter the Username of host where Trex is running',
                 default='root',
             ),
             wiz.WizardStep(
                 id='bdir',
                 name='What is Dir where the T-Rex Binary resides?',
                 help='Enter the Location where Trex Binary is',
                 default='/root/trex_2.37/scripts/',
             ),
             wiz.WizardStep(
                 id='pci1',
                 name='What is PCI address of the port-1?',
                 help='Enter the PCI address of Data port 1',
                 validators=(wiz.required_validator)
             ),
             wiz.WizardStep(
                 id='pci2',
                 name='What is PCI address of the port-2?',
                 help='Enter the PCI address of Data port 2',
                 validators=(wiz.required_validator)
             ),
             wiz.WizardStep(
                 id='rate',
                 name='What is Line rate (in Gbps) of the ports?',
                 help='Enter the linerate of the ports',
                 default='10',
             ),
             wiz.WizardStep(
                 id='prom',
                 name='T-Rex Promiscuous enabled?',
                 help='Do you want to enable the Promiscuous mode?',
                 default='False',
             ),
             wiz.WizardStep(
                 id='lat',
                 name='Whats the Trex Latency PPS?',
                 help='Enter the Latency value in PPS',
                 default='1000',
             ),
             wiz.WizardStep(
                 id='bslv',
                 name='Do you want Binary Loss Verification Enabled?',
                 help='Enter True if you want it to be enabled.',
                 default='True',
             ),
             wiz.WizardStep(
                 id='maxrep',
                 name='If Loss Verification, what the max rep?',
                 help='If BSLV is enabled, whats the max repetition value?',
                 default='2',
             ),
         )
     )
示例#15
0
 def __init__(self, component_info):
     engine_type_header = "Choose engine type:\n" + options_to_str(
         engine_options) + "\nEngine type"
     language_header = "Choose component language:\n" + options_to_str(
         language_options) + "\nLanguage"
     group_header = "Choose group:\n" + options_to_str(
         group_options) + "\nGroup"
     model_behavior_header = "Choose model behavior:\n" + options_to_str(
         model_behavior_options) + "\nModel behavior"
     user_standalone_header = "Choose value:\n" + options_to_str(
         boolean_options) + "\nUser standalone"
     self.wizard = wiz.PromptWizard(
         name="Component Configuration",
         description="Provide values for component main body attributes",
         steps=[
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_NAME_FIELD,
                 name='Component name',
                 help='Component identifier name, without spaces.',
                 default=component_info.name,
                 validators=(wiz.required_validator, no_spaces_validator,
                             repeat_input)),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_ENGINE_TYPE_FIELD,
                 name=engine_type_header,
                 help="Choose value from the list.",
                 default=component_info.engine_type
                 if component_info.engine_type else EngineType.GENERIC,
                 validators=(choice_validator(engine_options),
                             repeat_input)),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_LANGUAGE_FIELD,
                 name=language_header,
                 help="Choose value from the list.",
                 default=component_info.language
                 if component_info.language else ComponentLanguage.PYTHON,
                 validators=(choice_validator(language_options),
                             repeat_input)),
             wiz.WizardStep(id=json_fields.COMPONENT_DESC_GROUP_FIELD,
                            name=group_header,
                            help="Choose value from the list.",
                            default=component_info.group,
                            validators=(choice_validator(group_options),
                                        repeat_input)),
             wiz.WizardStep(id=json_fields.COMPONENT_DESC_LABEL_FIELD,
                            name='Label',
                            help='Label to be displayed in MCenter UI',
                            default=component_info.label,
                            validators=wiz.required_validator),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_DESCRIPTION_FIELD,
                 name='Description',
                 help=
                 'Component functionality description. It is displayed in MCenter UI',
                 default=component_info.description),
             wiz.WizardStep(id=json_fields.COMPONENT_DESC_VERSION_FIELD,
                            name="Component version",
                            help="Component version number",
                            default=component_info.version
                            if component_info.version else "1.0.0"),
             wiz.WizardStep(id=json_fields.COMPONENT_DESC_USER_STAND_ALONE,
                            name=user_standalone_header,
                            help='Component can be standalone or connected',
                            default=component_info.user_standalone
                            if component_info.user_standalone else "False",
                            validators=(choice_validator(boolean_options),
                                        repeat_input)),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_PROGRAM_FIELD,
                 name='Program file',
                 help='File name of the program to run. (for Python)',
                 default=component_info.program,
                 validators=not_required_validator),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_CLASS_FIELD,
                 name='Component class',
                 help=
                 'Name of the class that defines component.(For Python: name only; For Java: full package name + class name)',
                 default=component_info.component_class,
                 validators=not_required_validator),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_MODEL_BEHAVIOR_FIELD,
                 name=model_behavior_header,
                 help="Choose value from the list.",
                 default=component_info.model_behavior
                 if component_info.model_behavior else
                 ComponentModelBehaviorType.MODEL_CONSUMER.value,
                 validators=choice_validator(model_behavior_options)),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_USE_MLOPS_FIELD,
                 name='Use MLOps',
                 help=
                 'Whenever MLOps package is used in the component or not: '
                 + options_to_str(boolean_options),
                 default=component_info.use_mlops
                 if component_info.use_mlops else 'True',
                 validators=(choice_validator(boolean_options))),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_PYTHON_DEPS,
                 name='Dependencies',
                 help=
                 'Dependency packages, comma separated. Example: pytest, numpy, pandas',
                 default=component_info.deps,
                 validators=(not_required_validator, self._deps_validator)),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_INCLUDE_GLOB_PATTERNS,
                 name='Include Glob Patterns',
                 help='Example: **/folder | file.txt',
                 default=component_info.include_glob_patterns,
                 validators=not_required_validator),
             wiz.WizardStep(
                 id=json_fields.COMPONENT_DESC_EXCLUDE_GLOB_PATTERNS,
                 name='Exclude Glob Patterns',
                 help='Example: **/folder | file.txt',
                 default=component_info.exclude_glob_patterns,
                 validators=not_required_validator)
         ])
示例#16
0
def run_generic_addon_wizard():
    """Ask the user general questions needed to create any addon types."""
    import editor
    from pypsi import wizard
    from pypsi.completers import choice_completer

    package_name_step = wizard.WizardStep(
        'package_name',
        'package_name',
        validators=[
            wizard.required_validator,
            _string_length_validator(1, 200), wizard.lowercase_validator
        ],
        help='The name that this addon should be packaged as.')

    version_step = wizard.WizardStep(
        'version',
        'version',
        default='0.0.1',
        validators=[wizard.required_validator, _setuptools_version_validator],
        help=dedent("""
            The version of the addon.

            Often a simple scheme like a dot separated list of major version,
            minor version and patch number will suffice.

            For inspiration and suggestions about what options are available,
            please see PEP404: https://www.python.org/dev/peps/pep-0440/

            The version number shall be compatible with Python's setuptools.
            """))

    description_step = wizard.WizardStep(
        'description',
        'description',
        validators=[
            wizard.required_validator,
            _string_length_validator(1, 200), _escape_single_quote_validator
        ],
        help='A one-line summary of the addon.')

    long_description_step = wizard.WizardStep(
        'long_description',
        'long_description (press tab to launch editor)',
        validators=[wizard.required_validator, _escape_single_quote_validator],
        completer=lambda shell, path, prefix: [editor.edit().decode('UTF-8')],
        help='A more detailed description of the addon.')

    maintainer_step = wizard.WizardStep(
        'maintainer',
        'maintainer',
        validators=[
            wizard.required_validator,
            _string_length_validator(1, 200)
        ],
        help='Name of the person or group maintaining this addon.')

    maintainer_email_step = wizard.WizardStep(
        'maintainer_email',
        'maintainer_email',
        validators=[
            wizard.required_validator, _email_validator,
            _string_length_validator(1, 200)
        ],
        help='E-mail that can be used to reach the maintainer.')

    install_requires_step = wizard.WizardStep(
        'install_requires',
        'install_requires (may be empty)',
        help=dedent("""
            A comma-separated list of packages that this addon requires.

            Version requirements may be specified using Python logic operations.
            For instance the requirement of a specific version of a package may
            be expressed using the 'package==X.Y.Z' syntax.

            Specifying strict version dependencies should be avoided where
            possible, to avoid the difficult to resolve situation where multiple
            addons depend on different specific versions of the same package.

            If your addon requires a feature that was introduced in a specific
            version, a better solution would be to specify that the addon
            requires a version of the package that is greater than X.Y.Z, using
            the 'package>=X.Y.Z' syntax.

            When in doubt, it is best to leave the version information out.
            """))

    entrypoint_step = wizard.WizardStep(
        'entrypoint',
        'entrypoint (class name, use camelcase)',
        validators=[
            wizard.required_validator,
            _string_length_validator(1, 200), _camel_case_validator
        ],
        help=dedent("""
        Name the entrypoint for this addon.

        The entrypoint will be a class and should have a CamelCased name.

        For more information on naming conventions in K2, please see PEP-8:
        https://www.python.org/dev/peps/pep-0008/
        """))

    addon_path_step = wizard.WizardStep(
        'addon_path',
        'path to K2\'s addons root directory',
        validators=[wizard.directory_validator],
        completer=_path_completer,
        default=os.path.abspath(os.path.join(k2.__path__[0], '..', 'addons')),
        help=
        'Path to the K2 addons directory where this addon should be created.')

    addon_type_step = wizard.WizardStep(
        'addon_type',
        'addon_type',
        validators=[
            wizard.required_validator,
            wizard.choice_validator(['framework', 'command'])
        ],
        completer=choice_completer(['framework', 'command'],
                                   case_sensitive=True),
        help=dedent("""
            Select what type of addon you wish to create.

            There are two choices: framework or command.

            Framework extensions have the ability to extend the functionality of
            the K2 framework. They have the ability to add commands or to
            provide new general functionality to the K2 core framework.

            Command extensions have the ability to extend specific commands.
            """))

    return _run_pypsi_wizard(
        wizard.PromptWizard('Addon Creation',
                            dedent("""
            This wizard will guide you through the creation of a K2 addon.

            Please answer the following questions about your K2 addon:
            """),
                            steps=[
                                addon_type_step,
                                package_name_step,
                                version_step,
                                description_step,
                                long_description_step,
                                maintainer_step,
                                maintainer_email_step,
                                install_requires_step,
                                entrypoint_step,
                                addon_path_step,
                            ]))
示例#17
0
        else:
            pass

        return 0


ConfigWizard = wiz.PromptWizard(
    name="Example Configuration",
    description="Shows various examples of wizard steps",
    steps=(
        # The list of input prompts to ask the user.
        wiz.WizardStep(
            # ID where the value will be stored
            id="ip_addr",
            # Display name
            name="IP Address",
            # Help message
            help="Local IP Address or Host name",
            # List of validators to run on the input
            validators=(wiz.required_validator, wiz.hostname_or_ip_validator)),
        wiz.WizardStep(id='port',
                       name="TCP Port",
                       help="TCP port to listen on",
                       validators=(wiz.required_validator,
                                   wiz.int_validator(1024, 65535)),
                       default=1337),
        wiz.WizardStep(
            id='path',
            name='File path',
            help='File path to log file',
            validators=wiz.file_validator,