Best Python code snippet using molecule_python
images.py
Source: images.py
...17from sahara.utils.openstack import images as sahara_images18conductor = c.API19# Image Registry20def get_images(name, tags):21 return b.execute_with_retries(22 sahara_images.image_manager().list_registered, name, tags)23def get_image(**kwargs):24 if len(kwargs) == 1 and 'id' in kwargs:25 return b.execute_with_retries(26 sahara_images.image_manager().get, kwargs['id'])27 else:28 return b.execute_with_retries(29 sahara_images.image_manager().find, **kwargs)30def get_registered_image(id):31 return b.execute_with_retries(32 sahara_images.image_manager().get_registered_image, id)33def register_image(image_id, username, description=None):34 manager = sahara_images.image_manager()35 b.execute_with_retries(36 manager.set_image_info, image_id, username, description)37 return b.execute_with_retries(manager.get, image_id)38def unregister_image(image_id):39 manager = sahara_images.image_manager()40 b.execute_with_retries(manager.unset_image_info, image_id)41 return b.execute_with_retries(manager.get, image_id)42def get_image_tags(image_id):43 return b.execute_with_retries(44 sahara_images.image_manager().get, image_id).tags45def set_image_tags(image_id, tags):46 manager = sahara_images.image_manager()47 image_obj = b.execute_with_retries(manager.get, image_id)48 org_tags = frozenset(image_obj.tags)49 new_tags = frozenset(tags)50 to_add = list(new_tags - org_tags)51 to_remove = list(org_tags - new_tags)52 if to_add:53 b.execute_with_retries(manager.tag, image_id, to_add)54 if to_remove:55 b.execute_with_retries(manager.untag, image_id, to_remove)56 return b.execute_with_retries(manager.get, image_id)57def remove_image_tags(image_id):58 manager = sahara_images.image_manager()59 image_obj = b.execute_with_retries(manager.get, image_id)60 tags = image_obj.tags61 b.execute_with_retries(manager.untag, image_id, tags)...
base.py
Source: base.py
...15 try:16 sleep(1)17 logger.info("Running job '%s'", self.name)18 start = time()19 retries_left, result = self.execute_with_retries()20 end = time()21 self.notify_success(22 result=result,23 runtime=round(end - start),24 retries_left=retries_left,25 )26 except Exception as exc:27 logger.error("Error running job '%s': %s", self.name, str(exc))28 self.notify_failure(exc)29 def execute(self):30 raise NotImplementedError()31 def execute_with_retries(self, retries: int = MAX_RETRIES):32 try:33 return retries, self.execute()34 except Exception as exc:35 if retries:36 return self.execute_with_retries(retries - 1)37 raise exc38 def notify_success(self, result: str, runtime: int, retries_left: int):39 if not settings.SLACK_WEBHOOK_URL:40 return41 message = Message(42 text=f"{self.name} > finished successfully.",43 blocks=[44 Section(45 text=MarkdownText(46 text=f"*{self.name.upper()}* > finished successfully after {runtime} seconds. \n\n```{result}```",47 ),48 ),49 ],50 )...
actionqueue.py
Source: actionqueue.py
...23 """24 self._state_machine.transition_to_execute()25 for action in self._actions:26 self._executed_actions.append(action)27 self.execute_with_retries(action, lambda a: a.execute())28 self._state_machine.transition_to_execute_complete()29 def rollback(self):30 """Call rollback on executed actions."""31 self._state_machine.transition_to_rollback()32 for action in reversed(self._executed_actions):33 try:34 self.execute_with_retries(action, lambda a: a.rollback())35 except: # pylint: disable=bare-except36 pass # on exception, carry on with rollback of other steps37 self._state_machine.transition_to_rollback_complete()38 def execute_with_retries(self, action, f):39 """Execute function f with single argument action. Retry if40 ActionRetryException is raised.41 """42 # Run action until either it succeeds or throws an exception43 # that's not an ActionRetryException44 retry = True45 while retry:46 retry = False47 try:48 f(action)49 except ActionRetryException as ex: # other exceptions should bubble out50 retry = True...
Check out the latest blogs from LambdaTest on this topic:
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
Most test automation tools just do test execution automation. Without test design involved in the whole test automation process, the test cases remain ad hoc and detect only simple bugs. This solution is just automation without real testing. In addition, test execution automation is very inefficient.
I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!