Best Python code snippet using autotest_python
build_and_install.py
Source:build_and_install.py
1import os2import subprocess3import shutil4import sys5import platform as pf6detectPlatform = pf.system()7seperator = " ; "8if detectPlatform == "Windows":9 seperator = " & "10curWorkingDir = os.path.dirname(os.path.realpath(__file__))11update_cmd = "git submodule update --init --force --remote"12gen_cmake_cmd = "cmake .. -DCMAKE_BUILD_TYPE={}"13build_cmd = "cmake --build ."14build_install_cmd = "cmake --build . --target install"15submodproj = {16 "g3log": {17 "repo": "submods/g3log",18 "installdir": "install/g3log",19 "build-variants" : [20 "cmake -DG3_SHARED_LIB=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX={}/shared/Debug ..",21 "cmake -DG3_SHARED_LIB=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX={}/shared/Release ..",22 "cmake -DG3_SHARED_LIB=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX={}/static/Debug ..",23 "cmake -DG3_SHARED_LIB=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX={}/static/Release ..",24 ]25 },26 "g3log-wrapper": {27 "repo": "g3log-wrapper",28 "installdir": "install/g3log-wrapper",29 "build-variants" : [30 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX={}/static/Debug ..",31 "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX={}/static/Release ..",32 ]33 },34 "spdlog": {35 "repo": "submods/spdlog",36 "installdir": "install/spdlog",37 "build-variants" : [38# "cmake -DG3_SHARED_LIB=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX={}/shared/Debug ..",39# "cmake -DG3_SHARED_LIB=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX={}/shared/Release ..",40 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX={}/static/Debug ..",41 "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX={}/static/Release ..",42 ]43 },44 "yaml-cpp": {45 "repo": "submods/yaml-cpp",46 "installdir": "install/yaml-cpp",47 "build-variants" : [48 "cmake -DYAML_BUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX={}/shared/Debug ..",49 "cmake -DYAML_BUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX={}/shared/Release ..",50 "cmake -DYAML_BUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX={}/static/Debug ..",51 "cmake -DYAML_BUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX={}/static/Release ..",52 ]53 },54}55def DeleteDir(dir2Rem):56 result = True57 if os.path.exists(dir2Rem):58 try:59 print("Removing the directory {}".format(dir2Rem))60 shutil.rmtree(dir2Rem)61 except OSError as e:62 print("Error {} while removing the directory {}".format(e.strerror, dir2Rem))63 result = False64 return result65def CreateDir(dir2Create):66 result = True67 try:68 print("Creating the directory {}".format(dir2Create))69 os.mkdir(dir2Create)70 except OSError as e:71 print("Error {} while creating the directory {}".format(e.strerror, dir2Create))72 result = False73 return result74class SubModule(object):75 def __init__(self, inArgs):76 self.opt = inArgs77 self.buildDir = curWorkingDir + "/" + self.opt["repo"] + "/build"78 self.installDir = curWorkingDir + "/" + self.opt["installdir"]79 print("BuildDir={}\nInstallDir={}".format(self.buildDir, self.installDir))80 def InstallInit(self):81 return DeleteDir(self.installDir)82 def BuildInit(self):83 return DeleteDir(self.buildDir) and CreateDir(self.buildDir)84 def Build(self):85 buildDirCmd = "cd {}".format(self.buildDir)86 for cmd in self.opt["build-variants"]:87 # Delete the build directory88 self.BuildInit()89 # Command to change directory to the build directory90 allBuildCmds = buildDirCmd + seperator91 # Command to generate the build tree92 allBuildCmds += cmd.format(self.installDir) + seperator93 # Command to generate the build tree94 allBuildCmds += build_install_cmd95 print("Used command: {}".format(allBuildCmds))96 subprocess.call(allBuildCmds, shell=True)97 98def init():99 # 1. Update the submodues100 subprocess.call(update_cmd, shell=True)101def ExecSubMod(mod):102 sMod = SubModule(mod)103 if sMod.InstallInit():104 sMod.Build()105 else:106 print("Install pre initialization step failed")107def PHelp():108 print("Usage:")109 print("1. Update and compile all submodules: python3 build_and_install.py --a")110 print("2. Update all submodules but compile only one submodule(Note only name of the submodule/wrapper required): python3 build_and_install.py --s <submodule-wrapper-name>")111 print("2.1 Example: Build only yaml-cpp --> python3 build_and_install.py --s yaml-cpp")112 print("3. Build the consumer projects: python3 build_and_install.py --c <path-to-the-consumer-project>")113 print("3.1 Example: Build all examples under play directory --> python3 build_and_install.py --c play")114 print("3.2 Example: Build all examples of yaml-cpp project --> python3 build_and_install.py --c play/yaml-cpp")115 print("3.3 Example: Build only the example 'sequences' in the project yaml-cpp --> python3 build_and_install.py --c play/yaml-cpp/sequences")116if __name__ == '__main__':117 acceptableOpts = ['--a', '--s', '--c']118 if len(sys.argv) > 1:119 opt = sys.argv[1]120 if opt not in acceptableOpts:121 PHelp()122 elif opt == '--a':123 init()124 for proj in submodproj.keys():125 ExecSubMod(submodproj[proj])126 elif len(sys.argv) > 2:127 proj = sys.argv[2]128 if opt == '--s':129 ExecSubMod(submodproj[proj])130 else:131 projDir = "{}/{}/{}".format(curWorkingDir, proj, "build")132 DeleteDir(projDir)133 CreateDir(projDir)134 allBuildCmds = "cd {}".format(projDir) + seperator + gen_cmake_cmd.format("Debug") + seperator + build_cmd135 print("Used command: {}".format(allBuildCmds))136 subprocess.call(allBuildCmds, shell=True)137 else:138 PHelp()139 else:...
getrmpytools
Source:getrmpytools
...15class RMPyToolsSetup(paella.Setup):16 def __init__(self, args):17 paella.Setup.__init__(self, nop=args.nop)18 self.reinstall = args.reinstall19 def build_and_install(self, deps):20 self.run("%s/bin/getgcc" % READIES)21 self.install(deps)22 self.pip_install("psutil")23 def common_first(self):24 self.psutil_installed = self.pip_install("psutil", _try=True, output=False) == 025 def debian_compat(self):26 if not self.psutil_installed:27 self.psutil_installed = self.install("python%s-psutil" % ("" if self.pyver == "2" else self.pyver),28 _try=True, output=False) == 029 if not self.psutil_installed:30 self.build_and_install("python%s-dev" % self.pyver)31 def redhat_compat(self):32 if not self.psutil_installed:33 self.build_and_install("python%s-devel" % self.pyver)34 def fedora(self):35 if not self.psutil_installed:36 self.psutil_installed = self.install("python%s-psutil" % self.pyver, _try=True, output=False) == 037 if not self.psutil_installed:38 self.build_and_install("python%s-devel" % self.pyver)39 def macos(self):40 pass41 def common_last(self):42 self.install("git")43 if self.reinstall:44 self.run("pip uninstall -y -q redis redis-py-cluster ramp-packer RLTest || true")45 # redis-py-cluster should be installed from git due to redis-py dependency46 self.pip_install("--no-cache-dir git+https://github.com/Grokzen/redis-py-cluster.git@master")47 self.pip_install("--no-cache-dir git+https://github.com/RedisLabsModules/RLTest.git@master")48 self.pip_install("--no-cache-dir git+https://github.com/RedisLabs/RAMP@master")49#----------------------------------------------------------------------------------------------50parser = argparse.ArgumentParser(description='Install RedisLabs Modules Python tools')51parser.add_argument('-n', '--nop', action="store_true", help='no operation')52parser.add_argument('--reinstall', action="store_true", help='Reinstall everything')...
BUILD
Source:BUILD
1load("//tools:cpplint.bzl", "cpplint")2package(default_visibility = ["//visibility:public"])3licenses(["notice"])4genrule(5 name = "pandora_genrule",6 srcs = glob([7 "**/*.cc",8 "**/*.h",9 "build_and_install.sh",10 ]),11 outs = ["pandora_genrule.log"],12 cmd = "bash modules/drivers/pandora/build_and_install.sh > $@",13)14filegroup(15 name = "genrule_success",16 srcs = ["pandora_genrule.log"],17)...
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!!