Best Python code snippet using localstack_python
init.py
Source:init.py
...75 self.stage_completed = {stage: False for stage in Stage}76 @cached_property77 def scripts(self) -> Dict[Stage, List[Script]]:78 return self._find_scripts()79 def get_script_runner(self, script_file: str) -> Optional[ScriptRunner]:80 for suffix, runner in self._script_runners.items():81 if script_file.endswith(suffix):82 return runner83 return None84 def has_script_runner(self, script_file: str) -> bool:85 return self.get_script_runner(script_file) is not None86 def run_stage(self, stage: Stage) -> List[Script]:87 """88 Runs all scripts in the given stage.89 :param stage: the stage to run90 :return: the scripts that were in the stage91 """92 scripts = self.scripts.get(stage, [])93 if self.stage_completed[stage]:94 LOG.debug("Stage %s already completed, skipping", stage)95 return scripts96 try:97 for script in scripts:98 LOG.debug("Running %s script %s", script.stage, script.path)99 try:100 script.state = State.RUNNING101 runner = self.get_script_runner(script.path)102 runner.run(script.path)103 except Exception as e:104 script.state = State.ERROR105 if LOG.isEnabledFor(logging.DEBUG):106 LOG.exception("Error while running script %s", script)107 else:108 LOG.error("Error while running script %s: %s", script, e)109 else:110 script.state = State.SUCCESSFUL111 finally:112 self.stage_completed[stage] = True113 return scripts114 def _find_scripts(self) -> Dict[Stage, List[Script]]:115 scripts = {}...
steputils.py
Source:steputils.py
...92 args_list.append(constants.LATEST)93 args_list.append(constants.ARGS)94 args_list += args95 return emrutils.build_step(96 jar=emrutils.get_script_runner(region),97 args=args_list,98 name=name,99 action_on_failure=action_on_failure)100def build_pig_step(parsed_step, region=None):101 args = parsed_step.get('Args')102 emrutils.check_required_field(103 structure=constants.PIG_STEP_CONFIG, name='Args', value=args)104 emrutils.check_empty_string_list(name='Args', value=args)105 name = _apply_default_value(106 arg=parsed_step.get('Name'),107 value=constants.DEFAULT_PIG_STEP_NAME)108 action_on_failure = _apply_default_value(109 arg=parsed_step.get('ActionOnFailure'),110 value=constants.DEFAULT_FAILURE_ACTION)111 args_list = [112 emrutils.build_s3_link(113 relative_path=constants.PIG_SCRIPT_PATH, region=region),114 constants.RUN_PIG_SCRIPT]115 args_list.append(constants.PIG_VERSIONS)116 args_list.append(constants.LATEST)117 args_list.append(constants.ARGS)118 args_list += args119 return emrutils.build_step(120 jar=emrutils.get_script_runner(region),121 args=args_list,122 name=name,123 action_on_failure=action_on_failure)124def build_impala_step(parsed_step, region):125 name = _apply_default_value(126 arg=parsed_step.get('Name'),127 value=constants.DEFAULT_IMPALA_STEP_NAME)128 action_on_failure = _apply_default_value(129 arg=parsed_step.get('ActionOnFailure'),130 value=constants.DEFAULT_FAILURE_ACTION)131 args_list = [132 emrutils.build_s3_link(133 relative_path=constants.IMPALA_INSTALL_PATH, region=region),134 constants.RUN_IMPALA_SCRIPT]135 args = parsed_step.get('Args')136 emrutils.check_required_field(137 structure=constants.IMPALA_STEP_CONFIG, name='Args', value=args)138 args_list += args139 return emrutils.build_step(140 jar=emrutils.get_script_runner(region),141 args=args_list,142 name=name,143 action_on_failure=action_on_failure)144def _apply_default_value(arg, value):145 if arg is None:146 arg = value...
pyconsole.py
Source:pyconsole.py
...20 PythonManager.get_interpreter_icon(), QtCore.Qt.BottomDockWidgetArea)21 dock.hide()22 dock.setSizePolicy(QtWidgets.QSizePolicy.Expanding,23 QtWidgets.QSizePolicy.Expanding)24 self.script_runner = api.plugins.get_script_runner()25 self.script_runner.config_refreshed.connect(self._update_interpreter)26 self._interpeter = None27 self._update_interpreter()28 def close(self):29 self.widget.close()30 def apply_preferences(self):31 self.widget.font_name = settings.editor_font()32 self.widget.font_size = settings.editor_font_size()33 self.widget.syntax_highlighter.color_scheme = ColorScheme(settings.color_scheme())34 self.widget.update_terminal_colors()35 def _update_interpreter(self):36 interpeter = PythonManager().get_project_interpreter(api.project.get_current_project())37 if interpeter != self._interpeter:38 self.widget.change_interpreter(interpeter)...
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!!