Best Python code snippet using avocado_python
memory.py
Source:memory.py
...351 """352 thp_path = '/sys/kernel/mm/transparent_hugepage/'353 thp_feature_to_set = os.path.join(thp_path, feature)354 genio.write_file_or_fail(thp_feature_to_set, value)355def get_thp_value(feature):356 """357 Gets the value of the thp feature arg passed358 :Param feature: Thp feature to get value359 :type feature: str360 """361 thp_path = '/sys/kernel/mm/transparent_hugepage/'362 thp_feature_to_get = os.path.join(thp_path, feature)363 value = genio.read_file(thp_feature_to_get)364 if feature in ("enabled", "defrag", "shmem_enabled"):365 return (re.search(r"\[(\w+)\]", value)).group(1)366 else:367 return value368class _MemInfoItem:369 """...
thp_logger.py
Source:thp_logger.py
1#!/usr/bin/env python32# -*- coding: utf-8 -*-3import csv4VERSION="0.0.1"5def get_thp_value():6 try:7 with open('/dev/ttyACM0', 'r') as f:8 raw_data = f.readline()9 return raw_data.strip()[:-1].split(',')10 except FileNotFoundError:11 print('/dev/ttyACM0 not found')12 exit(-1)13if __name__ == '__main__':14 print('THP Logger version{}'.format(VERSION))15 j = 016 while(1):17 history = []18 for i in range(100):19 history.append(get_thp_value()) #timestamp, temp, humidity, pressure20 if (i % 10) == 0:21 print('{}, '.format(i), end='')22 for i in range(100):23 with open('log/log{:04}.csv'.format(j), 'a') as f:24 # f.write(str(history[i]))25 writer = csv.writer(f, lineterminator='\n')26 writer.writerow(history[i])27 # print(str(history[i]))28 j = j+1...
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!!