本文整理汇总了Python中click.exceptions方法的典型用法代码示例。如果您正苦于以下问题:Python click.exceptions方法的具体用法?Python click.exceptions怎么用?Python click.exceptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类click
的用法示例。
在下文中一共展示了click.exceptions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: confirm_project
# 需要导入模块: import click [as 别名]
# 或者: from click import exceptions [as 别名]
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
示例2: confirm_tags
# 需要导入模块: import click [as 别名]
# 或者: from click import exceptions [as 别名]
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
示例3: unschedule
# 需要导入模块: import click [as 别名]
# 或者: from click import exceptions [as 别名]
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))
示例4: catch_boto_errors
# 需要导入模块: import click [as 别名]
# 或者: from click import exceptions [as 别名]
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
示例5: validate_aws_profile
# 需要导入模块: import click [as 别名]
# 或者: from click import exceptions [as 别名]
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