mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-02 03:37:55 +00:00
many outputs from Pandas dataframe and basic test data on output
This commit is contained in:
@@ -1081,7 +1081,9 @@ class L3CXProfile(LFCliBase):
|
||||
created_cx=None,
|
||||
show=False,
|
||||
report_file=None,
|
||||
output_format=None):
|
||||
output_format=None,
|
||||
script_name=None,
|
||||
arguments=None):
|
||||
try:
|
||||
duration_sec=local_realm.parse_time(duration_sec).seconds
|
||||
except:
|
||||
@@ -1097,6 +1099,12 @@ class L3CXProfile(LFCliBase):
|
||||
raise ValueError("L3CXProfile::monitor wants monitor_interval >= 1 second")
|
||||
if col_names is None:
|
||||
raise ValueError("L3CXProfile::monitor wants a list of column names to monitor")
|
||||
if output_format is not None:
|
||||
if output_format.lower() != report_file.split('.')[-1]:
|
||||
if output_format.lower() != 'excel':
|
||||
raise ValueError('Filename %s does not match output format %s' (report_file, output_format))
|
||||
else:
|
||||
output_format = report_file.split('.')[-1]
|
||||
|
||||
#Step 1, column names
|
||||
fields=",".join(col_names)
|
||||
@@ -1152,7 +1160,7 @@ class L3CXProfile(LFCliBase):
|
||||
#step 4 save and close
|
||||
header_row=col_names
|
||||
header_row.insert(0,'Timestamp')
|
||||
if output_format.lower() == 'excel':
|
||||
if output_format.lower() in ['excel','xlsx'] or report_file.split('.')[-1] is 'xlsx':
|
||||
report_fh = open(report_file, "w+")
|
||||
workbook = xlsxwriter.Workbook(report_file)
|
||||
worksheet = workbook.add_worksheet()
|
||||
@@ -1164,12 +1172,40 @@ class L3CXProfile(LFCliBase):
|
||||
worksheet.write(row_num, col_num, str(data))
|
||||
row_num+=1
|
||||
workbook.close()
|
||||
elif output_format.lower() == 'csv':
|
||||
else:
|
||||
df=pd.DataFrame(endpoints2)
|
||||
df.columns=header_row
|
||||
df.to_csv(report_file)
|
||||
else:
|
||||
pass
|
||||
import requests
|
||||
import ast
|
||||
systeminfo=ast.literal_eval(requests.get('http://localhost:8080').text)
|
||||
df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion']
|
||||
df['Script Name'] = script_name
|
||||
df['Arguments'] = arguments
|
||||
for x in ['LFGUI Release','Script Name','Arguments']:
|
||||
df[x][1:] = ''
|
||||
if output_format == 'pdf':
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.backends.backend_pdf import PdfPages
|
||||
fig, ax = plt.subplots(figsize=(12,4))
|
||||
ax.axis('tight')
|
||||
ax.axis('off')
|
||||
the_table = ax.table(cellText=df.values, colLabels=df.columns, loc='center')
|
||||
pp = PdfPages(report_file)
|
||||
pp.savefig(fig, bbox_inches = 'tight')
|
||||
pp.close()
|
||||
if output_format == 'hdf':
|
||||
df.to_hdf(report_file,'table', append=True)
|
||||
if output_format == 'parquet':
|
||||
df.to_parquet(report_file,engine='pyarrow')
|
||||
if output_format == 'png':
|
||||
fig=df.plot().get_figure()
|
||||
fig.savefig(report_file)
|
||||
supported_formats = ['csv','json','html','stata','pickle']
|
||||
for x in supported_formats:
|
||||
if output_format.lower() == x or report_file.split('.')[-1] == x:
|
||||
exec('df.to_'+x+'("'+report_file+'")')
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ testCommands=("./example_security_connection.py --num_stations $NUM_STA --ssid j
|
||||
"./test_ipv4_l4_urls_per_ten.py --upstream_port eth1 --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600"
|
||||
"./test_ipv4_l4_wifi.py --upstream_port eth1 --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid jedway-wpa2-x2048-4-4 --passwd jedway-wpa2-x2048-4-4 --test_duration 3m"
|
||||
"./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security wpa2 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m --debug"
|
||||
"./test_ipv4_variable_time.py --radio wiphy1 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --mode 4 --ap 00:0e:8e:ff:86:e6 --test_duration 30s"
|
||||
"./test_ipv4_variable_time.py --radio wiphy1 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --mode 4 --ap 00:0e:8e:ff:86:e6 --test_duration 30s --output_format excel"
|
||||
"./test_ipv4_variable_time.py --radio wiphy1 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --mode 4 --ap 00:0e:8e:ff:86:e6 --test_duration 30s --output_format csv"
|
||||
)
|
||||
declare -A name_to_num
|
||||
name_to_num=(
|
||||
|
||||
@@ -228,24 +228,28 @@ def main():
|
||||
ip_var_test.start(False, False)
|
||||
|
||||
if args.report_file is None:
|
||||
if args.output_format == 'csv':
|
||||
report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.csv'
|
||||
output='csv'
|
||||
if args.output_format.isin(['csv','json','html','hdf','stata','pickle','pdf','parquet']):
|
||||
report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.' + args.output_format
|
||||
output=args.output_format
|
||||
else:
|
||||
print('Defaulting to Excel')
|
||||
report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.xlsx'
|
||||
output='excel'
|
||||
else:
|
||||
report_f=args.report_file
|
||||
if args.output_format == 'csv':
|
||||
output='csv'
|
||||
if args.output_format is None:
|
||||
output=str(args.report_file).split('.')[-1]
|
||||
else:
|
||||
output='excel'
|
||||
output=args.output_format
|
||||
|
||||
layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.l3cxprofile.json_get('endp')['endpoint']])
|
||||
ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs'],
|
||||
report_file=report_f,
|
||||
duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).seconds,
|
||||
created_cx= layer3connections,
|
||||
output_format=output)
|
||||
output_format=output,
|
||||
script_name='test_ipv4_variable_time',
|
||||
arguments=args)
|
||||
ip_var_test.stop()
|
||||
if not ip_var_test.passes():
|
||||
print(ip_var_test.get_fail_message())
|
||||
|
||||
Reference in New Issue
Block a user