Best Python code snippet using localstack_python
install_modules.py
Source:install_modules.py  
...57                # Only install .pyc or .sos, etc58                if not f.endswith('.py'):59                    fname = os.path.join(d, f)60                    shutil.copy2(os.path.join(root, f), fname)61    def _do_install(src, destdir, subdirs_only=False):62        print "Installing %s" % src63        if os.path.isdir(src):64            if not subdirs_only:65                subdir = src.rsplit('/', 1)[1]66                copy_tree(src, os.path.join(destdir, subdir))67                return68            for d in os.listdir(src):69                if d == "EGG-INFO":70                    continue71                path = os.path.join(src, d)72                if os.path.isdir(path):73                    copy_tree(path, os.path.join(destdir, d))74                else:75                    shutil.copy2(path, destdir)76        else:77            shutil.copy2(src, destdir)78    for modname in sys.modules:79        if modname == "__main__":80            continue81        try:82            mod_fn = sys.modules[modname].__file__83        except:84            continue85        mod_fn = os.path.normpath(mod_fn)86        base_dir = ''87        for p in system_paths:88            p_len = len(p)89            if mod_fn.startswith(p) and p > len(base_dir):90                base_dir = p91        # Only install modules that are in the system paths.  We install92        # our command modules separately.93        if base_dir:94            # Turn /usr/lib/python2.6/Crypto/Cipher/AES into:95            # /usr/lib/python2.6/Crypto96            rest_dir = mod_fn[len(base_dir) + 1:]97            if '/' in rest_dir:98                rest_dir = rest_dir.split('/', 1)[0]99            if base_dir.endswith('site-packages'):100                idir = installdir + '/site-packages'101            else:102                idir = installdir103            if re.match('.*\.egg', rest_dir):104                full_srcdir = os.path.join(base_dir, rest_dir)105                if os.path.isdir(full_srcdir):106                    _do_install(os.path.join(base_dir, rest_dir),107                            idir, True)108                else:109                    z = zipfile.ZipFile(full_srcdir)110                    files = z.infolist()111                    for f in files:112                        if f.filename == "EGG-INFO" or \113                                f.filename.startswith("EGG-INFO/"):114                            continue115                        z.extract(f, idir)116                    z.close()117            else:118                _do_install(os.path.join(base_dir, rest_dir),119                        idir)120if __name__ == "__main__":121    prog_name = sys.argv[0]122    if len(sys.argv) != 2:123        print "Usage: %s <install_dir>" % prog_name124        sys.exit(1)125    installdir = sys.argv[1]126    sys_paths = sys.path127    # Pop off the first directory, which is the directory of this script.128    # We do this so we can ignore *our* modules, which are installed129    # separately130    sys_paths.pop(0)131    if not os.path.exists(installdir):132        os.makedirs(installdir)...brew_installer.py
Source:brew_installer.py  
...20    check.check_brew_installer_options(options)21    brew.check_system()22    if brew.has_brew():23      raise brew_error('brew already installed')24    clazz._do_install(options)25    options.blurber.blurb('Installed brew version {}'.format(clazz.version()))26  @classmethod27  def uninstall(clazz, options):28    'Uninstall brew.'29    check.check_brew_installer_options(options)30    brew.check_system()31    if not brew.has_brew():32      raise brew_error('brew not installed')33    clazz.run_script('uninstall.sh', [ '--force' ], options)34    35  @classmethod36  def reinstall(clazz, options):37    'Reinstall brew even if already installed.'38    check.check_brew_installer_options(options)39    brew.check_system()40    clazz._do_install(options)41  _SUDO_ERROR_MESSAGE = 'Failed to read sudo password for brew.'42  _SUDO_PROMPT = 'sudo password for brew: '43  @classmethod44  def run_script(clazz, script_name, args, options):45    'Download and run a brew script with optional args.'46    check.check_brew_installer_options(options)47    check.check_string(script_name)48    check.check_string_seq(args, allow_none = True)49    if not shell.has_shell('/bin/bash'):50      raise brew_error('/bin/bash is needed to run brew scripts.')51    args = args or []52    tmp_script = clazz.download_script(script_name)53    sudo_options = sudo_cli_options()54    sudo_options.error_message = clazz._SUDO_ERROR_MESSAGE55    sudo_options.prompt = clazz._SUDO_PROMPT56    sudo_options.password = options.password57    clazz._log.log_d('run_script: calling sudo if needed: options={}'.format(options))58    sudo.authenticate_if_needed(options = sudo_options)59    cmd = [ '/bin/bash', tmp_script ] + args60    clazz._log.log_d('run_script: script_name={} cmd={}'.format(script_name, cmd))61    env = os_env.make_clean_env()62    env.update({63      'CI': '1',64    })65    execute.execute(cmd,66                    shell = False,67                    env = env,68                    non_blocking = options.verbose)69  @classmethod70  def _do_install(clazz, options):71    'Install brew.'72    73    clazz._log.log_d('_do_install: calling install.sh options={}'.format(options))74    clazz.run_script('install.sh', [], options)75  @classmethod76  def ensure(clazz, options):77    'Ensure brew is installed.'78    check.check_brew_installer_options(options)79    brew.check_system()80    if brew.has_brew():81      options.blurber.blurb('brew already installed at version {}'.format(brew().version()))82      return83    clazz.install(options)84    ...lpm.py
Source:lpm.py  
...19    Install all community packages, four in parallel:20        python -m localstack.cli.lpm list | grep "/community" | cut -d'/' -f1 | xargs python -m localstack.cli.lpm install --parallel 421    """22    setup_logging()23def _do_install(pkg):24    console.print(f"installing... [bold]{pkg}[/bold]")25    try:26        InstallerManager().get_installers()[pkg]()27        console.print(f"[green]installed[/green] [bold]{pkg}[/bold]")28    except Exception as e:29        console.print(f"[red]error[/red] installing {pkg}: {e}")30        raise e31@cli.command()32@click.argument("package", nargs=-1, required=True)33@click.option(34    "--parallel",35    type=int,36    default=1,37    required=False,...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!!
