Python click.exceptions() Examples
The following are 5
code examples of click.exceptions().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
click
, or try the search function
.
Example #1
Source File: utils.py From Watson with MIT License | 5 votes |
def confirm_project(project, watson_projects): """ Ask user to confirm creation of a new project 'project' must be a string 'watson_projects' must be an interable. Returns True on accept and raises click.exceptions.Abort on reject """ if project not in watson_projects: msg = ("Project '%s' does not exist yet. Create it?" % style('project', project)) click.confirm(msg, abort=True) return True
Example #2
Source File: utils.py From Watson with MIT License | 5 votes |
def confirm_tags(tags, watson_tags): """ Ask user to confirm creation of new tags (each separately) Both 'tags' and 'watson_tags" must be iterables. Returns True if all accepted and raises click.exceptions.Abort on reject """ for tag in tags: if tag not in watson_tags: msg = "Tag '%s' does not exist yet. Create it?" % style('tag', tag) click.confirm(msg, abort=True) return True
Example #3
Source File: cli.py From Zappa with MIT License | 5 votes |
def unschedule(self): """ Given a a list of scheduled functions, tear down their regular execution. """ # Run even if events are not defined to remove previously existing ones (thus default to []). events = self.stage_config.get('events', []) if not isinstance(events, list): # pragma: no cover print("Events must be supplied as a list.") return function_arn = None try: function_response = self.zappa.lambda_client.get_function(FunctionName=self.lambda_name) function_arn = function_response['Configuration']['FunctionArn'] except botocore.exceptions.ClientError as e: # pragma: no cover raise ClickException("Function does not exist, you should deploy first. Ex: zappa deploy {}. " "Proceeding to unschedule CloudWatch based events.".format(self.api_stage)) print("Unscheduling..") self.zappa.unschedule_events( lambda_name=self.lambda_name, lambda_arn=function_arn, events=events, ) # Remove async task SNS if self.stage_config.get('async_source', None) == 'sns' \ and self.stage_config.get('async_resources', True): removed_arns = self.zappa.remove_async_sns_topic(self.lambda_name) click.echo('SNS Topic removed: %s' % ', '.join(removed_arns))
Example #4
Source File: utils.py From newrelic-lambda-cli with Apache License 2.0 | 5 votes |
def catch_boto_errors(func): def _boto_error_wrapper(*args, **kwargs): try: return func(*args, **kwargs) except botocore.exceptions.NoRegionError: error( "You must specify a region. Pass `--aws-region` or run `aws configure`." ) except botocore.exceptions.NoCredentialsError: error("No AWS credentials configured. Did you run `aws configure`?") except botocore.exceptions.BotoCoreError as e: error("Unexpected AWS error: %s" % e) return _boto_error_wrapper
Example #5
Source File: utils.py From newrelic-lambda-cli with Apache License 2.0 | 5 votes |
def validate_aws_profile(ctx, param, value): """A click callback to validate that an AWS profile exists""" try: boto3.Session(profile_name=value) except botocore.exceptions.ProfileNotFound as e: raise click.BadParameter(e.fmt) else: return value