Best Python code snippet using yandex-tank
graph_as923.py
Source:graph_as923.py
...3from __future__ import print_function4import sys5import matplotlib.pyplot as plt6from lorawan_toa import *7def get_line(list_size, n_sf, bw=125):8 return [ get_toa(i, n_sf, n_bw=bw)["t_packet"] for i in list_size ]9#########10#11fig = plt.figure(num=None, figsize=(16, 8), facecolor='w', edgecolor='k')12ax = fig.add_subplot(1,1,1)13ax.set_title("SF and ToA (BW=125 kHz)")14x = range(0, 255)15ax.plot(x, get_line(x, 12), "b-", label="SF12", linewidth=3, alpha=1)16ax.plot(x, get_line(x, 11), "g-", label="SF11", linewidth=3, alpha=1)17ax.plot(x, get_line(x, 10), "k-", label="SF10", linewidth=3, alpha=1)18ax.plot(x, get_line(x, 9), "c-", label="SF9", linewidth=3, alpha=1)19ax.plot(x, get_line(x, 8), "m-", label="SF8", linewidth=3, alpha=1)20ax.plot(x, get_line(x, 7), "y-", label="SF7", linewidth=3, alpha=1)21ax.set_xlim(0, 260)22ax.set_ylim(0, 5000)23ax.set_xlabel("PHY Payload Size (Byte)")24ax.set_ylabel("Time on Air (ms)")25ax.grid(True)26ax.legend(loc="upper left", fancybox=True, shadow=True)27fig.tight_layout()28plt.show()29fig.savefig("image/lora-toa-125.png")30#########31#32fig = plt.figure(num=None, figsize=(16, 8), facecolor='w', edgecolor='k')33ax = fig.add_subplot(1,1,1)34ax.set_title("AS923 No DwellTime")35x = range(0, 255)36ax.plot(x, get_line(x, 12), "b-", linewidth=3, alpha=0.05)37ax.plot(x, get_line(x, 11), "g-", linewidth=3, alpha=0.05)38ax.plot(x, get_line(x, 10), "k-", linewidth=3, alpha=0.05)39ax.plot(x, get_line(x, 9), "c-", linewidth=3, alpha=0.05)40ax.plot(x, get_line(x, 8), "m-", linewidth=3, alpha=0.05)41ax.plot(x, get_line(x, 7), "y-", linewidth=3, alpha=0.05)42# no dwellTime consideration43ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 12), "b-", label="SF12",44 linewidth=3, alpha=1)45ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 11), "g-", label="SF11",46 linewidth=3, alpha=1)47ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 10), "k-", label="SF10",48 linewidth=3, alpha=1)49ax.plot(mpsrange(8, 123), get_line(mpsrange(8, 123), 9), "c-", label="SF9",50 linewidth=3, alpha=1)51ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 8), "m-", label="SF8",52 linewidth=3, alpha=1)53ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 7), "y-", label="SF7",54 linewidth=3, alpha=1)55ax.set_xlim(0, 260)56ax.set_ylim(0, 5000)57ax.set_xlabel("PHY Payload Size (Byte)")58ax.set_ylabel("Time on Air (ms)")59ax.grid(True)60ax.legend(loc="upper left", fancybox=True, shadow=True)61fig.tight_layout()62plt.show()63fig.savefig("image/as923-without-dwelltime.png")64#########65#66fig = plt.figure(num=None, figsize=(16, 8), facecolor='w', edgecolor='k')67ax = fig.add_subplot(1,1,1)68ax.set_title("AS923 DwellTime 400ms")69x = range(0, 255)70ax.plot(x, get_line(x, 12), "b-", linewidth=3, alpha=0.05)71ax.plot(x, get_line(x, 11), "g-", linewidth=3, alpha=0.05)72ax.plot(x, get_line(x, 10), "k-", linewidth=3, alpha=0.05)73ax.plot(x, get_line(x, 9), "c-", linewidth=3, alpha=0.05)74ax.plot(x, get_line(x, 8), "m-", linewidth=3, alpha=0.05)75ax.plot(x, get_line(x, 7), "y-", linewidth=3, alpha=0.05)76# required dwellTime consideration77ax.plot([0], [0], "b-", label="SF12", linewidth=3, alpha=1)78ax.plot([0], [0], "c-", label="SF11", linewidth=3, alpha=1)79ax.plot(mpsrange(8, 19), get_line(mpsrange(8, 19), 10), "k-", label="SF10", linewidth=3, alpha=1)80ax.plot(mpsrange(8, 61), get_line(mpsrange(8, 61), 9), "c-", label="SF9", linewidth=3, alpha=1)81ax.plot(mpsrange(8, 133), get_line(mpsrange(8, 133), 8), "m-", label="SF8", linewidth=3, alpha=1)82ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 7), "y-", label="SF7", linewidth=3, alpha=1)83ax.plot(x, [400 for i in range(0, 255)], "r,", linewidth=1, alpha=0.7)84ax.set_xlim(0, 260)85ax.set_ylim(0, 5000)86ax.set_xlabel("PHY Payload Size (Byte)")87ax.set_ylabel("Time on Air (ms)")88ax.grid(True)89ax.legend(loc="upper left", fancybox=True, shadow=True)90fig.tight_layout()91plt.show()92fig.savefig("image/as923-with-dwelltime.png")93#########94#95fig = plt.figure(num=None, figsize=(16, 8), facecolor='w', edgecolor='k')96ax = fig.add_subplot(1,1,1)97ax.set_title("AS923")98x = range(0, 255)99ax.plot(x, get_line(x, 12), "b-", linewidth=3, alpha=0.05)100ax.plot(x, get_line(x, 11), "g-", linewidth=3, alpha=0.05)101ax.plot(x, get_line(x, 10), "k-", linewidth=3, alpha=0.05)102ax.plot(x, get_line(x, 9), "c-", linewidth=3, alpha=0.05)103ax.plot(x, get_line(x, 8), "m-", linewidth=3, alpha=0.05)104ax.plot(x, get_line(x, 7), "y-", linewidth=3, alpha=0.05)105# no dwellTime consideration106ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 12), "b-", linewidth=1.2, alpha=0.7)107ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 11), "g-", linewidth=1.2, alpha=0.7)108ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 10), "k-", linewidth=1.2, alpha=0.7)109ax.plot(mpsrange(8, 123), get_line(mpsrange(8, 123), 9), "c-", linewidth=1.2, alpha=0.7)110ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 8), "m-", linewidth=1.2, alpha=0.7)111ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 7), "y-", linewidth=1.2, alpha=0.7)112# required dwellTime consideration113ax.plot([0], [0], "b-", label="SF12/125kHz", linewidth=3, alpha=1)114ax.plot([0], [0], "g-", label="SF11/125kHz", linewidth=3, alpha=1)115ax.plot(mpsrange(8, 19), get_line(mpsrange(8, 19), 10), "k-",116 label="SF10/125kHz", linewidth=3, alpha=1)117ax.plot(mpsrange(8, 61), get_line(mpsrange(8, 61), 9), "c-",118 label="SF9/125kHz", linewidth=3, alpha=1)119ax.plot(mpsrange(8, 133), get_line(mpsrange(8, 133), 8), "m-",120 label="SF8/125kHz", linewidth=3, alpha=1)121ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 7), "y-",122 label="SF7/125kHz", linewidth=3, alpha=1)123ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 7, bw=250), "b--",124 label="SF7/250kHz", linewidth=3, alpha=0.5)125ax.set_xlim(0, 260)126ax.set_ylim(0, 5000)127ax.set_xlabel("PHY Payload Size (Byte)")128ax.set_ylabel("Time on Air (ms)")129ax.grid(True)130ax.legend(loc="upper left", fancybox=True, shadow=True)131fig.tight_layout()132plt.show()133fig.savefig("image/as923-toa.png")134#########135#136fig = plt.figure(num=None, figsize=(16, 8), facecolor='w', edgecolor='k')137ax = fig.add_subplot(1,1,1)138ax.set_title("AS923 and ARIB STD-T108")139x = range(0, 255)140ax.plot(x, get_line(x, 12), "b-", linewidth=3, alpha=0.05)141ax.plot(x, get_line(x, 11), "g-", linewidth=3, alpha=0.05)142ax.plot(x, get_line(x, 10), "k-", linewidth=3, alpha=0.05)143ax.plot(x, get_line(x, 9), "c-", linewidth=3, alpha=0.05)144ax.plot(x, get_line(x, 8), "m-", linewidth=3, alpha=0.05)145ax.plot(x, get_line(x, 7), "y-", linewidth=3, alpha=0.05)146# no dwellTime consideration147ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 12), "b-", linewidth=1.2, alpha=0.7)148ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 11), "g-", linewidth=1.2, alpha=0.7)149ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 10), "k-", linewidth=1.2, alpha=0.7)150ax.plot(mpsrange(8, 123), get_line(mpsrange(8, 123), 9), "c-", linewidth=1.2, alpha=0.7)151ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 8), "m-", linewidth=1.2, alpha=0.7)152ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 7), "y-", linewidth=1.2, alpha=0.7)153# required dwellTime consideration154ax.plot([0], [0], "b-", label="SF12/125kHz", linewidth=3, alpha=1)155ax.plot([0], [0], "g-", label="SF11/125kHz", linewidth=3, alpha=1)156ax.plot(mpsrange(8, 19), get_line(mpsrange(8, 19), 10), "k-",157 label="SF10/125kHz", linewidth=3, alpha=1)158ax.plot(mpsrange(8, 61), get_line(mpsrange(8, 61), 9), "c-",159 label="SF9/125kHz", linewidth=3, alpha=1)160ax.plot(mpsrange(8, 133), get_line(mpsrange(8, 133), 8), "m-",161 label="SF8/125kHz", linewidth=3, alpha=1)162ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 7), "y-",163 label="SF7/125kHz", linewidth=3, alpha=1)164ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 7, bw=250), "b--",165 label="SF7/250kHz", linewidth=3, alpha=0.5)166ax.plot(x, [400 for i in range(0, 255)], "r--", linewidth=2, alpha=0.7)167ax.plot(x, [200 for i in range(0, 255)], "r--", linewidth=2, alpha=0.7)168ax.plot(x, [4000 for i in range(0, 255)], "r--", linewidth=2, alpha=0.7)169ax.set_xlim(0, 260)170ax.set_ylim(0, 5000)171ax.set_xlabel("PHY Payload Size (Byte)")172ax.set_ylabel("Time on Air (ms)")173ax.grid(True)174ax.legend(loc="upper left", fancybox=True, shadow=True)175fig.tight_layout()176plt.show()177fig.savefig("image/as923-with-arib180.png")178#########179#180fig = plt.figure(num=None, figsize=(16, 8), facecolor='w', edgecolor='k')181ax = fig.add_subplot(1,1,1)182ax.set_title("AS923 vs Others (SF12)")183x = range(0, 255)184ax.plot(x, get_line(x, 12), "b-", linewidth=3, alpha=0.05)185ax.plot(x, get_line(x, 12, bw=500), "r-", linewidth=3, alpha=0.05)186# no dwellTime consideration187ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 12), "b-",188 label="SF12/125kHz", linewidth=3.0, alpha=1)189# LoRa: SF12 / 500 kHz190ax.plot(mpsrange(8, 61), get_line(mpsrange(8, 61), 12, bw=500), "r-",191 label="SF12/500kHz", linewidth=3, alpha=1)192ax.set_xlim(0, 260)193ax.set_ylim(0, 5000)194ax.set_xlabel("PHY Payload Size (Byte)")195ax.set_ylabel("Time on Air (ms)")196ax.grid(True)197ax.legend(loc="best", fancybox=True, shadow=True)198fig.tight_layout()199plt.show()200fig.savefig("image/as923-vs-others-sf12.png")201#########202#203fig = plt.figure(num=None, figsize=(16, 8), facecolor='w', edgecolor='k')204ax = fig.add_subplot(1,1,1)205ax.set_title("AS923 vs Others (SF10)")206x = range(0, 255)207ax.plot(x, get_line(x, 10), "b-", linewidth=3, alpha=0.05)208ax.plot(x, get_line(x, 10, bw=500), "r-", linewidth=3, alpha=0.05)209# no dwellTime consideration210ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 10), "b-",211 label="SF10/125kHz", linewidth=3.0, alpha=1)212# LoRa: SF10 / 500 kHz213ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 10, bw=500), "r-",214 label="SF10/500kHz", linewidth=3, alpha=1)215ax.set_xlim(0, 260)216ax.set_ylim(0, 5000)217ax.set_xlabel("PHY Payload Size (Byte)")218ax.set_ylabel("Time on Air (ms)")219ax.grid(True)220ax.legend(loc="best", fancybox=True, shadow=True)221fig.tight_layout()222plt.show()223fig.savefig("image/as923-vs-others-sf10.png")224#########225#226fig = plt.figure(num=None, figsize=(16, 8), facecolor='w', edgecolor='k')227ax = fig.add_subplot(1,1,1)228ax.set_title("LoRaWAN")229x = range(0, 255)230ax.plot(x, get_line(x, 12), "b-", linewidth=3, alpha=0.05)231ax.plot(x, get_line(x, 11), "g-", linewidth=3, alpha=0.05)232ax.plot(x, get_line(x, 10), "k-", linewidth=3, alpha=0.05)233ax.plot(x, get_line(x, 9), "c-", linewidth=3, alpha=0.05)234ax.plot(x, get_line(x, 8), "m-", linewidth=3, alpha=0.05)235ax.plot(x, get_line(x, 7), "y-", linewidth=3, alpha=0.05)236# SF BW bit rate Max. MACPayload237# 12 125 250 59238# 11 125 440 59239# 10 125 980 59240# 9 125 1760 123241# 8 125 3125 250242# 7 125 5470 250243ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 12), "b-",244 label="SF12/125kHz", linewidth=2.0)245ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 11), "g-",246 label="SF11/125kHz", linewidth=2.0)247ax.plot(mpsrange(8, 59), get_line(mpsrange(8, 59), 10), "k-",248 label="SF10/125kHz", linewidth=2.0)249ax.plot(mpsrange(8, 123), get_line(mpsrange(8, 123), 9), "c-",250 label="SF9/125kHz", linewidth=2.0)251ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 8), "m-",252 label="SF8/125kHz", linewidth=2.0)253ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 7), "y-",254 label="SF7/125kHz", linewidth=2.0)255# SF BW bit rate Max. MACPayload256# 7 250 11000 250257ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 7, bw=250), "b-.",258 label="SF7/250kHz", linewidth=2.0)259# SF BW bit rate Max. MACPayload260# 12 500 980 61261# 11 500 1760 137262# 10 500 3900 250263# 9 500 7000 250264# 8 500 12500 250265# 7 500 21900 250266ax.plot(mpsrange(8, 61), get_line(mpsrange(8, 61), 12, bw=500), "b--",267 label="SF12/500kHz", linewidth=2.0)268ax.plot(mpsrange(8, 137), get_line(mpsrange(8, 137), 11, bw=500), "g--",269 label="SF11/500kHz", linewidth=2.0)270ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 10, bw=500), "k--",271 label="SF10/500kHz", linewidth=2.0)272ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 9, bw=500), "c--",273 label="SF9/500kHz", linewidth=2.0)274ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 8, bw=500), "m--",275 label="SF8/500kHz", linewidth=2.0)276ax.plot(mpsrange(8, 250), get_line(mpsrange(8, 250), 7, bw=500), "y--",277 label="SF7/500kHz", linewidth=2.0)278ax.set_xlim(0, 260)279ax.set_ylim(0, 5000)280ax.set_xlabel("PHY Payload Size (Byte)")281ax.set_ylabel("Time on Air (ms)")282ax.grid(True)283ax.legend(loc="upper right", fancybox=True, shadow=True)284fig.tight_layout()285plt.show()...
help.py
Source:help.py
...3 system("clear")4 system("echo '" + gc.term.normal \5 + gc.term.green("Launch Arguments: \n") + gc.term.red \6 + "--------------------------------------------- \n" \7 + get_line(gc, "--copy-skeleton", " --- ", "copies template settings") \8 + gc.term.cyan("This file can be found at ~/.config/socie/config \n") \9 + "\n"10 + get_line(gc, "--store-token", " --- ", "stores your token") \11 + gc.term.cyan("This file can be found at ~/.config/socie/token \n") \12 + "\n"13 + get_line(gc, "--config", " --- ", "specify a specific config path") \14 + "\n"15 + gc.term.green("Available Commands: \n") + gc.term.red \16 + "--------------------------------------------- \n" \17 + get_line(gc, "/channel", " - ", "switch to channel - (alias: 'c')") \18 + get_line(gc, "/server", " - ", "switch server - (alias: 's')") \19 + gc.term.cyan + "Note: these commands can now fuzzy-find! \n" \20 + "\n" \21 + get_line(gc, "/servers", " - ", "list available servers") \22 + get_line(gc, "/channels", " - ", "list available channels") \23 + get_line(gc, "/users", " - ", "list servers users") \24 + get_line(gc, "/emojis", " - ", "list servers custom emojis") \25 + "\n" \26 + get_line(gc, "/nick", " - ", "change server nick name") \27 + get_line(gc, "/game", " - ", "change your game status") \28 + get_line(gc, "/file", " - ", "upload a file via path") \29 + get_line(gc, "/status", " - ", "change online presence") \30 + gc.term.cyan + "This can be either 'online', 'offline', 'away', or 'dnd' \n" \31 + gc.term.cyan + "(dnd = do not disturb) \n" \32 + "\n" \33 + get_line(gc, "/cX", " - ", "shorthand to change channel (Ex: /c1)") \34 + gc.term.cyan("This can be configured to start at 0 in your config") \35 + "\n" \36 + "\n" \37 + get_line(gc, "/quit", " - ", "exit cleanly") \38 + "\n \n" \39 + gc.term.magenta + "Note: You can send emojis by using :emojiname: \n" \40 + gc.term.cyan("Nitro emojis do work! Make sure you have \n") \41 + gc.term.cyan("nitro enabled in your config. \n") \42 + "\n"43 + gc.term.yellow + "You can scroll up/down in channel logs \n" \44 + gc.term.yellow + "by using PageUp/PageDown. \n" \45 + gc.term.green + "~ \n" \46 + gc.term.green + "~ \n" \47 + gc.term.green + "~ \n" \48 + gc.term.green + "(press q to quit this dialog)" \49 + "' | less -R")50def get_line(gc, command, div, desc):...
header.py
Source:header.py
...5 def parse_header(self, rom_bytes):6 header_lines = []7 header_lines.append(f".section .data\n")8 header_lines.append(9 self.get_line("ascii", rom_bytes[0x00:0x08], "Magic number")10 )11 header_lines.append(self.get_line("word", rom_bytes[0x08:0x0C], "Zerofilled"))12 header_lines.append(self.get_line("word", rom_bytes[0x0C:0x10], "Zerofilled"))13 header_lines.append(14 self.get_line("word", rom_bytes[0x10:0x14][::-1], "Initial PC")15 )16 header_lines.append(17 self.get_line("word", rom_bytes[0x14:0x18][::-1], "Initial $gp/r28")18 )19 header_lines.append(20 self.get_line("word", rom_bytes[0x18:0x1C][::-1], ".text start")21 )22 header_lines.append(23 self.get_line("word", rom_bytes[0x1C:0x20][::-1], ".text size")24 )25 header_lines.append(26 self.get_line("word", rom_bytes[0x20:0x24][::-1], ".data start")27 )28 header_lines.append(29 self.get_line("word", rom_bytes[0x24:0x28][::-1], ".data size")30 )31 header_lines.append(32 self.get_line("word", rom_bytes[0x28:0x2C][::-1], ".bss start")33 )34 header_lines.append(35 self.get_line("word", rom_bytes[0x2C:0x30][::-1], ".bss size")36 )37 header_lines.append(38 self.get_line(39 "word", rom_bytes[0x30:0x34][::-1], "Initial $sp/r29 & $fp/r30 base"40 )41 )42 header_lines.append(43 self.get_line(44 "word", rom_bytes[0x34:0x38][::-1], "Initial $sp/r29 & $fp/r30 offset"45 )46 )47 header_lines.append(self.get_line("word", rom_bytes[0x38:0x3C], "Reserved"))48 header_lines.append(self.get_line("word", rom_bytes[0x3C:0x40], "Reserved"))49 header_lines.append(self.get_line("word", rom_bytes[0x40:0x44], "Reserved"))50 header_lines.append(self.get_line("word", rom_bytes[0x44:0x48], "Reserved"))51 header_lines.append(self.get_line("word", rom_bytes[0x48:0x4C], "Reserved"))52 header_lines.append(53 self.get_line("ascii", rom_bytes[0x4C : self.rom_end], "Sony Inc")54 )55 header_lines.append("")...
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!!