mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
argparse and help fixed
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
import sys
|
||||
import os
|
||||
if sys.version_info[0] != 3:
|
||||
@@ -76,49 +77,37 @@ def main():
|
||||
prog='example_security_connection.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
Example flags and command line input to run the script.
|
||||
This python script creates an inputted number of stations using user-inputted security. This verifies that the most basic form of security works with the LANforge device.
|
||||
''',
|
||||
|
||||
description='''\
|
||||
example_security_connection.py
|
||||
--------------------
|
||||
This python script creates an inputted number of stations using user-inputted security. This verifies that the most basic form of security works with the LANforge device.
|
||||
--------------------
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Generic command example:
|
||||
python3 ./example_security_connection.py
|
||||
Example of command line to run:
|
||||
./example_security_connection.py
|
||||
--mgr localhost
|
||||
--mgr_port 8080
|
||||
--num_stations 6
|
||||
--mode 1
|
||||
{"auto" : "0",
|
||||
"a" : "1",
|
||||
"b" : "2",
|
||||
"g" : "3",
|
||||
"abg" : "4",
|
||||
"abgn" : "5",
|
||||
"bgn" : "6",
|
||||
"bg" : "7",
|
||||
"abgnAC" : "8",
|
||||
"anAC" : "9",
|
||||
"an" : "10",
|
||||
"bgnAC" : "11",
|
||||
"abgnAX" : "12",
|
||||
"bgnAX" : "13",
|
||||
"anAX" : "14"}
|
||||
--radio wiphy2
|
||||
--security {open|wep|wpa|wpa2|wpa3}
|
||||
--ssid netgear-wpa3
|
||||
--ap "00:0e:8e:78:e1:76"
|
||||
--passwd admin123-wpa3
|
||||
--debug
|
||||
|
||||
''')
|
||||
optional = parser.add_argument_group('optional arguments')
|
||||
required = parser.add_argument_group('required arguments')
|
||||
required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', required=True)
|
||||
optional.add_argument('--mode',help='Used to force mode of stations')
|
||||
optional.add_argument('--ap',help='Used to force a connection to a particular AP')
|
||||
required=None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "required arguments":
|
||||
required = agroup
|
||||
#if required is not None:
|
||||
optional = None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "optional arguments":
|
||||
optional = agroup
|
||||
if optional is not None:
|
||||
optional.add_argument('--mode',help=LFCliBase.Help_Mode)
|
||||
optional.add_argument('--ap',help='Add BSSID of access point to connect to')
|
||||
|
||||
args = parser.parse_args()
|
||||
num_sta = 2
|
||||
@@ -131,8 +120,11 @@ def main():
|
||||
end_id_=num_sta-1,
|
||||
padding_number_=10000,
|
||||
radio=args.radio)
|
||||
ip_test = IPv4Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, radio=args.radio, mode= args.mode,
|
||||
security=args.security, sta_list=station_list, ap=args.ap)
|
||||
ip_test = IPv4Test(host=args.mgr, port=args.mgr_port,
|
||||
ssid=args.ssid, password=args.passwd,
|
||||
radio=args.radio, mode= args.mode,
|
||||
security=args.security, sta_list=station_list,
|
||||
ap=args.ap)
|
||||
ip_test.cleanup(station_list)
|
||||
ip_test.timeout = 60
|
||||
ip_test.build()
|
||||
|
||||
Reference in New Issue
Block a user