mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-10-29 18:02:35 +00:00
l4_cxprofile: Fix whitespace
Signed-off-by: matthew <stidmatt@gmail.com>
This commit is contained in:
@@ -8,7 +8,6 @@ import time
|
||||
import datetime
|
||||
import ast
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -74,7 +73,8 @@ class L4CXProfile(LFCliBase):
|
||||
print(".", end='')
|
||||
print("")
|
||||
|
||||
def compare_vals(self, old_list, new_list):
|
||||
@staticmethod
|
||||
def compare_vals(old_list, new_list):
|
||||
passes = 0
|
||||
expected_passes = 0
|
||||
if len(old_list) == len(new_list):
|
||||
@@ -142,7 +142,11 @@ class L4CXProfile(LFCliBase):
|
||||
def create(self, ports=[], sleep_time=.5, debug_=False, suppress_related_commands_=None):
|
||||
cx_post_data = []
|
||||
for port_name in ports:
|
||||
print("port_name: {} len: {} self.local_realm.name_to_eid(port_name): {}".format(port_name, len(self.local_realm.name_to_eid(port_name)), self.local_realm.name_to_eid(port_name)))
|
||||
print("port_name: {} len: {} self.local_realm.name_to_eid(port_name): {}".format(port_name,
|
||||
len(self.local_realm.name_to_eid(
|
||||
port_name)),
|
||||
self.local_realm.name_to_eid(
|
||||
port_name)))
|
||||
shelf = self.local_realm.name_to_eid(port_name)[0]
|
||||
resource = self.local_realm.name_to_eid(port_name)[1]
|
||||
name = self.local_realm.name_to_eid(port_name)[2]
|
||||
@@ -194,7 +198,7 @@ class L4CXProfile(LFCliBase):
|
||||
except:
|
||||
if (duration_sec is None) or (duration_sec <= 1):
|
||||
raise ValueError("L4CXProfile::monitor wants duration_sec > 1 second")
|
||||
if (duration_sec <= monitor_interval):
|
||||
if duration_sec <= monitor_interval:
|
||||
raise ValueError("L4CXProfile::monitor wants duration_sec > monitor_interval")
|
||||
if report_file is None:
|
||||
raise ValueError("Monitor requires an output file to be defined")
|
||||
@@ -211,20 +215,20 @@ class L4CXProfile(LFCliBase):
|
||||
# Step 1 - Assign column names
|
||||
|
||||
if col_names is not None and len(col_names) > 0:
|
||||
header_row=col_names
|
||||
header_row = col_names
|
||||
else:
|
||||
header_row=list((list(self.json_get("/layer4/all")['endpoint'][0].values())[0].keys()))
|
||||
header_row = list((list(self.json_get("/layer4/all")['endpoint'][0].values())[0].keys()))
|
||||
if debug:
|
||||
print(header_row)
|
||||
|
||||
# Step 2 - Monitor columns
|
||||
start_time = datetime.datetime.now()
|
||||
end_time = start_time + datetime.timedelta(seconds=duration_sec)
|
||||
sleep_interval = round(duration_sec // 5)
|
||||
sleep_interval = round(duration_sec // 5)
|
||||
if debug:
|
||||
print("Sleep_interval is %s ", sleep_interval)
|
||||
print("Start time is %s " , start_time)
|
||||
print("End time is %s " ,end_time)
|
||||
print("Start time is %s ", start_time)
|
||||
print("End time is %s ", end_time)
|
||||
value_map = dict()
|
||||
passes = 0
|
||||
expected_passes = 0
|
||||
@@ -232,7 +236,7 @@ class L4CXProfile(LFCliBase):
|
||||
if self.test_type != 'urls':
|
||||
old_rx_values = self.get_bytes()
|
||||
|
||||
for test in range(1+iterations):
|
||||
for test in range(1 + iterations):
|
||||
while datetime.datetime.now() < end_time:
|
||||
if col_names is None:
|
||||
response = self.json_get("/layer4/all")
|
||||
@@ -276,10 +280,10 @@ class L4CXProfile(LFCliBase):
|
||||
|
||||
print(value_map)
|
||||
|
||||
#[further] post-processing data, after test completion
|
||||
# [further] post-processing data, after test completion
|
||||
full_test_data_list = []
|
||||
for test_timestamp, data in value_map.items():
|
||||
#reduce the endpoint data to single dictionary of dictionaries
|
||||
# reduce the endpoint data to single dictionary of dictionaries
|
||||
for datum in data["endpoint"]:
|
||||
for endpoint_data in datum.values():
|
||||
if debug:
|
||||
@@ -287,19 +291,19 @@ class L4CXProfile(LFCliBase):
|
||||
endpoint_data["Timestamp"] = test_timestamp
|
||||
full_test_data_list.append(endpoint_data)
|
||||
|
||||
|
||||
header_row.append("Timestamp")
|
||||
header_row.append('Timestamp milliseconds')
|
||||
df = pd.DataFrame(full_test_data_list)
|
||||
|
||||
df["Timestamp milliseconds"] = [self.get_milliseconds(x) for x in df["Timestamp"]]
|
||||
#round entire column
|
||||
df["Timestamp milliseconds"]=df["Timestamp milliseconds"].astype(int)
|
||||
df["Timestamp"]=df["Timestamp"].apply(lambda x:x.strftime("%m/%d/%Y %I:%M:%S"))
|
||||
df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]]
|
||||
#compare previous data to current data
|
||||
# round entire column
|
||||
df["Timestamp milliseconds"] = df["Timestamp milliseconds"].astype(int)
|
||||
df["Timestamp"] = df["Timestamp"].apply(lambda x: x.strftime("%m/%d/%Y %I:%M:%S"))
|
||||
df = df[["Timestamp", "Timestamp milliseconds", *header_row[:-2]]]
|
||||
# compare previous data to current data
|
||||
|
||||
systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text)
|
||||
systeminfo = ast.literal_eval(
|
||||
requests.get('http://' + str(self.lfclient_host) + ':' + str(self.lfclient_port)).text)
|
||||
|
||||
if output_format == 'hdf':
|
||||
df.to_hdf(report_file, 'table', append=True)
|
||||
@@ -312,7 +316,7 @@ class L4CXProfile(LFCliBase):
|
||||
df.to_excel(report_file, index=False)
|
||||
if output_format == 'df':
|
||||
return df
|
||||
supported_formats = ['csv', 'json', 'stata', 'pickle','html']
|
||||
supported_formats = ['csv', 'json', 'stata', 'pickle', 'html']
|
||||
for x in supported_formats:
|
||||
if output_format.lower() == x or report_file.split('.')[-1] == x:
|
||||
exec('df.to_' + x + '("'+report_file+'")')
|
||||
exec('df.to_' + x + '("' + report_file + '")')
|
||||
|
||||
Reference in New Issue
Block a user