Skip to content

Commit

Permalink
py-scripts/tools/lf_cli_to_testjson.py flake8 white space cleanup
Browse files Browse the repository at this point in the history
Verified:
./lf_cli_to_testjson.py --help

Signed-off-by: Chuck SmileyRekiere <[email protected]>
  • Loading branch information
smileyrekiere committed Jan 31, 2025
1 parent 7baaf1e commit 7d9ad92
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions py-scripts/tools/lf_cli_to_testjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
STATUS: Functional
STATUS: Functional
VERIFIED_ON:
Working date : 12/07/2023
Expand All @@ -84,57 +84,58 @@

sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))


class clitojson():
def __init__(self,

cli_list=["--mgr 192.168.200.147 --port 8080 --lf_user lanforge --lf_password lanforge --instance_name scenario_wpa2_wc --upstream 1.1.eth1 --batch_size 1,3,5 --loop_iter 1 --protocol TCP-IPv4 --duration 20000 --download_rate 10Mbps --upload_rate 10Mbps --pull_report --delete_old_scenario --local_lf_report_dir /home/lanforge/html-scripts --test_tag WCT_MTK7915_W1_5G_40_UDP_BD_AT --test_rig TEST_RIG --set DUT_SET_NAME"],
list= [],
length_of_cli=[]
cli_list=["--mgr 192.168.200.147 --port 8080 --lf_user lanforge --lf_password lanforge --instance_name scenario_wpa2_wc --upstream 1.1.eth1 --batch_size 1,3,5 --loop_iter 1 --protocol TCP-IPv4 --duration 20000 --download_rate 10Mbps --upload_rate 10Mbps --pull_report --delete_old_scenario --local_lf_report_dir /home/lanforge/html-scripts --test_tag WCT_MTK7915_W1_5G_40_UDP_BD_AT --test_rig TEST_RIG --set DUT_SET_NAME"],
list=[],
length_of_cli=[]

):

self.cli_list=cli_list
self.list1=list
self.length_of_cli=length_of_cli
self.cli_list = cli_list
self.list1 = list
self.length_of_cli = length_of_cli
print(self.cli_list)

def split_cli(self):
l1=self.cli_list.split(' ')
l1 = self.cli_list.split(' ')
self.length_of_cli.append(len(l1))
print("l1",l1)
print("l1", l1)

for i in range(self.length_of_cli[0]):
if i+1 == self.length_of_cli[0]:
if i + 1 == self.length_of_cli[0]:
break

for j in range(len(l1)):
if j+1 == len(l1) and ("--" or "-") in l1[j]:
if j + 1 == len(l1) and ("--" or "-") in l1[j]:
self.list1.append(l1[j])
break
if ("--" in l1[j]) :
if ("--" not in l1[j+1]):
self.list1.append(l1[j]+ " "+l1[j+1])
if ("--" in l1[j]):
if ("--" not in l1[j + 1]):
self.list1.append(l1[j] + " " + l1[j + 1])
else:
if ("--" in l1[j+1]):
self.list1.append(l1[j] +" ")
if ("--" in l1[j + 1]):
self.list1.append(l1[j] + " ")

self.json_dump()

def json_dump(self):
s='args_list'
json_list=json.dumps(self.list1)
print(s,json_list)
dict1={s:self.list1}
out_file=open("test1.json","w")
json.dump(dict1,out_file,indent=4)
s = 'args_list'
json_list = json.dumps(self.list1)
print(s, json_list)
dict1 = {s: self.list1}
out_file = open("test1.json", "w")
json.dump(dict1, out_file, indent=4)
out_file.close()


def main():
parser = argparse.ArgumentParser(
prog='lf_cli_to_testjson.py',
formatter_class=argparse.RawTextHelpFormatter,
description= """
description="""
NAME: lf_cli_to_testjson.py
Expand Down Expand Up @@ -209,13 +210,14 @@ def main():
"""
)

parser.add_argument("--cli",type=str, help="--cli '<command in quotes>'", required=True)
parser.add_argument("--cli", type=str, help="--cli '<command in quotes>'", required=True)

args = parser.parse_args()

conversion=clitojson(cli_list= args.cli)
conversion = clitojson(cli_list=args.cli)

conversion.split_cli()


if __name__ == "__main__":
main()

0 comments on commit 7d9ad92

Please sign in to comment.