How to use __get_timestamp method in SeleniumBase

Best Python code snippet using SeleniumBase

fluentd.py

Source:fluentd.py Github

copy

Full Screen

...47 '''48 # reset counters49 self.__warning_counter = 050 self.__error_counter = 051 self.runlogdate = self.__get_timestamp()52 # send start record53 self.__send_start_record()54 def emit(self, record):55 data = {56 "loglevel": record.levelname,57 "message": self.formatter.format(record),58 "@timestamp": self.__get_timestamp()59 }60 # if runlogdate is 0, it's a log from server (not an nfvbench run) so do not send runlogdate61 if self.runlogdate != 0:62 data["runlogdate"] = self.runlogdate63 self.__update_stats(record.levelno)64 for log_sender in self.log_senders:65 log_sender.emit(None, data)66 # this function is called by summarizer, and used for sending results67 def record_send(self, record):68 for result_sender in self.result_senders:69 result_sender.emit(None, record)70 # send START log record for each run71 def __send_start_record(self):72 data = {73 "runlogdate": self.runlogdate,74 "loglevel": "START",75 "message": "NFVBENCH run is started",76 "numloglevel": 0,77 "numerrors": 0,78 "numwarnings": 0,79 "@timestamp": self.__get_timestamp()80 }81 for log_sender in self.log_senders:82 log_sender.emit(None, data)83 # send stats related to the current run and reset state for a new run84 def send_run_summary(self, run_summary_required):85 if run_summary_required or self.__get_highest_level() == logging.ERROR:86 data = {87 "loglevel": "RUN_SUMMARY",88 "message": self.__get_highest_level_desc(),89 "numloglevel": self.__get_highest_level(),90 "numerrors": self.__error_counter,91 "numwarnings": self.__warning_counter,92 "@timestamp": self.__get_timestamp()93 }94 # if runlogdate is 0, it's a log from server (not an nfvbench run)95 # so don't send runlogdate96 if self.runlogdate != 0:97 data["runlogdate"] = self.runlogdate98 for log_sender in self.log_senders:99 log_sender.emit(None, data)100 def __get_highest_level(self):101 if self.__error_counter > 0:102 return logging.ERROR103 elif self.__warning_counter > 0:104 return logging.WARNING105 return logging.INFO106 def __get_highest_level_desc(self):107 highest_level = self.__get_highest_level()108 if highest_level == logging.INFO:109 return "GOOD RUN"110 elif highest_level == logging.WARNING:111 return "RUN WITH WARNINGS"112 return "RUN WITH ERRORS"113 def __update_stats(self, levelno):114 if levelno == logging.WARNING:115 self.__warning_counter += 1116 elif levelno == logging.ERROR:117 self.__error_counter += 1118 def __get_timestamp(self):119 return datetime.utcnow().replace(tzinfo=pytz.utc).strftime(...

Full Screen

Full Screen

serialize.py

Source:serialize.py Github

copy

Full Screen

...12 if model is None or modelclass is None or path is None:13 raise RuntimeError("model, class name or path can not be empty")14 if not os.path.exists(path):15 os.makedirs(path)16 timestamp = __get_timestamp()17 save_name = modelclass + '_' + timestamp + '.pt'18 save_path = os.path.join(path, save_name)19 torch.save(model.state_dict(), save_path)20 return save_path2122def load_module(model, path):23 model.load_state_dict(torch.load(path))24 model.eval()25 return model2627def save_results(results, modelclass, path):28 if not os.path.exists(path):29 os.makedirs(path)30 save_name = modelclass + '_' + __get_timestamp() + '.csv'31 save_path = os.path.join(path, save_name)32 with open(save_path, 'w', newline='') as f:33 writer = csv.writer(f)34 writer.writerows(results)35 return save_path3637def load_results(path):38 results = []39 with open(path, newline='') as f:40 reader = csv.reader(f)41 for result in reader:42 results.append(result)43 return results4445def get_all_results_names():46 # Config parser47 config = configparser.ConfigParser()48 config.read('config.ini')49 config = config['DEFAULT']50 save_path = config['output']51 result_folder = config['results']52 save_path_results = os.path.join(save_path)53 result_list = helper.get_all_files(save_path_results)54 result_list = [x for x in result_list if 'results' in x]55 result_list = [x for x in result_list if '.directory' not in x]56 return result_list5758def __get_timestamp():59 now = datetime.now()60 timestamp = now.strftime("%Y_%m_%d_%H_%M_%S")61 return timestamp6263def exportcsv(dicthitormiss, modelclass, path):64 if not os.path.exists(path):65 os.makedirs(path)66 fname = modelclass + '_' + __get_timestamp() + '.csv'67 save_path = os.path.join(path, fname)68 fieldnames = ['id', 'category']69 with open(save_path, 'w', newline='') as f:70 writer = csv.DictWriter(f, delimiter=',', fieldnames=fieldnames)71 writer.writeheader()72 for key, value in dicthitormiss.items():73 writer.writerow({'id': key, 'category': value}) ...

Full Screen

Full Screen

utils.py

Source:utils.py Github

copy

Full Screen

1import math2from datetime import datetime3from typing import Dict, Any4def __get_timestamp(datetime_str: str) -> float:5 datetime_obj = datetime.fromisoformat(datetime_str)6 return datetime_obj.timestamp()7def get_timestamp(datetime_str: str) -> float:8 return __get_timestamp(datetime_str[:-1])9def get_time_from_data(frame_data: Dict[str, Any]) -> float:10 datetime_str = frame_data['rfc460Timestamp'][:-1]11 return __get_timestamp(datetime_str)12def get_iso_time(timestamp: float, normalised: bool = True) -> str:13 if normalised:14 timestamp = math.floor(timestamp / 10) * 1015 datetime_str = datetime.fromtimestamp(timestamp).isoformat()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful