def run(self, path, stdin): for source, dest in self._get_loader_requirements(): shutil.copyfile( os.path.join(self.project._gordon_root, 'loaders', source), os.path.join(path, dest) ) command = self.settings.get('run', self._get_default_run_command()) command = command.format( lambda_path=path, name=self.name, memory=self.get_memory(), handler=self.get_handler(), timeout=self.get_timeout() ) with utils.cd(path): try: out = subprocess.check_output( command, shell=True, stdin=stdin, stderr=subprocess.STDOUT ) except subprocess.CalledProcessError as exc: print(exc.output) else: print(out.decode('utf-8'))
def _test_project_step(self, filename): super(BaseIntegrationTest, self)._test_project_step(filename) with cd(os.path.join(self.test_path, filename)): code = gordon([ 'gordon', 'apply', '--stage={}'.format(self.uid), ]) self.assertEqual(code, 0)
def assertRun(self, filename, lambda_name, stdin_input, expected_output): fake_stdin = tempfile.NamedTemporaryFile(mode='w') fake_stdin.write(stdin_input) fake_stdin.seek(0) with cd(os.path.join(self.test_path, filename)): with Capturing() as output: code = gordon(['gordon', 'run', lambda_name], stdin=fake_stdin) self.assertEqual(output, expected_output) self.assertEqual(code, 0)
def _collect_lambda_module_content(self, destination, go_target_arch='amd64', go_target_os='linux'): root = os.path.join(self.get_root(), self.settings['code']) with utils.cd(root): commands = self._get_build_command(destination) if hasattr(commands, '__call__'): commands() return elif isinstance(commands, six.string_types): commands = [commands] for command in commands: command = command.format( target=destination, pip_path=self._pip_path(), npm_path=self._npm_path(), gradle_path=self._gradle_path(), pip_install_extra=self._pip_install_extra(), npm_install_extra=self._npm_install_extra(), gradle_build_extra=self._gradle_build_extra(), project_path=self.project.path, project_name=self.project.name, lambda_name=self.name, go_target_os=go_target_os, go_target_arch=go_target_arch, ) if self.project.debug: with indent(4): self.project.puts(colored.white(command)) out = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT) if self.project.debug and out: with indent(4): self.project.puts(out)
def _collect_lambda_module_content(self, destination, go_target_arch='amd64', go_target_os='linux'): root = os.path.join(self.get_root(), self.settings['code']) with utils.cd(root): commands = self._get_build_command(destination) if hasattr(commands, '__call__'): commands() return elif isinstance(commands, six.string_types): commands = [commands] for command in commands: command = command.format( target=destination, pip_path=self._pip_path(), npm_path=self._npm_path(), gradle_path=self._gradle_path(), pip_install_extra=self._pip_install_extra(), npm_install_extra=self._npm_install_extra(), gradle_build_extra=self._gradle_build_extra(), project_path=self.project.path, project_name=self.project.name, lambda_name=self.name, go_target_os=go_target_os, go_target_arch=go_target_arch, ) if self.project.debug: with indent(4): self.project.puts(colored.white(command)) out = subprocess.check_output( command, shell=True, stderr=subprocess.STDOUT ) if self.project.debug and out: with indent(4): self.project.puts(out)
def _test_project_step(self, filename): with cd(os.path.join(self.test_path, filename)): code = gordon(['gordon', 'build']) self.assertEqual(code, 0)