How to use action_default method in autotest

Best Python code snippet using autotest_python

VirtualWatchdog.py

Source:VirtualWatchdog.py Github

copy

Full Screen

1#2# Copyright 2010 Red Hat, Inc.3# Cole Robinson <crobinso@redhat.com>4#5# This program is free software; you can redistribute it and/or modify6# it under the terms of the GNU General Public License as published by7# the Free Software Foundation; either version 2 of the License, or8# (at your option) any later version.9#10# This program is distributed in the hope that it will be useful,11# but WITHOUT ANY WARRANTY; without even the implied warranty of12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13# GNU General Public License for more details.14#15# You should have received a copy of the GNU General Public License16# along with this program; if not, write to the Free Software17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,18# MA 02110-1301 USA.19import VirtualDevice20from virtinst import _gettext as _21from XMLBuilderDomain import _xml_property22class VirtualWatchdog(VirtualDevice.VirtualDevice):23 _virtual_device_type = VirtualDevice.VirtualDevice.VIRTUAL_DEV_WATCHDOG24 MODEL_DEFAULT = "default"25 MODELS = [ "i6300esb", "ib700", MODEL_DEFAULT ]26 ACTION_DEFAULT = "default"27 ACTION_SHUTDOWN = "shutdown"28 ACTION_RESET = "reset"29 ACTION_POWEROFF = "poweroff"30 ACTION_PAUSE = "pause"31 ACTION_NONE = "none"32 ACTIONS = [ACTION_RESET, ACTION_SHUTDOWN,33 ACTION_POWEROFF, ACTION_PAUSE,34 ACTION_NONE, ACTION_DEFAULT]35 @staticmethod36 def get_action_desc(action):37 if action == VirtualWatchdog.ACTION_RESET:38 return _("Forcefully reset the guest")39 if action == VirtualWatchdog.ACTION_SHUTDOWN:40 return _("Gracefully shutdown the guest")41 if action == VirtualWatchdog.ACTION_POWEROFF:42 return _("Forcefully power off the guest")43 if action == VirtualWatchdog.ACTION_PAUSE:44 return _("Pause the guest")45 if action == VirtualWatchdog.ACTION_NONE:46 return _("No action")47 if action == VirtualWatchdog.ACTION_DEFAULT:48 return _("Hypervisor default")49 else:50 return action51 def __init__(self, conn, parsexml=None, parsexmlnode=None, caps=None):52 VirtualDevice.VirtualDevice.__init__(self, conn, parsexml,53 parsexmlnode, caps)54 self._model = None55 self._action = None56 if self._is_parse():57 return58 self.model = self.MODEL_DEFAULT59 self.action = self.ACTION_DEFAULT60 def get_model(self):61 return self._model62 def set_model(self, new_model):63 if type(new_model) != str:64 raise ValueError(_("'model' must be a string, "65 " was '%s'." % type(new_model)))66 if not self.MODELS.count(new_model):67 raise ValueError(_("Unsupported watchdog model '%s'" % new_model))68 self._model = new_model69 model = _xml_property(get_model, set_model,70 xpath="./@model")71 def get_action(self):72 return self._action73 def set_action(self, val):74 if val not in self.ACTIONS:75 raise ValueError("Unknown watchdog action '%s'." % val)76 self._action = val77 action = _xml_property(get_action, set_action,78 xpath="./@action")79 def _get_xml_config(self):80 model = self.model81 if model == self.MODEL_DEFAULT:82 model = "i6300esb"83 action = self.action84 if action == self.ACTION_DEFAULT:85 action = self.ACTION_RESET86 xml = " <watchdog model='%s'" % model87 if action:88 xml += " action='%s'" % action89 xml += "/>"...

Full Screen

Full Screen

devicewatchdog.py

Source:devicewatchdog.py Github

copy

Full Screen

1#2# Copyright 2010, 2013 Red Hat, Inc.3# Cole Robinson <crobinso@redhat.com>4#5# This program is free software; you can redistribute it and/or modify6# it under the terms of the GNU General Public License as published by7# the Free Software Foundation; either version 2 of the License, or8# (at your option) any later version.9#10# This program is distributed in the hope that it will be useful,11# but WITHOUT ANY WARRANTY; without even the implied warranty of12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13# GNU General Public License for more details.14#15# You should have received a copy of the GNU General Public License16# along with this program; if not, write to the Free Software17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,18# MA 02110-1301 USA.19from virtinst import VirtualDevice20from virtinst.xmlbuilder import XMLProperty21class VirtualWatchdog(VirtualDevice):22 virtual_device_type = VirtualDevice.VIRTUAL_DEV_WATCHDOG23 MODEL_I6300 = "i6300esb"24 MODEL_IB700 = "ib700"25 MODEL_DEFAULT = "default"26 MODELS = [MODEL_I6300, MODEL_IB700, MODEL_DEFAULT]27 ACTION_SHUTDOWN = "shutdown"28 ACTION_RESET = "reset"29 ACTION_POWEROFF = "poweroff"30 ACTION_PAUSE = "pause"31 ACTION_NONE = "none"32 ACTION_DUMP = "dump"33 ACTION_DEFAULT = "default"34 ACTIONS = [ACTION_RESET, ACTION_SHUTDOWN,35 ACTION_POWEROFF, ACTION_PAUSE,36 ACTION_NONE, ACTION_DUMP,37 ACTION_DEFAULT]38 @staticmethod39 def get_action_desc(action):40 if action == VirtualWatchdog.ACTION_RESET:41 return _("Forcefully reset the guest")42 if action == VirtualWatchdog.ACTION_SHUTDOWN:43 return _("Gracefully shutdown the guest")44 if action == VirtualWatchdog.ACTION_POWEROFF:45 return _("Forcefully power off the guest")46 if action == VirtualWatchdog.ACTION_PAUSE:47 return _("Pause the guest")48 if action == VirtualWatchdog.ACTION_NONE:49 return _("No action")50 if action == VirtualWatchdog.ACTION_DEFAULT:51 return _("Hypervisor default")52 return action53 _XML_PROP_ORDER = ["model", "action"]54 model = XMLProperty("./@model",55 default_name=MODEL_DEFAULT,56 default_cb=lambda s: s.MODEL_I6300)57 action = XMLProperty("./@action",58 default_name=ACTION_DEFAULT,59 default_cb=lambda s: s.ACTION_RESET)...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...12 user.arrows_count -= 113def action_move(user: User, maze: Maze) -> None:14 room_number = int(input('В какую комнату? : '))15 maze.user_move(room_number)16def action_default(user: User, maze: Maze) -> None:17 print('---\nНепонятно. Попробуем еще раз?')18actions_mapper = {19 ACTION_SHOOT: action_shoot,20 ACTION_MOVE: action_move,21 ACTION_DEFAULT: action_default,22}23def current_room_info(user: User, maze: Maze) -> str:24 res = f'---\nВы находитесь в комнате номер {user.current_room_number}.\n'25 creature_signs = maze.signs_in_current_room()26 if creature_signs:27 res += f'В соседних комнатах что-то происходит: \n'28 for sign in creature_signs:29 res += sign + "\n"30 res += f'Отсюда можно перейти в комнаты {", ".join([str(x) for x in maze.available_user_moves()])} \n'...

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