Best Python code snippet using autotest_python
VirtualWatchdog.py
Source: VirtualWatchdog.py
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 += "/>"...
devicewatchdog.py
Source: devicewatchdog.py
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)...
main.py
Source: main.py
...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'...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!