How to use _bool_to_binary method in avocado

Best Python code snippet using avocado_python

cpu.py

Source:cpu.py Github

copy

Full Screen

...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()...

Full Screen

Full Screen

capabilities.py

Source:capabilities.py Github

copy

Full Screen

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),...

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