How to use __save_metadata method in webdriver_manager

Best Python code snippet using webdriver_manager

driver_cache.py

Source:driver_cache.py Github

copy

Full Screen

...21 archive = save_file(file, path)22 files = archive.unpack(path)23 binary = self.__get_binary(files, driver_name)24 binary_path = os.path.join(path, binary)25 self.__save_metadata(browser_version, driver_name, os_type, driver_version, binary_path)26 log(f"Driver has been saved in cache [{path}]")27 return binary_path28 def __get_binary(self, files, driver_name):29 if len(files) == 1:30 return files[0]31 for f in files:32 if driver_name in f:33 return f34 raise Exception(f"Can't find binary for {driver_name} among {files}")35 def __save_metadata(self, browser_version, driver_name, os_type, driver_version, binary_path,36 date=None):37 if date is None:38 date = datetime.date.today()39 metadata = self.get_metadata()40 key = f"{os_type}_{driver_name}_{driver_version}_for_{browser_version}"41 data = {42 key: {43 "timestamp": date.strftime(self._date_format),44 "binary_path": binary_path45 }46 }47 metadata.update(data)48 with open(self._drivers_json_path, 'w+') as outfile:49 json.dump(metadata, outfile, indent=4)...

Full Screen

Full Screen

frame_list__.py

Source:frame_list__.py Github

copy

Full Screen

...17 def __get_metadata(self, filepath) -> dict:18 with open(self.__get_json_filepath(filepath)) as file:19 return json.load(file)20 21 def __save_metadata(self, frame:Frame) -> None:22 json_filepath = self.__get_json_filepath(frame.filepath)23 with open(json_filepath,'w') as f:24 json.dump(frame.metadata, f)25 def __remove_metadata(self, filepath) -> None:26 os.remove(self.__get_json_filepath(filepath))27 def __len__(self) -> int:28 return len(self.__filepathlist)29 def __getitem__(self, ii) -> Frame:30 filepath = self.__filepathlist[ii]31 metadata = self.__get_metadata(filepath)32 frame_arr = img_to_array(load_img(filepath), dtype='uint8')33 return Frame(frame_arr=frame_arr, metadata=metadata, filepath=filepath)34 def __delitem__(self, ii) -> None:35 filepath = self.__filepathlist[ii]36 #remove jpg imgage37 os.remove(filepath)38 #remove json imgage data39 self.__remove_metadata(filepath)40 del self.__filepathlist[ii]41 def __setitem__(self, ii, frame:Frame) -> None:42 #use it to update only metadata43 if self.__filepathlist[ii] == frame.filepath:44 self.__save_metadata(frame)45 else:46 raise NameError('Error in FrameList.__setitem__')47 def append(self, frame:Frame) -> None:48 frame.filepath = os.path.join(self.__pathdir, '%s.jpg'%int(time.time()))49 self.__filepathlist.append(frame.filepath)50 self.__save_metadata(frame)51 img = img_to_array(frame.original)52 save_img(frame.filepath, img)53 def insert(self, index: int, frame: Frame) -> None:54 frame.filepath = os.path.join(self.__pathdir, '%s.jpg'%int(time.time()))55 self.__filepathlist.insert(index, frame.filepath)56 self.__save_metadata(frame)57 img = img_to_array(frame.original)58 save_img(frame.filepath, img)59 60 def remove(self, frame: Frame) -> None:61 i = self.index(frame)62 self.__delitem__(i)63 def index(self, frame: Frame) -> int:64 for i in range(len(self.__filepathlist)):65 if self.__filepathlist[i] == frame.filepath:66 return i67 else:...

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 webdriver_manager 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