How to use _list_matches method in avocado

Best Python code snippet using avocado_python

msim.py

Source:msim.py Github

copy

Full Screen

...80 return81 proc.kill()82 proc.wait()83 raise Exception("Failed to start X server (no free display number?)")84 def _list_matches(self, actual, expected):85 size = len(actual)86 if size != len(expected):87 return False88 for i in range(size):89 if expected[i] is not None:90 if actual[i] != expected[i]:91 return False92 return True93 def _rewrite_configuration(self):94 out_lines = []95 with open(self.config, 'r') as inp:96 bootmem = None97 disk = None98 for line in inp.readlines():99 tok = line.split()100 if self._list_matches(tok, ['add', 'rom', None, '0x1fc00000']):101 bootmem = tok[2]102 if (bootmem is not None) and self._list_matches(tok, [bootmem, 'load', None]):103 tok[2] = '"{}"'.format(self.boot_image)104 if self._list_matches(tok, ['add', 'ddisk', None, '0x10000200', None]):105 disk = tok[2]106 if (disk is not None) and self._list_matches(tok, [disk, 'fmap', None]):107 if self.disk_image is None:108 tok = []109 else:110 tok[2] = '"{}"'.format(self.disk_image)111 out_lines.append(' '.join(tok))112 return out_lines113 def boot(self, **kwargs):114 self.screenshot_filename = self.get_temp('screenshot.png')115 self.screendump_file = self.get_temp('xterm.screendump')116 config_file = self.get_temp('rewr.msim.conf')117 with open(config_file, 'w') as f:118 config_lines = self._rewrite_configuration()119 for l in config_lines:120 print(l, file=f)...

Full Screen

Full Screen

cpu.py

Source:cpu.py Github

copy

Full Screen

...17"""18Get information from the current's machine CPU.19"""20import re21def _list_matches(lst, pattern):22 """23 True if any item in list matches the specified pattern.24 """25 compiled = re.compile(pattern)26 for element in lst:27 match = compiled.search(element)28 if match:29 return 130 return 031def _get_cpu_info():32 """33 Reads /proc/cpuinfo and returns a list of file lines34 :returns: `list` of lines from /proc/cpuinfo file35 :rtype: `list`36 """37 with open('/proc/cpuinfo', 'r') as f:38 cpuinfo = f.readlines()39 return cpuinfo40def cpu_has_flags(flags):41 """42 Check if a list of flags are available on current CPU info43 :param flags: A `list` of cpu flags that must exists on the current CPU.44 :type flags: `list`45 :returns: `bool` True if all the flags were found or False if not46 :rtype: `list`47 """48 cpu_info = _get_cpu_info()49 if not isinstance(flags, list):50 flags = [flags]51 for flag in flags:52 if not _list_matches(cpu_info, '.*%s.*' % flag):53 return False54 return True55def get_cpu_vendor_name():56 """57 Get the current cpu vendor name58 :returns: string 'intel' or 'amd' or 'power7' depending on the59 current CPU architecture.60 :rtype: `string`61 """62 vendors_map = {63 'intel': ("GenuineIntel", ),64 'amd': ("AMD", ),65 'power7': ("POWER7", )66 }67 cpu_info = _get_cpu_info()68 for vendor, identifiers in vendors_map.items():69 for identifier in identifiers:70 if _list_matches(cpu_info, identifier):71 return vendor72 return None73def get_cpu_arch():74 """75 Work out which CPU architecture we're running on76 """77 cpuinfo = _get_cpu_info()78 if _list_matches(cpuinfo, '^cpu.*(RS64|POWER3|Broadband Engine)'):79 return 'power'80 elif _list_matches(cpuinfo, '^cpu.*POWER4'):81 return 'power4'82 elif _list_matches(cpuinfo, '^cpu.*POWER5'):83 return 'power5'84 elif _list_matches(cpuinfo, '^cpu.*POWER6'):85 return 'power6'86 elif _list_matches(cpuinfo, '^cpu.*POWER7'):87 return 'power7'88 elif _list_matches(cpuinfo, '^cpu.*POWER8'):89 return 'power8'90 elif _list_matches(cpuinfo, '^cpu.*PPC970'):91 return 'power970'92 elif _list_matches(cpuinfo, 'ARM'):93 return 'arm'94 elif _list_matches(cpuinfo, '^flags.*:.* lm .*'):95 return 'x86_64'96 else:97 return 'i386'98def cpu_online_list():99 """100 Reports a list of indexes of the online cpus101 """102 cpus = []103 for line in open('/proc/cpuinfo', 'r'):104 if line.startswith('processor'):105 cpus.append(int(line.split()[2])) # grab cpu number...

Full Screen

Full Screen

uuid_engine.py

Source:uuid_engine.py Github

copy

Full Screen

1import re2import uuid3import json4def new_id(email):5 _uuid_string = str(uuid.uuid4())6 with open("uuid_list.json", 'r') as uuid_json:7 uuid_data = json.load(uuid_json)8 for val in uuid_data.values():9 if val == email:10 print(email+' is already in the uuid_list\n')11 return None12 uuid_data[_uuid_string] = email13 with open("uuid_list.json",'w') as uuid_json:14 json.dump(uuid_data,uuid_json,indent=4)15 return _uuid_string16def search_id(request_id):17 pattern = r'[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}'18 _list_matches = re.split(pattern,request_id)19 if _list_matches[0] != request_id:20 return False21 22 with open('uuid_list.json') as uuid_json:23 uuid_data = json.load(uuid_json)24 for _id in uuid_data.keys():25 if request_id == _id:26 email = uuid_data[_id]27 uuid_data.pop(_id)28 with open('uuid_list.json','w') as uuid_json:29 json.dump(uuid_data,uuid_json,indent=4)30 print(email)31 return email32 print("None")...

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