How to use _run_and_log method in localstack

Best Python code snippet using localstack_python

init.py

Source:init.py Github

copy

Full Screen

...142@hooks.on_infra_start()143def _run_init_scripts_on_start():144 # this is a hack since we currently cannot know whether boot scripts have been executed or not145 init_script_manager().stage_completed[Stage.BOOT] = True146 _run_and_log(Stage.START)147@hooks.on_infra_ready()148def _run_init_scripts_on_ready():149 _run_and_log(Stage.READY)150@hooks.on_infra_shutdown()151def _run_init_scripts_on_shutdown():152 _run_and_log(Stage.SHUTDOWN)153def _run_and_log(stage: Stage):154 from localstack.utils.analytics import log155 then = time.time()156 scripts = init_script_manager().run_stage(stage)157 took = (time.time() - then) * 1000158 if scripts:159 log.event("run_init", {"stage": stage.name, "scripts": len(scripts), "duration": took})160def main():161 """162 Run the init scripts for a particular stage. For example, to run all boot scripts run::163 python -m localstack.runtime.init BOOT164 The __main__ entrypoint is currently mainly used for the docker-entrypoint.sh. Other stages165 are executed from runtime hooks.166 """167 import sys...

Full Screen

Full Screen

remote_cd.py

Source:remote_cd.py Github

copy

Full Screen

...12 deploy.Logger.log(out.output)13 if out.returncode != 0:14 raise deploy.DeployFail()15 return out.output16 def _run_and_log(self, cmd):17 deploy.Logger.log(cmd)18 return self._handle_result(self._run_cmd(cmd))19 def _deploy_dmg(self):20 self._run_and_log("hdiutil convert " + os.path.join(self._get_project_path(deploy.CD.PROJECT), Cocoa.TEMPL_DMG) + " -format UDSP -o " + Cocoa.OUTPUT)21 self._run_and_log("hdiutil mount " + Cocoa.SPARSE_OUTPUT)22 self._run_and_log("rm -rf /Volumes/Remote/Remote.app/Contents")23 self._run_and_log("cp -r " + os.path.join(self._get_project_path(deploy.CD.PROJECT), "Contents") + " /Volumes/Remote/Remote.app/")24 self._run_and_log("hdiutil eject /Volumes/Remote")25 self._run_and_log("hdiutil convert " + Cocoa.SPARSE_OUTPUT + " -format UDBZ -o " + Cocoa.DMG_OUTPUT)26 self._run_and_log("rm " + Cocoa.SPARSE_OUTPUT)27 self._run_and_log("scp " + Cocoa.DMG_OUTPUT + " foggyciti@foggyciti.com:")28 self._run_and_log("rm " + Cocoa.DMG_OUTPUT)29 self._run_and_log("ssh foggyciti@foggyciti.com './trampoline.sh Remote.dmg'")30 def _zip_to_download(self, filename):31 self._run_and_log("zip -q -r %s.zip %s" % (filename, filename))32 self._run_and_log("scp %s.zip foggyciti@foggyciti.com:" % (filename))33 self._run_and_log("ssh foggyciti@foggyciti.com './trampoline.sh %s.zip'" % (filename))34 self._run_and_log("rm %s.zip" % (filename))35 def _deploy_updates(self):36 cwd = os.getcwd()37 os.chdir(os.path.join(self._get_project_path(deploy.CD.PROJECT), "Contents/Resources"))38 self._zip_to_download("daemon.app")39 self._zip_to_download("helper.app")40 os.chdir(cwd)41 42 def _incr_version(self):43 version = self._run_and_log("ssh foggyciti@foggyciti.com 'cat %s'" % (remote_version))44 if len(version) == 0:45 version = "0"46 self._run_and_log("ssh foggyciti@foggyciti.com 'echo %d > %s'" % (int(version) + 1, remote_version))47 def _deploy(self):48 self._deploy_dmg()49 self._deploy_updates()50 self._incr_version()51 ...

Full Screen

Full Screen

auto-deploy

Source:auto-deploy Github

copy

Full Screen

...3import sys4import logging5import argparse6import subprocess7def _run_and_log(msg, cmd):8 logging.info(msg, extra=dict(command=' '.join(cmd)))9 subprocess.check_call(cmd)10def main(argv):11 arg_parser = argparse.ArgumentParser(12 description='Fully deploy the project.')13 arg_parser.parse_args(argv[1:])14 # Use the default style.15 logging.basicConfig(16 format="%(asctime)s:%(levelname)s:%(message)s:command='%(command)s'",17 level=logging.INFO)18 _run_and_log('Updating sources from Git', ['git', 'pull'])19 # Install Python requirements, as they may have changed.20 _run_and_log('Installing Python requirements',21 ['pip', 'install', '-r', 'requirements.txt'])22 # Re-run the build. We re-configure as well, in case configuration changes23 # have been made.24 _run_and_log('Running the build', [25 os.path.abspath('waf'), 'configure', 'build', 'archive', 'deploy'])26 return 027if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful