Best Python code snippet using lisa_python
run.py
Source:run.py
...15 print(f"Latest go-cqhttp version:{rsp['tag_name']}")16 for i in rsp["assets"]:17 if "linux_amd64.tar.gz" in i["name"]:18 return i["browser_download_url"]19def check_runnable():20 if not Path("./.data", "go-cqhttp").exists():21 down_url = get_down_url()22 content = requests.get(down_url, headers=HEADERS)23 with open(Path(".data", "download.tar.gz"), "wb")as file:24 file.write(content.content)25 os.system("cd ./.data/ && tar -zxvf ./download.tar.gz")26 os.chmod("./.data/go-cqhttp", 755)27def run_gocq():28 while True:29 process = subprocess.Popen("cd ./.data && ./go-cqhttp faststart", shell=True, stdin=sys.stdin,30 stdout=sys.stdout,31 stderr=sys.stderr)32 process.wait()33 time.sleep(10)34def keep_live(url: str):35 while True:36 try:37 requests.get(url, headers=HEADERS)38 except Exception as e:39 logging.exception(e)40 time.sleep(60)41def mv_config(env, file_name):42 if os.environ.get(env, None) is not None:43 file = Path(f"./.data/{file_name}")44 if file.exists():45 os.remove(file)46 with open(file, "w") as file:47 content = base64.b64decode(os.environ[env]).decode()48 file.write(content)49if __name__ == '__main__':50 if not Path(".data").exists():51 os.mkdir(".data")52 check_runnable()53 mv_config("CONF", "config.yml")54 mv_config("DEVICE", "devices.json")55 # os.system("refresh") # å·æ°glitch56 # os.system("git reset HEAD .")57 gocq_thread = threading.Thread(target=run_gocq)58 gocq_thread.isDaemon()59 gocq_thread.start()...
check_model.py
Source:check_model.py
1import onnx2from onnx import checker3import onnxruntime as ort4def check_model(model: onnx.ModelProto, check_runnable: bool = True) -> None:5 """6 Check if model's well-defined and executable on onnxruntime7 """8 # TODO After collecting possible errors,9 # pass through only if all error messages are "No opset import for domain 'com.microsoft'".10 # The code below is only to see the first error encountered.11 acceptable_error_msg = [12 "No opset import for domain 'com.microsoft'",13 "No Op registered for LayerNormalization with domain_version of 12",14 ]15 try:16 checker.check_model(model)17 except checker.ValidationError as e:18 if str(e).split("==>")[0].rstrip() in acceptable_error_msg:19 pass20 else:21 checker.check_model(model)22 if check_runnable:23 ort.set_default_logger_severity(3)...
sample_grading.py
Source:sample_grading.py
...8 f = open("test_memory_visualizer.mips")9 student_program = preprocess(f)10 # Ensures that a student's program is not longer than 500 instructions11 assert len(student_program.source) < 50012 def check_runnable(p):13 # This is where to set a condition to test students' programs14 assert p.registers["$k0"] == 015 assert p.registers["$k1"] == 016 if not p.exited:17 l = p.source[p.registers["pc"]]18 print(f"{l.filename.split('/')[-1]}:{l.lineno} - {l.line}")19 return not p.exited...
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!!