Best Python code snippet using lisa_python
mdadm.py
Source:mdadm.py  
...53    def _windows_tool(cls) -> Optional[Type[Tool]]:54        return WindowsMdadm55    def _install(self) -> bool:56        posix_os: Posix = cast(Posix, self.node.os)57        if posix_os.is_package_in_repo("mdadm"):58            posix_os.install_packages("mdadm")59        else:60            self._install_from_src()61        return self._check_exists()62    def _install_from_src(self) -> None:63        self._install_dep_packages()64        posix_os: Posix = cast(Posix, self.node.os)65        posix_os.install_packages([Gcc])66        tool_path = self.get_tool_path()67        git = self.node.tools[Git]68        git.clone(self._repo, tool_path)69        make = self.node.tools[Make]70        code_path = tool_path.joinpath("mdadm")71        make.make_install(cwd=code_path)72    def _install_dep_packages(self) -> None:73        posix_os: Posix = cast(Posix, self.node.os)74        if isinstance(self.node.os, CBLMariner):75            package_list = [76                "kernel-headers",77                "binutils",78                "glibc-devel",79                "zlib-devel",80                "cmake",81            ]82        elif (83            isinstance(self.node.os, Fedora)84            or isinstance(self.node.os, Debian)85            or isinstance(self.node.os, Suse)86        ):87            pass88        else:89            raise LisaException(90                f"tool {self.command} can't be installed in distro {self.node.os.name}."91            )92        for package in list(package_list):93            if posix_os.is_package_in_repo(package):94                posix_os.install_packages(package)95class WindowsMdadm(Mdadm):96    @property97    def command(self) -> str:98        return "powershell"99    def _check_exists(self) -> bool:100        return True101    def create_raid(102        self,103        disk_list: List[str],104        level: int = 0,105        volume_name: str = "Raid0-Disk",106        chunk_size: int = 0,107        pool_name: str = "Raid0-Pool",...netperf.py
Source:netperf.py  
...85            raise LisaException(86                f"tool {self.command} can't be installed in distro {self.node.os.name}."87            )88        for package in list(package_list):89            if posix_os.is_package_in_repo(package):90                posix_os.install_packages(package)91    def _install_from_src(self) -> None:92        self._install_dep_packages()93        tool_path = self.get_tool_path()94        git = self.node.tools[Git]95        git.clone(self.repo, tool_path, ref=self.branch)96        code_path = tool_path.joinpath("netperf")97        make = self.node.tools[Make]98        if self.node.shell.exists(self.node.get_pure_path(f"{code_path}/autogen.sh")):99            self.node.execute("./autogen.sh", cwd=code_path).assert_exit_code()100        self.node.execute("./configure", cwd=code_path).assert_exit_code()101        arguments = ""102        # fix compile issue when gcc version >= 10103        if self.node.tools[Gcc].get_version() >= "10.0.0":...stress_ng.py
Source:stress_ng.py  
...16    def can_install(self) -> bool:17        return True18    def install(self) -> bool:19        posix_os: Posix = cast(Posix, self.node.os)20        if posix_os.is_package_in_repo("stress-ng"):21            posix_os.install_packages("stress-ng")22        else:23            self._install_from_src()24        return self._check_exists()25    def launch(26        self, num_workers: int = 0, vm_bytes: str = "", timeout_in_seconds: int = 027    ) -> None:28        # --vm N, start N workers spinning on anonymous mmap29        # --timeout T, timeout after T seconds30        # --vm-bytes N, allocate N bytes per vm worker31        #  (default 256MB)32        cmd = ""33        if num_workers:34            cmd += f" --vm {num_workers} "...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!!
