Best Python code snippet using avocado_python
cpu.py
Source: cpu.py
...259 except IOError as err:260 logging.warning("Failed to read idle state on cpu %s "261 "for state %s:\n%s", cpu, state_no, err)262 return cpu_idlestate263def _bool_to_binary(value):264 """265 Turns a Python boolean value (True or False) into binary data.266 This function is suitable for writing to /proc/* and /sys/* files.267 """268 if value is True:269 return b'1'270 if value is False:271 return b'0'272 raise TypeError("Value is not a boolean: %s" % value)273def set_idle_state(state_number="all", disable=True, setstate=None):274 """275 Set/Reset cpu idle states for all cpus276 :param state_number: cpuidle state number, default: `all` all states277 :param disable: whether to disable/enable given cpu idle state,278 default is to disable (True). Must be a boolean value.279 :type disable: bool280 :param setstate: cpuidle state value, output of `get_idle_state()`281 """282 cpus_list = online_list()283 if not setstate:284 states = []285 if state_number == 'all':286 states = range(0, len(glob.glob("/sys/devices/system/cpu/cpu0/cpuidle/state*")))287 else:288 states.append(state_number)289 disable = _bool_to_binary(disable)290 for cpu in cpus_list:291 for state_no in states:292 state_file = "/sys/devices/system/cpu/cpu%s/cpuidle/state%s/disable" % (cpu, state_no)293 try:294 open(state_file, "wb").write(disable)295 except IOError as err:296 logging.warning("Failed to set idle state on cpu %s "297 "for state %s:\n%s", cpu, state_no, err)298 else:299 for cpu, stateval in setstate.items():300 for state_no, value in stateval.items():301 state_file = "/sys/devices/system/cpu/cpu%s/cpuidle/state%s/disable" % (cpu, state_no)302 disable = _bool_to_binary(value)303 try:304 open(state_file, "wb").write(disable)305 except IOError as err:306 logging.warning("Failed to set idle state on cpu %s "307 "for state %s:\n%s", cpu, state_no, err)308def set_freq_governor(governor="random"):309 """310 To change the given cpu frequency governor311 :param governor: frequency governor profile name whereas `random` is default312 option to choose random profile among available ones.313 """314 avl_gov_file = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors"315 cur_gov_file = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"316 cur_gov = get_freq_governor()...
capabilities.py
Source: capabilities.py
2import structlog3from raiden_common.constants import Capabilities4from raiden_common.settings import CapabilitiesConfig5log = structlog.get_logger(__name__)6def _bool_to_binary(value: Any) -> str:7 if isinstance(value, bool):8 return "1" if value is True else "0"9 return value10def int_bool(value: str) -> Union[bool, str]:11 try:12 if int(value) in {0, 1}:13 return bool(int(value))14 else:15 return value16 except ValueError:17 return value18def capdict_to_config(capdict: Dict[str, Any]) -> CapabilitiesConfig:19 config = CapabilitiesConfig(20 receive=capdict.get(Capabilities.RECEIVE.value, True),...
Check out the latest blogs from LambdaTest on this topic:
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.
JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.
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!!