How to use _get_parent_commands method in localstack

Best Python code snippet using localstack_python

cli.py

Source:cli.py Github

copy

Full Screen

...19 ),20 )21 publisher = AnalyticsClientPublisher(AnalyticsClient())22 publisher.publish([event])23def _get_parent_commands(ctx: click.Context) -> List[str]:24 parent_commands = []25 parent = ctx.parent26 while parent is not None:27 parent_commands.insert(0, parent.command.name)28 parent = parent.parent29 return parent_commands30def publish_invocation(fn):31 """32 Decorator for capturing CLI commands from Click and publishing them to the backend as analytics events.33 This decorator should only be used on outermost subcommands, e.g. "localstack status docker" not "localstack status"34 otherwise it may publish multiple events for a single invocation.35 If DISABLE_EVENTS is set then nothing is collected.36 For performance reasons, the API call to the backend runs on a separate process and is killed if it takes longer37 than ANALYTICS_API_RESPONSE_TIMEOUT_SECS.38 The emitted event contains the invoked command, plus any parameter names if their associated values are truthy (but39 not the values themselves).40 """41 @functools.wraps(fn)42 def publisher_wrapper(*args, **kwargs):43 if config.DISABLE_EVENTS:44 return fn(*args, **kwargs)45 ctx = click.get_current_context()46 full_command = " ".join(_get_parent_commands(ctx) + [ctx.command.name])47 publish_cmd_process = Process(48 target=_publish_cmd_as_analytics_event,49 args=(full_command, [k for k, v in ctx.params.items() if v]),50 )51 publish_cmd_process.start()52 publish_cmd_process.join(ANALYTICS_API_RESPONSE_TIMEOUT_SECS)53 publish_cmd_process.terminate()54 return fn(*args, **kwargs)...

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