Best Python code snippet using autotest_python
ulp.py
Source:ulp.py
...17from platformio.proc import where_is_program18Import("env project_config idf_variant")19ulp_env = env.Clone()20platform = ulp_env.PioPlatform()21FRAMEWORK_DIR = platform.get_package_dir("framework-espidf")22BUILD_DIR = ulp_env.subst("$BUILD_DIR")23ULP_BUILD_DIR = os.path.join(24 BUILD_DIR, "esp-idf", project_config["name"].replace("__idf_", ""), "ulp_main"25)26def prepare_ulp_env_vars(env):27 ulp_env.PrependENVPath("IDF_PATH", FRAMEWORK_DIR)28 additional_packages = [29 os.path.join(30 platform.get_package_dir(31 "toolchain-xtensa%s" % ("32s2" if idf_variant == "esp32s2" else "32")32 ),33 "bin",34 ),35 os.path.join(36 platform.get_package_dir("toolchain-%sulp" % idf_variant),37 "bin",38 ),39 platform.get_package_dir("tool-ninja"),40 os.path.join(platform.get_package_dir("tool-cmake"), "bin"),41 os.path.dirname(where_is_program("python")),42 ]43 if "windows" in get_systype():44 additional_packages.append(platform.get_package_dir("tool-mconf"))45 for package in additional_packages:46 ulp_env.PrependENVPath("PATH", package)47def collect_ulp_sources():48 return [49 os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp", f)50 for f in os.listdir(os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp"))51 ]52def get_component_includes(target_config):53 for source in target_config.get("sources", []):54 if source["path"].endswith("ulp_main.bin.S"):55 return [56 inc["path"]57 for inc in target_config["compileGroups"][source["compileGroupIndex"]][58 "includes"59 ]60 ]61 return [os.path.join(BUILD_DIR, "config")]62def generate_ulp_config(target_config):63 ulp_sources = collect_ulp_sources()64 cmd = (65 os.path.join(platform.get_package_dir("tool-cmake"), "bin", "cmake"),66 "-DCMAKE_GENERATOR=Ninja",67 "-DCMAKE_TOOLCHAIN_FILE="68 + os.path.join(69 FRAMEWORK_DIR,70 "components",71 "ulp",72 "cmake",73 "toolchain-%s-ulp.cmake" % idf_variant,74 ),75 '-DULP_S_SOURCES="%s"' % ";".join(ulp_sources),76 "-DULP_APP_NAME=ulp_main",77 "-DCOMPONENT_DIR=" + os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp"),78 '-DCOMPONENT_INCLUDES="%s"' % ";".join(get_component_includes(target_config)),79 "-DIDF_PATH=" + FRAMEWORK_DIR,80 "-DSDKCONFIG=" + os.path.join(BUILD_DIR, "config", "sdkconfig.h"),81 "-DPYTHON=" + env.subst("$PYTHONEXE"),82 "-GNinja",83 "-B",84 ULP_BUILD_DIR,85 os.path.join(FRAMEWORK_DIR, "components", "ulp", "cmake"),86 )87 return ulp_env.Command(88 os.path.join(ULP_BUILD_DIR, "build.ninja"),89 ulp_sources,90 ulp_env.VerboseAction(" ".join(cmd), "Generating ULP configuration"),91 )92def compile_ulp_binary():93 cmd = (94 os.path.join(platform.get_package_dir("tool-cmake"), "bin", "cmake"),95 "--build",96 ULP_BUILD_DIR,97 "--target",98 "build",99 )100 return ulp_env.Command(101 [102 os.path.join(ULP_BUILD_DIR, "ulp_main.h"),103 os.path.join(ULP_BUILD_DIR, "ulp_main.ld"),104 os.path.join(ULP_BUILD_DIR, "ulp_main.bin"),105 os.path.join(ULP_BUILD_DIR, "esp32.ulp.ld"),106 ],107 None,108 ulp_env.VerboseAction(" ".join(cmd), "Generating ULP project files $TARGETS"),109 )110def generate_ulp_assembly():111 cmd = (112 os.path.join(platform.get_package_dir("tool-cmake"), "bin", "cmake"),113 "-DDATA_FILE=$SOURCE",114 "-DSOURCE_FILE=$TARGET",115 "-DFILE_TYPE=BINARY",116 "-P",117 os.path.join(118 FRAMEWORK_DIR, "tools", "cmake", "scripts", "data_file_embed_asm.cmake"119 ),120 )121 return ulp_env.Command(122 os.path.join(BUILD_DIR, "ulp_main.bin.S"),123 os.path.join(ULP_BUILD_DIR, "ulp_main.bin"),124 ulp_env.VerboseAction(" ".join(cmd), "Generating ULP assembly file $TARGET"),125 )126prepare_ulp_env_vars(ulp_env)...
setup.py
Source:setup.py
...53 else:54 path = p55 result[package_name].append(path)56 return result57def get_package_dir():58 return _combine_dicts([client.setup.get_package_dir(),59 shared.setup.get_package_dir(),60 frontend.setup.get_package_dir(),61 cli.setup.get_package_dir(),62 server.setup.get_package_dir(),63 scheduler.setup.get_package_dir(),64 database_legacy.setup.get_package_dir(),65 tko.setup.get_package_dir(),66 utils.setup.get_package_dir(),67 mirror.setup.get_package_dir()])68def get_packages():69 return (client.setup.get_packages() +70 shared.setup.get_packages() +71 frontend.setup.get_packages() +72 cli.setup.get_packages() +73 server.setup.get_packages() +74 scheduler.setup.get_packages() +75 database_legacy.setup.get_packages() +76 tko.setup.get_packages() +77 utils.setup.get_packages() +78 mirror.setup.get_packages() +79 installation_support.setup.get_packages())80def get_data_files():81 return (tko.setup.get_data_files() +82 utils.setup.get_data_files() +83 mirror.setup.get_data_files())84def get_package_data():85 return _combine_dicts([86 _fix_data_paths(client.setup.get_package_data()),87 _fix_data_paths(frontend.setup.get_package_data()),88 _fix_data_paths(cli.setup.get_package_data()),89 _fix_data_paths(server.setup.get_package_data()),90 _fix_data_paths(scheduler.setup.get_package_data()),91 _fix_data_paths(database_legacy.setup.get_package_data()),92 _fix_data_paths(utils.setup.get_package_data())93 ])94def get_scripts():95 return (client.setup.get_scripts() +96 frontend.setup.get_scripts() +97 cli.setup.get_scripts() +98 server.setup.get_scripts() +99 scheduler.setup.get_scripts() +100 database_legacy.setup.get_scripts() +101 tko.setup.get_scripts() +102 installation_support.setup.get_scripts())103def run():104 setup(name='autotest',105 description='Autotest test framework',106 maintainer='Lucas Meneghel Rodrigues',107 maintainer_email='lmr@redhat.com',108 version=version.get_version(),109 url='http://autotest.github.com',110 package_dir=get_package_dir(),111 package_data=get_package_data(),112 packages=get_packages(),113 scripts=get_scripts(),114 data_files=get_data_files(),115 cmdclass=cmdclass,116 command_options=command_options,117 include_package_data=True,118 )119if __name__ == '__main__':...
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!!