How to use add_parser method in ATX

Best Python code snippet using ATX

argparser.py

Source:argparser.py Github

copy

Full Screen

...9 description='Actions cover tasks that are able to modify the configuration of the upribox',10 help='This script accepts the name of an action that shall be executed',11 dest='action')12 # create the parser for the "set_ssid" command13 parser_set_ssid = subparser.add_parser('set_ssid',14 help='Sets a new SSID for the Silent WiFi by writing to the fact *wlan*')15 parser_set_ssid.add_argument('arg', help='The SSID for the Silent WiFi', metavar="ssid")16 # create the parser for the "set_password" command17 parser_set_password = subparser.add_parser('set_password',18 help='Sets a new password for the Silent WiFi by writing to the fact *wlan*')19 parser_set_password.add_argument('arg', help='The SSID for the Silent WiFi', metavar="password")20 # create the parser for the "restart_wlan" command21 subparser.add_parser('restart_wlan', help='Triggers the Ansible tasks with the tag *ssid*')22 # create the parser for the "enable_silent" command23 parser_enable_silent = subparser.add_parser('enable_silent',24 help='Enables/disables the Silent WiFi by writing to the fact *wlan*')25 parser_enable_silent.add_argument('arg', help='Whether or not Silent WiFi is enabled ("yes" or "no")',26 metavar="boolean", choices=["yes", "no"]).completer = boolean_completer27 # create the parser for the "restart_silent" command28 subparser.add_parser('restart_silent', help='Triggers the Ansible tasks with the tag *toggle_silent*')29 # create the parser for the "enable_vpn" command30 parser_enable_vpn = subparser.add_parser('enable_vpn', help='Enables/disables the VPN by writing to the fact *vpn*')31 parser_enable_vpn.add_argument('arg', help='Whether or not VPN is enabled ("yes" or "no")', metavar="boolean", choices=["yes", "no"]).completer = boolean_completer32 # create the parser for the "set_vpn_connection" command33 parser_set_vpn_connection = subparser.add_parser('set_vpn_connection',34 help='Sets a custom port and protocol for the upribox OpenVPN server by writing to the fact *vpn*')35 parser_set_vpn_connection.add_argument('arg',36 help='The port and protocol used for the OpenVPN server (usage: "1194/udp")',37 metavar="port_protocol")38 # create the parser for the "set_wlan_channel" command39 parser_set_wlan_channel = subparser.add_parser('set_wlan_channel',40 help='Sets a new WiFi channel for the Silent WiFi by writing to the fact *wlan*')41 parser_set_wlan_channel.add_argument('arg', help='The channel for the Silent WiFi', metavar="channel")42 # create the parser for the "restart_vpn" command43 subparser.add_parser('restart_vpn', help='Triggers the Ansible tasks with the tag *toggle_vpn*')44 # create the parser for the "enable_ssh" command45 parser_enable_ssh = subparser.add_parser('enable_ssh', help='Enables/disables the ssh by writing to the fact *ssh*')46 parser_enable_ssh.add_argument('arg', help='Whether or not SSH is enabled ("yes" or "no")', metavar="boolean", choices=["yes", "no"]).completer = boolean_completer47 # create the parser for the "restart_ssh" command48 subparser.add_parser('restart_ssh', help='Triggers the Ansible tasks with the tag *toggle_ssh*')49 # create the parser for the "enable_apate" command50 parser_enable_apate = subparser.add_parser('enable_apate',51 help='Enables/disables the Apate (see arp) by writing to the fact *apate*')52 parser_enable_apate.add_argument('arg', help='Whether or not Apate is enabled ("yes" or "no")', metavar="boolean", choices=["yes", "no"]).completer = boolean_completer53 # create the parser for the "enable_static_ip" command54 parser_enable_static_ip = subparser.add_parser('enable_static_ip',55 help='Sets the upribox to DHCP or static IP mode by writing to the fact *interfaces*')56 parser_enable_static_ip.add_argument('arg', help='Whether or not a static IP is enabled ("yes" or "no")',57 metavar="boolean", choices=["yes", "no"]).completer = boolean_completer58 # create the parser for the "restart_apate" command59 subparser.add_parser('restart_apate', help='Triggers the Ansible tasks with the tag *toggle_apate*')60 # create the parser for the "parse_logs" command61 subparser.add_parser('parse_logs', help='Parses the log files of the services and aggregates the statistics data')62 # create the parser for the "parse_user_agents" command63 subparser.add_parser('parse_user_agents',64 help='Parses the log file of the service squid containing MAC addresses, IP addresses and user-agents and saves the gathered information into the database')65 # create the parser for the "generate_profile" command66 parser_generate_profile = subparser.add_parser('generate_profile',67 help='Generates openvpn client certificates and saves the generated openvpn client configuration into the database')68 parser_generate_profile.add_argument('arg',69 help='The profile ID of a profile that was created in the web interface',70 metavar="profile_id")71 # create the parser for the "delete_profile" command72 parser_delete_profile = subparser.add_parser('delete_profile',73 help='Revokes previously generated openvpn client certificates')74 parser_delete_profile.add_argument('arg', help='The profile ID of a profile that was created in the web interface',75 metavar="profile_id")76 # create the parser for the "restart_firewall" command77 subparser.add_parser('restart_firewall', help='Triggers the Ansible tasks with the tag *iptables*')78 # # create the parser for the "enable_device" command79 # parser_enable_device = subparser.add_parser('enable_device',80 # help='Enables ARP spoofing via Apate (see arp) for a specific device')81 # parser_enable_device.add_argument('arg', help='The IP address of the device that shall be enabled', metavar="ip")82 #83 # # create the parser for the "disable_device" command84 # parser_disable_device = subparser.add_parser('disable_device',85 # help='Disables ARP spoofing via Apate (see arp) for a specific device')86 # parser_disable_device.add_argument('arg', help='The IP address of the device that shall be disabled', metavar="ip")87 # create the parser for the "set_ip" command88 parser_set_ip = subparser.add_parser('set_ip', help='Sets a static IP by writing to the fact *interfaces*')89 parser_set_ip.add_argument('arg', help='The static IP address for the upribox', metavar="ip")90 # create the parser for the "configure_devices" command91 subparser.add_parser('configure_devices', help='Triggers the Ansible tasks with the tag *configure_devices*')92 # create the parser for the "set_dns_server" command93 parser_set_dns_server = subparser.add_parser('set_dns_server',94 help='Sets the DNS server by writing to the fact *interfaces*')95 parser_set_dns_server.add_argument('arg', help='The DNS server for the upribox', metavar="dns")96 # create the parser for the "set_netmask" command97 parser_set_netmask = subparser.add_parser('set_netmask', help='Sets subnetmask by writing to the fact *interfaces*')98 parser_set_netmask.add_argument('arg', help='The subnetmask for the upribox', metavar="netmask")99 # create the parser for the "set_gateway" command100 parser_set_gateway = subparser.add_parser('set_gateway',101 help='Sets the gateway by writing to the fact *interfaces*')102 parser_set_gateway.add_argument('arg', help='The gateway for the upribox', metavar="gateway")103 # create the parser for the "restart_network" command104 subparser.add_parser('restart_network', help='Triggers the Ansible tasks with the tag *network_config*')105 # create the parser for the "set_dhcpd" command106 parser_set_dhcpd = subparser.add_parser('set_dhcpd',107 help='Enables/disables the DHCP server by writing to the fact *dhcpd*')108 parser_set_dhcpd.add_argument('arg', help='Whether or not the upribox acts as a DHCP server ("yes" or "no")',109 metavar="boolean", choices=["yes", "no"]).completer = boolean_completer110 # create the parser for the "restart_dhcpd" command111 subparser.add_parser('restart_dhcpd', help='Triggers the Ansible tasks with the tag *dhcp_server*')112 # create the parser for the "torify_device" command113 parser_torify_device = subparser.add_parser('torify_device', help='Adds iptables rule to torify a specific device')114 parser_torify_device.add_argument('arg',115 help='The MAC address of the device whose traffic shall be routed over the tor network',116 metavar="mac")117 # create the parser for the "exclude_device" command118 parser_exclude_device = subparser.add_parser('exclude_device',119 help='Adds iptables rule to disable ad-blocking for a specific device')120 parser_exclude_device.add_argument('arg', help='The MAC address of the device whose traffic shall not be ad-blocked',121 metavar="mac")122 # create the parser for the "untorify_device" command123 parser_untorify_device = subparser.add_parser('untorify_device',124 help='Removes iptables rule to untorify a specific device')125 parser_untorify_device.add_argument('arg',126 help='The MAC address of the device whose traffic shall not be routed over the tor network',127 metavar="mac")128 # create the parser for the "include_device" command129 parser_include_device = subparser.add_parser('include_device',130 help='Removes iptables rule to enable ad-blocking for a specific device')131 parser_include_device.add_argument('arg', help='The MAC address of the device whose traffic shall be ad-blocked',132 metavar="mac")133 # create the parser for the "silent_device" command134 parser_silent_device = subparser.add_parser('silent_device',135 help='Shortcut for calling of include_device and untorify_device')136 parser_silent_device.add_argument('arg', help='The MAC address of the device whose mode shall be set to silent',137 metavar="mac")138 # create the parser for the "check_device" command139 parser_check_device = subparser.add_parser('check_device', help='Checks if device with given ip address is online')140 parser_check_device.add_argument('arg',141 help='The IP address of the device to check',142 metavar="ip")143 # create the parser for the "filter_update" command144 subparser.add_parser('filter_update', help='updates the filter files')145 # create the parser for the "vpn_forward" command146 parser_vpn_forward = subparser.add_parser('vpn_forward', help='enables vpn port forwarding if possible')147 parser_vpn_forward.add_argument('--debug', action='store_true', help='Print additional debug messages', dest="arg")148 parser_vpn_unforward = subparser.add_parser('vpn_unforward', help='removes vpn port forwarding')149 parser_vpn_unforward.add_argument('--debug', action='store_true', help='Print additional debug messages', dest="arg")150 parser_backup = subparser.add_parser('backup_settings', help='Saves settings and logs to a backup archive')151 parser_backup.add_argument('arg', help='The path of the backup archive',152 metavar="path", nargs='?', default='/home/upri')153 parser_restore = subparser.add_parser('restore_settings', help="Restore settings from backup archive")154 parser_restore.add_argument('arg', help='The path of the backup archive',155 metavar="path")156 argcomplete.autocomplete(parser)...

