mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
new way to group all arguments of the same class together
This commit is contained in:
@@ -494,7 +494,9 @@ class LFCliBase:
|
||||
def create_basic_argparse(prog=None,
|
||||
formatter_class=None,
|
||||
epilog=None,
|
||||
description=None):
|
||||
description=None,
|
||||
more_optional=None,
|
||||
more_required=None):
|
||||
if (prog is not None) or (formatter_class is not None) or (epilog is not None) or (description is not None):
|
||||
parser = argparse.ArgumentParser(prog=prog,
|
||||
formatter_class=formatter_class,
|
||||
@@ -516,13 +518,26 @@ class LFCliBase:
|
||||
optional.add_argument('--debug', help='Enable debugging', default=False, action="store_true")
|
||||
optional.add_argument('--proxy', nargs='?', default=None,
|
||||
help='Connection proxy like http://proxy.localnet:80 or https://user:pass@proxy.localnet:3128')
|
||||
|
||||
#Required Args
|
||||
if more_optional is not None:
|
||||
for x in more_optional:
|
||||
if 'default' in x.keys():
|
||||
optional.add_argument(x['name'], help=x['help'], default=x['default'])
|
||||
else:
|
||||
optional.add_argument(x['name'], help=x['help'])
|
||||
|
||||
#Required Args
|
||||
required.add_argument('--radio', help='radio EID, e.g: 1.wiphy2')
|
||||
required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', default="open")
|
||||
required.add_argument('--ssid', help='WiFi SSID for script objects to associate to')
|
||||
required.add_argument('--passwd', '--password' ,'--key', help='WiFi passphrase/password/key', default="[BLANK]")
|
||||
|
||||
if more_required is not None:
|
||||
for x in more_required:
|
||||
if 'default' in x.keys():
|
||||
required.add_argument(x['name'], help=x['help'], default=x['default'])
|
||||
else:
|
||||
required.add_argument(x['name'], help=x['help'])
|
||||
|
||||
return parser
|
||||
|
||||
# use this function to add an event You can see these events when watching websocket_client at 8081 port
|
||||
|
||||
@@ -129,13 +129,22 @@ class IPV4VariableTime(Realm):
|
||||
self._pass("PASS: Station build finished")
|
||||
|
||||
def main():
|
||||
optional=[]
|
||||
optional.append({'name':'--mode','help':'Used to force mode of stations'})
|
||||
optional.append({'name':'--ap','help':'Used to force a connection to a particular AP'})
|
||||
optional.append({'name':'--output_format','help':'choose either csv or xlsx'})
|
||||
optional.append({'name':'--report_file','help':'where you want to store results', 'default':None})
|
||||
optional.append({'name':'--a_min','help':'--a_min bps rate minimum for side_a', 'default':256000})
|
||||
optional.append({'name':'--b_min','help':'--b_min bps rate minimum for side_b', 'default':256000})
|
||||
optional.append({'name':'--test_duration','help':'--test_duration sets the duration of the test', 'default':"2m"})
|
||||
optional.append({'name':'--col_names','help':'Columns wished to be monitor', 'default':['name','tx bytes','rx bytes']})
|
||||
optional.append({'name':'--compared_report','help':'report path and file which is wished to be compared with new report', 'default':None})
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
prog='test_ipv4_variable_time.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
Create stations to test connection and traffic on VAPs of varying security types (WEP, WPA, WPA2, WPA3, Open)
|
||||
''',
|
||||
|
||||
description='''\
|
||||
test_ipv4_variable_time.py:
|
||||
--------------------
|
||||
@@ -236,30 +245,9 @@ python3 ./test_ipv4_variable_time.py
|
||||
Elapsed | 'elapsed'
|
||||
Destination Addr | 'destination addr'
|
||||
Source Addr | 'source addr'
|
||||
''')
|
||||
''',
|
||||
more_optional=optional)
|
||||
|
||||
required_args=None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "required arguments":
|
||||
required_args=group
|
||||
break
|
||||
#if required_args is not None:
|
||||
|
||||
optional_args=None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "optional arguments":
|
||||
optional_args=group
|
||||
break
|
||||
if optional_args is not None:
|
||||
optional_args.add_argument('--mode',help='Used to force mode of stations')
|
||||
optional_args.add_argument('--ap',help='Used to force a connection to a particular AP')
|
||||
optional_args.add_argument('--output_format', help='choose either csv or xlsx')
|
||||
optional_args.add_argument('--report_file',help='where you want to store results', default=None)
|
||||
optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000)
|
||||
optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000)
|
||||
optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m")
|
||||
optional_args.add_argument('--col_names', help='Columns wished to be monitor', default=['name','tx bytes','rx bytes'])
|
||||
optional_args.add_argument('--compared_report',help='report path and file which is wished to be compared with new report', default=None)
|
||||
args = parser.parse_args()
|
||||
|
||||
num_sta = 2
|
||||
|
||||
Reference in New Issue
Block a user