mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-03 04:07:52 +00:00
argparse and help fixed
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
if sys.version_info[0] != 3:
|
if sys.version_info[0] != 3:
|
||||||
@@ -76,49 +77,37 @@ def main():
|
|||||||
prog='example_security_connection.py',
|
prog='example_security_connection.py',
|
||||||
formatter_class=argparse.RawTextHelpFormatter,
|
formatter_class=argparse.RawTextHelpFormatter,
|
||||||
epilog='''\
|
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='''\
|
description='''\
|
||||||
example_security_connection.py
|
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:
|
Example of command line to run:
|
||||||
python3 ./example_security_connection.py
|
./example_security_connection.py
|
||||||
--mgr localhost
|
--mgr localhost
|
||||||
--mgr_port 8080
|
--mgr_port 8080
|
||||||
--num_stations 6
|
--num_stations 6
|
||||||
--mode 1
|
--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
|
--radio wiphy2
|
||||||
--security {open|wep|wpa|wpa2|wpa3}
|
--security {open|wep|wpa|wpa2|wpa3}
|
||||||
--ssid netgear-wpa3
|
--ssid netgear-wpa3
|
||||||
--ap "00:0e:8e:78:e1:76"
|
--ap "00:0e:8e:78:e1:76"
|
||||||
--passwd admin123-wpa3
|
--passwd admin123-wpa3
|
||||||
--debug
|
--debug
|
||||||
|
|
||||||
''')
|
''')
|
||||||
optional = parser.add_argument_group('optional arguments')
|
required=None
|
||||||
required = parser.add_argument_group('required arguments')
|
for agroup in parser._action_groups:
|
||||||
required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', required=True)
|
if agroup.title == "required arguments":
|
||||||
optional.add_argument('--mode',help='Used to force mode of stations')
|
required = agroup
|
||||||
optional.add_argument('--ap',help='Used to force a connection to a particular AP')
|
#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()
|
args = parser.parse_args()
|
||||||
num_sta = 2
|
num_sta = 2
|
||||||
@@ -131,8 +120,11 @@ def main():
|
|||||||
end_id_=num_sta-1,
|
end_id_=num_sta-1,
|
||||||
padding_number_=10000,
|
padding_number_=10000,
|
||||||
radio=args.radio)
|
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,
|
ip_test = IPv4Test(host=args.mgr, port=args.mgr_port,
|
||||||
security=args.security, sta_list=station_list, ap=args.ap)
|
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.cleanup(station_list)
|
||||||
ip_test.timeout = 60
|
ip_test.timeout = 60
|
||||||
ip_test.build()
|
ip_test.build()
|
||||||
|
|||||||
Reference in New Issue
Block a user