Full Screen

Full Screen

oc.py

Source:oc.py Github

copy

Full Screen

...9 description="Open-CRAVAT genomic variant interpreter. https://github.com/KarchinLab/open-cravat"10)11root_sp = root_p.add_subparsers(title="Commands")12# run13run_p = root_sp.add_parser(14 "run",15 parents=[cravat_cmd_parser],16 add_help=False,17 description="Run a job",18 help="Run a job",19 epilog="inputs should be the first argument",20)21# report22report_p = root_sp.add_parser(23 "report",24 parents=[report_parser],25 add_help=False,26 help="Generate a report from a job",27 epilog="dbpath must be the first argument",28)29# gui30gui_p = root_sp.add_parser(31 "gui", parents=[gui_parser], add_help=False, help="Start the GUI"32)33# module34module_p = root_sp.add_parser(35 "module", description="Change installed modules", help="Change installed modules"36)37module_sp = module_p.add_subparsers(title="Commands")38module_ls_p = module_sp.add_parser(39 "ls", parents=[cravat_admin.parser_ls], add_help=False, help="List modules"40)41module_install_p = module_sp.add_parser(42 "install",43 parents=[cravat_admin.parser_install],44 add_help=False,45 help="Install modules",46)47module_uninstall_p = module_sp.add_parser(48 "uninstall",49 parents=[cravat_admin.parser_uninstall],50 add_help=False,51 help="Uninstall modules",52)53module_update_p = module_sp.add_parser(54 "update",55 parents=[cravat_admin.parser_update],56 add_help=False,57 help="Update modules",58)59module_info_p = module_sp.add_parser(60 "info", parents=[cravat_admin.parser_info], add_help=False, help="Module details"61)62module_install_base_base_p = module_sp.add_parser(63 "install-base",64 parents=[cravat_admin.parser_install_base],65 add_help=False,66 help="Install base modules",67)68# config69config_p = root_sp.add_parser(70 "config",71 description="View and change configuration settings",72 help="View and change configuration settings",73)74config_sp = config_p.add_subparsers(title="Commands")75config_md_p = config_sp.add_parser(76 "md",77 parents=[cravat_admin.parser_md],78 add_help=False,79 help="Change modules directory",80)81config_system_p = config_sp.add_parser(82 "system",83 parents=[cravat_admin.parser_show_system_conf],84 add_help=False,85 help="Show system config",86)87config_system_p = config_sp.add_parser(88 "cravat",89 parents=[cravat_admin.parser_show_cravat_conf],90 add_help=False,91 help="Show cravat config",92)93# new94new_p = root_sp.add_parser(95 "new", description="Create new modules", help="Create new modules"96)97new_sp = new_p.add_subparsers(title="Commands")98create_example_input_p = new_sp.add_parser(99 "example-input",100 parents=[cravat_admin.parser_make_example_input],101 add_help=False,102 help="Make example input file",103)104create_annotator_p = new_sp.add_parser(105 "annotator",106 parents=[cravat_admin.parser_new_annotator],107 add_help=False,108 help="Create new annotator",109)110# store111store_p = root_sp.add_parser(112 "store",113 description="Publish modules to the store",114 help="Publish modules to the store",115)116store_sp = store_p.add_subparsers(title="Commands")117store_publish_p = store_sp.add_parser(118 "publish",119 parents=[cravat_admin.parser_publish],120 add_help=False,121 help="Publish a module",122)123account_create_p = store_sp.add_parser(124 "new-account",125 parents=[cravat_admin.parser_create_account],126 add_help=False,127 help="Create an account",128)129account_change_pw_p = store_sp.add_parser(130 "change-pw",131 parents=[cravat_admin.parser_change_password],132 add_help=False,133 help="Change password",134)135account_reset_pw_p = store_sp.add_parser(136 "reset-pw",137 parents=[cravat_admin.parser_reset_pw],138 add_help=False,139 help="Request password reset",140)141account_verify_email_p = store_sp.add_parser(142 "verify-email",143 parents=[cravat_admin.parser_verify_email],144 add_help=False,145 help="Request email verification",146)147account_check_login_p = store_sp.add_parser(148 "check-login",149 parents=[cravat_admin.parser_check_login],150 add_help=False,151 help="Check login credentials",152)153# util154util_p = root_sp.add_parser("util", description="Utilities", help="Utilities")155util_sp = util_p.add_subparsers(title="Commands")156util_test_p = util_sp.add_parser(157 "test", parents=[test_parser], add_help=False, help="Test installed modules"158)159util_update_result_p = util_sp.add_parser(160 "update-result",161 parents=[cravat_util.parser_migrate_result],162 add_help=False,163 help="Update old result database to newer format",164)165util_send_gui_p = util_sp.add_parser(166 "send-gui",167 parents=[cravat_util.parser_result2gui],168 add_help=False,169 help="Copy a command line job into the GUI submission list",170)171util_mergesqlite_p = util_sp.add_parser(172 "mergesqlite",173 parents=[cravat_util.parser_mergesqlite],174 add_help=False,175 help="Merge SQLite result files",176)177util_filtersqlite_p = util_sp.add_parser(178 "filtersqlite",179 parents=[cravat_util.parser_filtersqlite],180 add_help=False,181 help="Filter SQLite result files",182)183util_showsqliteinfo_p = util_sp.add_parser(184 "showsqliteinfo",185 parents=[cravat_util.parser_showsqliteinfo],186 add_help=False,187 help="Show SQLite result file information",188)189# version190version_p = root_sp.add_parser(191 "version",192 parents=[cravat_admin.parser_show_version],193 add_help=False,194 help="Show version",195)196# feedback197feedback_p = root_sp.add_parser(198 "feedback",199 parents=[cravat_admin.parser_report_issue],200 add_help=False,201 help="Send feedback to the developers",202)203def main():204 args = root_p.parse_args()205 if hasattr(args, "func"):206 args.func(args)207 else:208 root_p.parse_args(sys.argv[1:] + ["--help"])209if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful