Best Python code snippet using lisa_python
state.py
Source:state.py
2 usersdb = cursor.execute('SELECT * FROM users').rowcount3 usersdb_count = cursor.fetchall()4 guildsdb = cursor.execute('SELECT * FROM guilds').rowcount5 guildsdb_count = cursor.fetchall()6 if cpuinfo.get_cpu_info()['count'] < 2:7 cores_amount = str(cpuinfo.get_cpu_info()['count']) + localization[1][1][9]8 elif cpuinfo.get_cpu_info()['count'] < 5:9 cores_amount = str(cpuinfo.get_cpu_info()['count']) + localization[1][1][10]10 else:11 cores_amount = str(cpuinfo.get_cpu_info()['count']) + localization[1][1][11]12 if psutil.virtual_memory().available < 1024:13 ram_available = str(round(psutil.virtual_memory().available / 1024, 2)) + localization[1][1][14] + localization[1][1][17]14 elif psutil.virtual_memory().available < 1048576 and psutil.virtual_memory().available >= 1024:15 ram_available = str(round(psutil.virtual_memory().available / 1024 / 1024, 2)) + localization[1][1][15] + localization[1][1][17]16 else:17 ram_available = str(round(psutil.virtual_memory().available / 1024 / 1024 / 1024, 2)) + localization[1][1][16] + localization[1][1][17]18 if psutil.virtual_memory().total < 1024:19 ram_total = str(round(psutil.virtual_memory().total / 1024, 2)) + localization[1][1][14]20 elif psutil.virtual_memory().total < 1048576 and psutil.virtual_memory().total >= 1024:21 ram_total = str(round(psutil.virtual_memory().total / 1024 / 1024, 2)) + localization[1][1][15]22 else:23 ram_total = str(round(psutil.virtual_memory().total / 1024 / 1024 / 1024, 2)) + localization[1][1][16]24 state_content = discord.Embed(title=str(localization[1][1][0]), description="**" + str(localization[1][1][1]) + ":** " + str(round(bot.latency * 1000, 2)) + str(localization[1][1][2]), color=embed_color)25 state_content.add_field(name=str(localization[1][1][3]), value=platform.uname()[0] + " " + platform.uname()[2] + " (" + platform.uname()[3] + ")", inline=False)26 state_content.add_field(name=str(localization[1][1][4]), value=str(cpuinfo.get_cpu_info()['brand_raw']) + " (" + cores_amount + ", " + str(round(cpuinfo.get_cpu_info()['hz_advertised'][0] / 1000000, 2)) + localization[1][1][12] + ")", inline=False)27 state_content.add_field(name=str(localization[1][1][13]), value=ram_available + " / " + ram_total, inline=True)28 state_content.add_field(name=str(localization[1][1][5]), value=platform.python_version(), inline=True)29 state_content.add_field(name=str(localization[1][1][6]), value=platform.python_build()[1], inline=True)30 state_content.add_field(name=str(localization[1][1][7]), value="**discord.py:** " + discord.__version__ + "\n**SQLite3 library:** " + sqlite3.sqlite_version + "\n**Vision bot:** " + botconfig['version'], inline=True)31 state_content.add_field(name=str(localization[1][1][8]), value="ð " + str(len(bot.guilds)) + " | ð¥ " + str(len(bot.users)) + " | ð " + str(len(usersdb_count) + len(guildsdb_count)), inline=True)...
cpuinfo.py
Source:cpuinfo.py
...3# 4# © Takeyuki UEDA 2017 - 5import subprocess6# import re7def get_cpu_info(param_str):8 command_str = "vcgencmd " + param_str9 p = subprocess.Popen(command_str, stdout=subprocess.PIPE, shell=True)10# match = re.match('([0-9,.]*).*', p.stdout.readline().strip().split('=')[1])11# return match.group(1)12 return p.stdout.readline().strip().split('=')[1]13def temp():14 return get_cpu_info("measure_temp")15def clock_arm():16 return get_cpu_info("measure_clock arm")17def clock_core():18 return get_cpu_info("measure_clock core")19def clock_uart():20 return get_cpu_info("measure_clock uart")21def codec_enabled_H264():22 return get_cpu_info("codec_enabled H264")23def codec_enabled_MPG2():24 return get_cpu_info("codec_enabled MPG2")25def codec_enabled_WVC1():26 return get_cpu_info("codec_enabled WVC1")27def mem_usage_arm():28 return get_cpu_info("get_mem arm")29def mem_usage_gpu():30 return get_cpu_info("get_mem gpu")31if __name__ == '__main__':32 print "temp = {}".format(temp())33 print "clock frequency of arm = {}".format(clock_arm())34 print "clock frequency of core = {}".format(clock_core())35 print "clock frequency of uart = {}".format(clock_uart())36 print "codec enabled of H264 = {}".format(codec_enabled_H264())37 print "codec enabled of MPG2 = {}".format(codec_enabled_MPG2())38 print "codec enabled of WVC1 = {}".format(codec_enabled_WVC1())39 print "memory usage of arm = {}".format(mem_usage_arm())...
cpu.py
Source:cpu.py
2import cpuinfo3import subprocess4from flask import jsonify5def get_proc_model():6 cpu = cpuinfo.get_cpu_info()7 cpu_model = {"model": cpu['model']}8 return jsonify(cpu_model)9def get_proc_cache(level):10 if level == "l2":11 cach = cpuinfo.get_cpu_info()['l2_cache_size']12 cach_cpu = {"l2": cache}13 return jsonify(cache_info)14 if level == "l3":15 cach = cpuinfo.get_cpu_info()['l3_cache_size']16 cach_cpu = {"l3": cache}17 return jsonify(cach_cpu)18 else:19 cach_cpu = {"l2": cpuinfo.get_cpu_info()['l2_cache_size'],20 "l3": cpuinfo.get_cpu_info()['l3_cache_size']}...
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!!