mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 19:28:00 +00:00
1. Updating argparse commands so they include flags
2. Create check_argparse which allows us to check which flags are or are not included in argparse statements. Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
57
py-scripts/check_argparse.py
Normal file
57
py-scripts/check_argparse.py
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import pandas as pd
|
||||
import argparse
|
||||
|
||||
|
||||
def get_tag(x, tag):
|
||||
try:
|
||||
return x[tag]
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="check_argparse.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description='''
|
||||
Check each file in py-scripts, or user defined '''
|
||||
)
|
||||
parser.add_argument("--path", default='.')
|
||||
parser.add_argument("--output", default='argparse_results')
|
||||
args = parser.parse_args()
|
||||
|
||||
files = [f for f in os.listdir(args.path) if '.py' in f]
|
||||
results = dict()
|
||||
for file in files:
|
||||
text = open(os.path.join(args.path, file)).read()
|
||||
results_file = dict()
|
||||
results_file['argparse'] = 'argparse.' in text
|
||||
if results_file['argparse'] is True:
|
||||
results_file['create_basic'] = 'create_basic_argparse' in text
|
||||
results_file['create_bare'] = 'create_bare_argparse' in text
|
||||
results_file['prog'] = 'prog=' in text
|
||||
results_file['formatter_class'] = 'formatter_class=' in text
|
||||
results_file['description'] = 'description=' in text
|
||||
results_file['epilog'] = 'epilog=' in text
|
||||
results_file['usage'] = 'usage=' in text
|
||||
results[file] = results_file
|
||||
df = pd.DataFrame(results.items())
|
||||
df.columns = ['File', 'results']
|
||||
df['argparse'] = [x['argparse'] for x in df['results']]
|
||||
for tag in ['create_basic',
|
||||
'create_bare',
|
||||
'prog',
|
||||
'formatter_class',
|
||||
'description',
|
||||
'epilog',
|
||||
'usage']:
|
||||
df[tag] = [get_tag(x, tag) for x in df['results']]
|
||||
df['details'] = df['description'] + df['epilog'] + df['usage']
|
||||
df.to_csv(args.output + '.csv', index=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -171,6 +171,8 @@ class CreateChamberview(cv):
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='create_chamberview.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""
|
||||
For Two line scenario use --line twice as shown in example, for multi line scenario
|
||||
use --line argument to create multiple lines
|
||||
|
||||
@@ -145,6 +145,8 @@ class DUT(dut):
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='create_chamberview_dut.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""
|
||||
./create_chamberview_dut -m "localhost" -o "8080" -d "dut_name"
|
||||
--ssid "ssid_idx=0 ssid=NET1 security=WPA|WEP|11r|EAP-PEAP bssid=78:d2:94:bf:16:41"
|
||||
|
||||
@@ -124,7 +124,7 @@ def main():
|
||||
|
||||
#debug_on = False
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='quick_test.py',
|
||||
prog='csv_processor.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
Useful Information:
|
||||
|
||||
@@ -38,7 +38,9 @@ class CSVtoInflux:
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='csv_to_influx.py'
|
||||
)
|
||||
cv_add_base_parser(parser)
|
||||
|
||||
parser.add_argument('--path', action='append')
|
||||
|
||||
@@ -30,7 +30,10 @@ class CVManager(cv_test):
|
||||
self.build_cv_scenario()
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='''This is a simple driver script to load a CV Scenario''')
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='cv_manager.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description='''This is a simple driver script to load a CV Scenario''')
|
||||
parser.add_argument('--scenario', help='Scenario you wish to build')
|
||||
parser.add_argument('--debug', help='Enable debugging', default=False, action="store_true")
|
||||
parser.add_argument('--mgr', default='localhost')
|
||||
|
||||
@@ -137,7 +137,10 @@ class Layer3Test(LFCliBase):
|
||||
|
||||
def main():
|
||||
# This has --mgr, --mgr_port and --debug
|
||||
parser = LFCliBase.create_basic_argparse(prog="layer3_test.py", formatter_class=argparse.RawTextHelpFormatter, epilog="About This Script")
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
prog="layer3_test.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog="About This Script")
|
||||
|
||||
# Adding More Arguments for custom use
|
||||
parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="1m")
|
||||
|
||||
@@ -295,7 +295,10 @@ class ApAutoTest(cvtest):
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser("""
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lf_ap_auto_test.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""
|
||||
Open this file in an editor and read the top notes for more details.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -219,7 +219,10 @@ class DataplaneTest(cv_test):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="""
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='lf_dataplane_test',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""
|
||||
|
||||
IMPORTANT: Start lanforge with socket 3990 : ./lfclient.bash -cli-socket 3990
|
||||
lfclient.bash is located in the LANforgeGUI_X.X.X directory
|
||||
|
||||
@@ -308,7 +308,10 @@ class VAP_Measure(LFCliBase):
|
||||
# main method
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description="Test Scenario of DUT Temperature measurement along with simultaneous throughput on VAP as well as stations")
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='lf_dut_sta_vap_test.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="Test Scenario of DUT Temperature measurement along with simultaneous throughput on VAP as well as stations")
|
||||
|
||||
parser.add_argument("-m", "--manager", type=str, help="Enter the address of Lanforge Manager (By default localhost)")
|
||||
parser.add_argument("-sc", "--scenario", type=str, help="Enter the Name of the Scenario you want to load (by Default DFLT)")
|
||||
|
||||
@@ -700,7 +700,10 @@ class FtpTest(LFCliBase):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="FTP Test Script")
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='lf_ftp.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="FTP Test Script")
|
||||
parser.add_argument('--mgr', help='hostname for where LANforge GUI is running', default='localhost')
|
||||
parser.add_argument('--mgr_port', help='port LANforge GUI HTTP service is running on', default=8080)
|
||||
parser.add_argument('--upstream_port', help='non-station port that generates traffic: eg: eth1', default='eth1')
|
||||
|
||||
@@ -218,7 +218,10 @@ class MeshTest(cvtest):
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser("""
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lf_mesh_test.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""
|
||||
Open this file in an editor and read the top notes for more details.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -318,7 +318,10 @@ class MultiPsk(Realm):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="lanforge webpage download Test Script")
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lf_multipsk.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="lanforge webpage download Test Script")
|
||||
parser.add_argument('--mgr', help='hostname for where LANforge GUI is running', default='localhost')
|
||||
parser.add_argument('--mgr_port', help='port LANforge GUI HTTP service is running on', default=8080)
|
||||
parser.add_argument('--ssid', help='WiFi SSID for client to associate to')
|
||||
|
||||
@@ -218,7 +218,10 @@ class RvrTest(cvtest):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser("""
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lf_rvr_test.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""
|
||||
Open this file in an editor and read the top notes for more details.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -222,7 +222,10 @@ class RxSensitivityTest(cv_test):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="""
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='lf_rx_sensitivity_test.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""
|
||||
|
||||
IMPORTANT: Start lanforge with socket 3990 : ./lfclient.bash -cli-socket 3990
|
||||
lfclient.bash is located in the LANforgeGUI_X.X.X directory
|
||||
|
||||
@@ -77,8 +77,11 @@ class SniffRadio(Realm):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(usage=
|
||||
"""./lf_sniff_radio.py
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lf_sniff_radio.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
usage=
|
||||
"""./lf_sniff_radio.py
|
||||
--mgr localhost
|
||||
--mgr_port 8080
|
||||
--radio wiphy0
|
||||
|
||||
@@ -263,7 +263,10 @@ class TR398Test(cvtest):
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser("""
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lf_tr398_test.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""
|
||||
Open this file in an editor and read the top notes for more details.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -614,7 +614,10 @@ class HttpDownload(Realm):
|
||||
report.write_pdf()
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="lanforge webpage download Test Script")
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lf_webpage.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="lanforge webpage download Test Script")
|
||||
parser.add_argument('--mgr', help='hostname for where LANforge GUI is running', default='localhost')
|
||||
parser.add_argument('--mgr_port', help='port LANforge GUI HTTP service is running on', default=8080)
|
||||
parser.add_argument('--upstream_port', help='non-station port that generates traffic: eg: eth1', default='eth2')
|
||||
|
||||
@@ -487,6 +487,8 @@ class WiFiCapacityTest(cv_test):
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lf_wifi_capacity_test.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""
|
||||
./lf_wifi_capacity_test.py --mgr localhost --port 8080 --lf_user lanforge --lf_password lanforge \
|
||||
--instance_name wct_instance --config_name wifi_config --upstream 1.1.eth1 --batch_size 1 --loop_iter 1 \
|
||||
|
||||
@@ -153,10 +153,12 @@ def main():
|
||||
lfjson_host = "localhost"
|
||||
lfjson_port = 8080
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="run_cv_scenario.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""LANforge Reporting Script: Load a scenario and run a RvR report
|
||||
Example:
|
||||
./load_ap_scenario.py --lfmgr 127.0.0.1 --scenario_db 'handsets' --cv_test --test_scenario 'test-20'
|
||||
""")
|
||||
Example:
|
||||
./load_ap_scenario.py --lfmgr 127.0.0.1 --scenario_db 'handsets' --cv_test --test_scenario 'test-20'
|
||||
""")
|
||||
parser.add_argument("-m", "--lfmgr", type=str, help="address of the LANforge GUI machine (localhost is default)")
|
||||
parser.add_argument("-o", "--port", type=int, help="IP Port the LANforge GUI is listening on (8080 is default)")
|
||||
parser.add_argument("-d", "--lanforge_db", type=str, help="Name of test scenario database (see Status Tab)")
|
||||
|
||||
@@ -159,6 +159,8 @@ def main():
|
||||
lfjson_host = "localhost"
|
||||
lfjson_port = 8080
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="rvr_scenario.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""LANforge Reporting Script: Load a scenario and run a RvR report
|
||||
Example:
|
||||
./load_ap_scenario.py --lfmgr 127.0.0.1 --lanforge_db 'handsets' --cv_test --test_scenario 'test-20'
|
||||
|
||||
@@ -479,6 +479,8 @@ def main():
|
||||
lfjson_host = "localhost"
|
||||
lfjson_port = 8080
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="sta_connect.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""LANforge Unit Test: Connect Station to AP
|
||||
Example:
|
||||
./sta_connect.py --dest 192.168.100.209 --dut_ssid OpenWrt-2 --dut_bssid 24:F5:A2:08:21:6C
|
||||
|
||||
@@ -398,6 +398,8 @@ def main():
|
||||
lfjson_host = "localhost"
|
||||
lfjson_port = 8080
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="sta_connect2.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""LANforge Unit Test: Connect Station to AP
|
||||
Example:
|
||||
./sta_connect2.py --dest 192.168.100.209 --dut_ssid OpenWrt-2 --dut_bssid 24:F5:A2:08:21:6C
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
this script creates 1 station on given arguments
|
||||
how to run - [lanforge@LF4-Node2 py-scripts]$ python3 station_banao.py -hst localhost -s TestAP22 -pwd [BLANK] -sec open -rad wiphy0
|
||||
'''
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import argparse
|
||||
import time
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
|
||||
|
||||
class STATION(LFCliBase):
|
||||
def __init__(self, lfclient_host, lfclient_port, ssid, paswd, security, radio, sta_list=None, name_prefix="L3Test", upstream="eth2"):
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
this script creates 1 station on given arguments
|
||||
how to run - [lanforge@LF4-Node2 py-scripts]$ python3 station_banao.py -hst localhost -s TestAP22 -pwd [BLANK] -sec open -rad wiphy0
|
||||
'''
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import argparse
|
||||
import time
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
|
||||
|
||||
class STATION(LFCliBase):
|
||||
def __init__(self, lfclient_host, lfclient_port, ssid, paswd, security, radio, sta_list=None, name_prefix="L3Test", upstream="eth2"):
|
||||
super().__init__(lfclient_host, lfclient_port)
|
||||
self.host = lfclient_host
|
||||
self.port = lfclient_port
|
||||
@@ -83,7 +83,10 @@ class STATION(LFCliBase):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Netgear AP DFS Test Script")
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='station_layer3.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="Netgear AP DFS Test Script")
|
||||
parser.add_argument('-hst', '--host', type=str, help='host name')
|
||||
parser.add_argument('-s', '--ssid', type=str, help='ssid for client')
|
||||
parser.add_argument('-pwd', '--passwd', type=str, help='password to connect to ssid')
|
||||
@@ -101,6 +104,6 @@ def main():
|
||||
obj.precleanup(station_list)
|
||||
obj.build()
|
||||
obj.start(station_list)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -103,7 +103,10 @@ class LoadLayer3(Realm):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Client Admission Test Script")
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="test_client_admission.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="Client Admission Test Script")
|
||||
parser.add_argument('-hst', '--host', type=str, help='host name')
|
||||
parser.add_argument('-s', '--ssid', type=str, help='ssid for client')
|
||||
parser.add_argument('-pwd', '--passwd', type=str, help='password to connect to ssid')
|
||||
|
||||
@@ -274,7 +274,10 @@ def PortUtility(host, port, duration, report_name, scenario, detail):
|
||||
def main():
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description="Test Scenario of DUT Temperature measurement along with simultaneous throughput on VAP as well as stations")
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="test_l3_scenario_throughput.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="Test Scenario of DUT Temperature measurement along with simultaneous throughput on VAP as well as stations")
|
||||
|
||||
parser.add_argument("-m", "--manager", type=str, help="Enter the address of Lanforge Manager (By default localhost)")
|
||||
parser.add_argument("-sc", "--scenario", type=str, help="Enter the Name of the Scenario you want to load (by Default DFLT)")
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
# INCLUDE_IN_README
|
||||
'''
|
||||
NAME: update_dependencies.py
|
||||
|
||||
PURPOSE: Installs python3 script package dependencies
|
||||
|
||||
OUTPUT: List of successful and unsuccessful installs
|
||||
|
||||
NOTES: Install as root
|
||||
'''
|
||||
|
||||
import subprocess
|
||||
import argparse
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="update_dependencies.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description='''
|
||||
NAME: update_dependencies.py
|
||||
|
||||
PURPOSE: Installs python3 script package dependencies
|
||||
|
||||
OUTPUT: List of successful and unsuccessful installs
|
||||
|
||||
NOTES: Install as root
|
||||
'''
|
||||
)
|
||||
parser.add_argument('--pyjwt', help='Install PyJWT which is necessary for GhostRequest', action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
Reference in New Issue
Block a user