From 37b44441a64516b8e209de466fbd586938cac889 Mon Sep 17 00:00:00 2001 From: Dipti Date: Wed, 3 Mar 2021 00:47:09 -0800 Subject: [PATCH] delete base_profile from realm.py, add updated logg function from logg in base_profile in realm.py to base_profile.py file Signed-off-by: Dipti --- py-json/base_profile.py | 33 ++++++++++++++------------- py-json/realm.py | 49 ----------------------------------------- 2 files changed, 16 insertions(+), 66 deletions(-) diff --git a/py-json/base_profile.py b/py-json/base_profile.py index 8406e008..f3e79bac 100644 --- a/py-json/base_profile.py +++ b/py-json/base_profile.py @@ -7,13 +7,14 @@ import csv import datetime import random import string +import pprint from pprint import pprint #from LANforge.lfcriteria import LFCriteria class BaseProfile: def __init__(self, local_realm, debug=False): self.parent_realm = local_realm - self.halt_on_error = False + #self.halt_on_error = False self.exit_on_error = False self.debug = debug or local_realm.debug self.profiles = [] @@ -55,36 +56,34 @@ class BaseProfile: def wait_until_cxs_appear(self, these_cx, debug=False): return self.parent_realm.wait_until_cxs_appear(these_cx, debug=False) - def logg(self, message=None): + def logg(self, message=None, audit_list=None): + if audit_list is None: + self.parent_realm.logg(message) + for item in audit_list: + message += ("\n" + pprint.pformat(item, indent=4)) self.parent_realm.logg(message) - - def replace_special_char(self, - str): + def replace_special_char(self, str): return str.replace('+', ' ').replace('_', ' ').strip(' ') - def get_milliseconds(self, - timestamp): + def get_milliseconds(self, timestamp): return (timestamp - datetime.datetime(1970,1,1)).total_seconds()*1000 - def get_seconds(self, - timestamp): + + def get_seconds(self, timestamp): return (timestamp - datetime.datetime(1970,1,1)).total_seconds() - def read_file(self, - filename): - #Convert file contents to a list + + def read_file(self, filename): filename = open(filename, 'r') return [line.split(',') for line in filename.readlines()] - def random_chars(self, - size, - chars=None): - #Create random characters made of letters + #Function to create random characters made of letters + def random_chars(self, size, chars=None): if chars is None: chars = string.ascii_letters return ''.join(random.choice(chars) for x in range(size)) - + #--------------- create file path / find file path code - to be put into functions # #Find file path to save data/csv to: # if args.report_file is None: # new_file_path = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-h-%M-m-%S-s")).replace(':', diff --git a/py-json/realm.py b/py-json/realm.py index f4d3cdb4..9fd9643a 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -926,55 +926,6 @@ class Realm(LFCliBase): # test_group_profile = test_group_profile2.TestGroupProfile2(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) return test_group_profile -class BaseProfile: - def __init__(self, local_realm, debug=False): - self.parent_realm = local_realm - # self.halt_on_error = False - self.exit_on_error = False - self.debug = debug or local_realm.debug - - def json_get(self, _req_url, debug_=False): - return self.parent_realm.json_get(_req_url, debug_=False) - - def json_post(self, req_url=None, data=None, debug_=False, suppress_related_commands_=None): - return self.parent_realm.json_post(_req_url=req_url, - _data=data, - suppress_related_commands_=suppress_related_commands_, - debug_=debug_) - - def parse_time(self, time_string): - return self.parent_realm.parse_time(time_string) - - def stopping_cx(self, name): - return self.parent_realm.stop_cx(name) - - def cleanup_cxe_prefix(self, prefix): - return self.parent_realm.cleanup_cxe_prefix(prefix) - - def rm_cx(self, cx_name): - return self.parent_realm.rm_cx(cx_name) - - def rm_endp(self, ename, debug_=False, suppress_related_commands_=True): - self.parent_realm.rm_endp(ename, debug_=False, suppress_related_commands_=True) - - def name_to_eid(self, eid): - return self.parent_realm.name_to_eid(eid) - - def set_endp_tos(self, ename, _tos, debug_=False, suppress_related_commands_=True): - return self.parent_realm.set_endp_tos(ename, _tos, debug_=False, suppress_related_commands_=True) - - def wait_until_endps_appear(self, these_endp, debug=False): - return self.parent_realm.wait_until_endps_appear(these_endp, debug=False) - - def wait_until_cxs_appear(self, these_cx, debug=False): - return self.parent_realm.wait_until_cxs_appear(these_cx, debug=False) - - def logg(self, message=None, audit_list=None): - if audit_list is None: - self.parent_realm.logg(message) - for item in audit_list: - message += ("\n" + pprint.pformat(item, indent=4)) - self.parent_realm.logg(message) class MULTICASTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm,