當前位置: 首頁>>代碼示例>>Python>>正文


Python click.exceptions方法代碼示例

本文整理匯總了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 
開發者ID:TailorDev,項目名稱:Watson,代碼行數:14,代碼來源:utils.py

示例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 
開發者ID:TailorDev,項目名稱:Watson,代碼行數:13,代碼來源:utils.py

示例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)) 
開發者ID:Miserlou,項目名稱:Zappa,代碼行數:36,代碼來源:cli.py

示例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 
開發者ID:newrelic,項目名稱:newrelic-lambda-cli,代碼行數:16,代碼來源:utils.py

示例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 
開發者ID:newrelic,項目名稱:newrelic-lambda-cli,代碼行數:10,代碼來源:utils.py


注:本文中的click.exceptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。