Best Python code snippet using lisa_python
Qt.py
Source:Qt.py
...90 self._host_qmake = value91 def install(self):92 """ Install for the target. """93 if self.install_from_source:94 self._install_from_source()95 def sdk_configure(self, platform_name):96 """ Perform any platform-specific SDK configuration. """97 if platform_name == 'ios':98 if 'IPHONEOS_DEPLOYMENT_TARGET' not in os.environ:99 if self.version >= (5, 14):100 dep_target = '12.0'101 else:102 dep_target = '11.0'103 os.environ['IPHONEOS_DEPLOYMENT_TARGET'] = dep_target104 setattr(self, '_ios_dep_target_set', True)105 elif self.target_platform_name == 'macos':106 if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ:107 if self.version >= (5, 14):108 dep_target = '10.13'109 else:110 dep_target = '10.12'111 os.environ['MACOSX_DEPLOYMENT_TARGET'] = dep_target112 setattr(self, '_macos_dep_target_set', True)113 def sdk_deconfigure(self, platform_name):114 """ Remove any platform-specific SDK configuration applied by a115 previous call to sdk_configure().116 """117 if platform_name == 'ios':118 if getattr(self, '_ios_dep_target_set', False):119 del os.environ['IPHONEOS_DEPLOYMENT_TARGET']120 delattr(self, '_ios_dep_target_set')121 elif platform_name == 'macos':122 if getattr(self, '_macos_dep_target_set', False):123 del os.environ['MACOSX_DEPLOYMENT_TARGET']124 delattr(self, '_macos_dep_target_set')125 def verify(self):126 """ Verify the component. """127 # Do some basic version checks.128 if self.version >= 6:129 self.unsupported()130 if self.version < (5, 12):131 self.unsupported()132 if self.version > (5, 15):133 self.untested()134 # If we are linking against OpenSSL then get its version number.135 if self.ssl == 'openssl-linked':136 self._openssl = self.get_component('OpenSSL')137 else:138 self._openssl = None139 if self.install_from_source:140 # We don't support cross-compiling Qt.141 if self.host_platform_name != self.target_platform_name:142 self.error("cross compiling Qt is not supported")143 if not self.edition:144 self.error(145 "the 'edition' option must be specified when building "146 "from source")147 # Make sure we have a Python v2.7 installation on Windows.148 if self.host_platform_name == 'win':149 self._py_27 = self.get_python_install_path(2, 7)150 # Check the OpenSSL version.151 if self._openssl is not None:152 if self.version >= (5, 15):153 if self._openssl.version != (1, 1, 1):154 self.error(155 "v{0} requires OpenSSL v1.1.1".format(156 self.version))157 else:158 self._verify_installed_version()159 # Check the OpenSSL version for compatibility with the binary160 # installers.161 if self._openssl is not None:162 if self.version >= (5, 12, 4):163 if self._openssl.version != (1, 1, 1):164 self.error(165 "v{0} requires OpenSSL v1.1.1".format(166 self.version))167 else:168 if self._openssl.version != (1, 0, 2):169 self.error(170 "v{0} requires OpenSSL v1.0.2".format(171 self.version))172 # Platform-specific checks.173 if self.target_platform_name == 'android':174 if self.android_api < 21:175 self.error("Android API level 21 or greater is required")176 if self.version >= (5, 13, 2) or (5, 12, 6) <= self.version <= (5, 13, 0):177 if self.android_ndk_version not in (20, 21):178 self.error(179 "v{0} requires NDK r20 or r21".format(180 self.version))181 else:182 if self.android_ndk_version != 19:183 self.error("v{0} requires NDK r19".format(self.version))184 elif self.target_platform_name == 'ios':185 if self.version >= (5, 13) and self.apple_sdk_version < (13, 2):186 self.error(187 "v{0} requires iOS SDK v13.2 (Xcode 11) or "188 "later".format(self.version))189 elif self.apple_sdk_version < (12, 1):190 self.error(191 "v{0} requires iOS SDK v12.1 (Xcode 10) or "192 "later".format(self.version))193 elif self.target_platform_name == 'mac':194 if self.apple_sdk_version < (10, 4):195 self.error(196 "v{0} requires macOS SDK v10.4 (Xcode 10) or "197 "later".format(self.version))198 def _install_from_source(self):199 """ Install Qt from source. """200 self.unpack_archive(self.get_archive())201 if self.host_platform_name == 'win':202 configure = 'configure.bat'203 dx_setenv = os.path.expandvars(204 '%DXSDK_DIR%\\Utilities\\bin\\dx_setenv.cmd')205 if os.path.exists(dx_setenv):206 self.run(dx_setenv)207 original_path = os.environ['PATH']208 new_path = [original_path]209 new_path.insert(0, os.path.abspath('gnuwin32\\bin'))210 new_path.insert(0, self._py_27)211 os.environ['PATH'] = ';'.join(new_path)212 else:...
setup.py
Source:setup.py
...65 shutil.copyfile("lib/"+core_crypto_cpp_shared_filename, "/usr/local/lib/"+core_crypto_cpp_shared_filename)66 def _virtualenv_enabled(self):67 """Checks virtualenv is enabled or not"""68 return hasattr(sys, 'real_prefix')69 def _install_from_source(self):70 site_package_dir = "none"71 if self._virtualenv_enabled():72 site_package_dir = next(p for p in sys.path if 'site-packages' in p)73 # commands to run74 git_clone_command = ["git" ,"clone", "https://github.com/peacemakr-io/peacemakr-core-crypto.git"]75 git_checkout_tag = ["cd", "peacemakr-core-crypto", "&&", "git", "checkout", "tags/"+CORE_CRYPTO_VERSION]76 rm_clone_command = ["rm", "-rf", "peacemakr-core-crypto"]77 install_command = ["cd", "peacemakr-core-crypto/bin", "&&", "./release-python.sh", "local", site_package_dir, "release"]78 check_openssl_installed = ["openssl", "version"]79 check_cmake_installed = ["cmake", "--version"]80 # clone the repo81 self.announce(82 'Cloning core-crypto @: %s' % ("https://github.com/peacemakr-io/peacemakr-core-crypto.git"),83 level=distutils.log.INFO)84 self._execute_command(git_clone_command)85 # checkout lastest stable core-crypto tag86 self.announce(87 'Checking out tag '+CORE_CRYPTO_VERSION,88 level=distutils.log.INFO)89 self._execute_shell_command(git_checkout_tag)90 # check openssl and cmake91 self.announce("Checking CMake and OpenSSL is installed", level=distutils.log.INFO)92 self._execute_shell_command(check_cmake_installed, err_msg="CMake not installed. CMake 3.15+ required for this library.\n\n\n \93 Please refer to Core-crypto for installation: https://github.com/peacemakr-io/peacemakr-core-crypto/")94 self._execute_shell_command(check_openssl_installed, err_msg="OpenSSL not installed. Openssl 1.1+ required for this library.\n\n\n \95 Please refer to Core-crypto for installation: https://github.com/peacemakr-io/peacemakr-core-crypto/")96 # running release commands97 self.announce(98 'Installing core-crytpo into %s %s' % (str(site_package_dir), " ".join(install_command)),99 level=distutils.log.INFO)100 self._execute_shell_command(install_command, err_msg="Installation from source failed. Please refer to Core-crypto for installation: https://github.com/peacemakr-io/peacemakr-core-crypto/")101 # remove peacemakr-core-crypto102 self.announce(103 'Removing core-crytpo folder',104 level=distutils.log.INFO)105 self._execute_command(rm_clone_command)106 def run(self):107 """Build core-crypto108 Two methods to build core-crypto python library109 1. From Artifact: If user is using a OS/Arch/Python version that fits the deployed artifact,110 the command simply fetch and deploy the pre-built library111 2. From Source: If the version doesn't match, but is still macos/linux. The command112 clone the core-crypto from specific tag and built from source.113 # TODO: Remind user to set LD_LIBRARY_PATH for Ubuntu in README114 """115 os_type = sys.platform116 machine_type = platform.machine()117 python_version = platform.python_version_tuple()118 tar_filename = ""119 core_crypto_so_filename = ""120 core_crypto_shared_filename = ""121 core_crypto_cpp_shared_filename = ""122 if os_type == "darwin":123 # user is using macos124 if machine_type == "x86_64" and self._is_pyversion_in_range(python_version, '3', '7'):125 # install from artifact126 tar_filename = "peacemakr-core-crypto-python-macos-x86_64.tar.gz"127 core_crypto_so_filename = "peacemakr_core_crypto_python.cpython-37m-darwin.so"128 core_crypto_shared_filename = "libpeacemakr-core-crypto.dylib"129 core_crypto_cpp_shared_filename = "libpeacemakr-core-crypto-cpp.dylib"130 self._install_from_artifact(tar_filename, core_crypto_so_filename, core_crypto_shared_filename, core_crypto_cpp_shared_filename)131 else:132 # install from src133 self.announce("Installing core-crypto from source", level=distutils.log.INFO)134 self._install_from_source()135 elif os_type == "linux":136 # user is using linux137 import distro138 linux_distribution = distro.linux_distribution(full_distribution_name=False)[0]139 140 if linux_distribution in ["debian", "ubuntu"] and machine_type == "x86_64" and self._is_pyversion_in_range(python_version, '3', '6'):141 # install from artifact142 tar_filename = "peacemakr-core-crypto-python-ubuntu-x86_64.tar.gz"143 core_crypto_so_filename = "peacemakr_core_crypto_python.cpython-36m-x86_64-linux-gnu.so"144 core_crypto_shared_filename = "libpeacemakr-core-crypto.so"145 core_crypto_cpp_shared_filename = "libpeacemakr-core-crypto-cpp.so"146 self._install_from_artifact(tar_filename, core_crypto_so_filename, core_crypto_shared_filename, core_crypto_cpp_shared_filename)147 else:148 # install from src149 self.announce("Installing in Non-Debian Linux, installing core-crypto from source", level=distutils.log.INFO)150 self._install_from_source()151 else:152 sys.exit("Error: OS not supported. We only support Ubuntu and MacOS at the moment.")153class BuildPyCommand(setuptools.command.build_py.build_py):154 """Custom build command."""155 def run(self):156 self.run_command('install_core_crypto')157 setuptools.command.build_py.build_py.run(self)158setup(159 cmdclass={160 'install_core_crypto': InstallCoreCryptoCommand,161 'build_py': BuildPyCommand,162 },163 name=NAME,164 version=VERSION,...
docker_compose.py
Source:docker_compose.py
...25 cwd=path,26 expected_exit_code=0,27 expected_exit_code_failure_message="fail to launch docker-compose up -d",28 )29 def _install_from_source(self) -> None:30 wget_tool = self.node.tools[Wget]31 uname_tool = self.node.tools[Uname]32 hardware = uname_tool.get_linux_information().hardware_platform33 filename = "docker-compose"34 wget_tool.run(35 "https://github.com/docker/compose/releases/download/1.23.2"36 f"/docker-compose-Linux-{hardware} -O {filename}",37 sudo=True,38 )39 self.node.execute(f"sudo chmod +x {filename}")40 self.node.execute(41 "mv docker-compose /usr/bin/", sudo=True, expected_exit_code=042 )43 def _install(self) -> bool:44 # The default installed docker-compose package doesn't work for45 # redhat so it uses the latest version46 if isinstance(self.node.os, Redhat) or isinstance(self.node.os, CBLMariner):47 self._install_from_source()48 elif isinstance(self.node.os, Posix):49 try:50 self._install_from_source()51 except Exception as e:52 self._log.info(53 f"Failed to install docker-compose from source. Error: {e}"54 )55 self.node.os.install_packages("docker-compose")56 else:57 raise LisaException(f"Not supported on {self.node.os.information.vendor}")...
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!!