当前位置: 首页>>代码示例>>Python>>正文


Python exception.BotoServerError方法代码示例

本文整理汇总了Python中boto.exception.BotoServerError方法的典型用法代码示例。如果您正苦于以下问题:Python exception.BotoServerError方法的具体用法?Python exception.BotoServerError怎么用?Python exception.BotoServerError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boto.exception的用法示例。


在下文中一共展示了exception.BotoServerError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _mws_send

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def _mws_send(self, mws_send, syncs, sync_values):
        log_template = "about to call MWS send() for product syncs."
        _logger.debug(log_template.format(len(sync_values)))

        try:
            results = mws_send(sync_values)
            sync_result = self._convert_results(results)
            ProductSyncAccess.update_sync_status(syncs, sync_result)
        except BotoServerError as boto_ex:
            _logger.debug("MWS Request error: {}".format(
                boto_ex.error_code))
            if boto_ex.error_code in ["RequestThrottled",
                                      "ServiceUnavailable"]:
                _logger.debug("Continue with throttled or unavailable error.")
            else:
                ProductSyncAccess.update_sync_new_exception(syncs, boto_ex)
        except Exception as ex:
            # we may want to re-try for recoverable exceptions
            # for now, just report error
            _logger.exception("mws send() threw exception.")
            ProductSyncAccess.update_sync_new_exception(syncs, ex) 
开发者ID:amdeb,项目名称:amdeb-amazon,代码行数:23,代码来源:product_sync_new.py

示例2: get_messages_from_queue

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def get_messages_from_queue(self):
        """ Fetches messages from the sqs queue of name passed in during this
        object's construction.
        Does not handle exceptions from Boto.

        :rtype: a list of SQS message or None
        """
        try:
            msgs = self._queue.get_messages(
                num_messages=self._num_messages_to_fetch,
                wait_time_seconds=self._wait_time_secs)
            return msgs
        except (BotoClientError, BotoServerError):
            log_exception(
                "Boto exception in fetching messages from SQS, for queue name:"
                + self._queue.id)
            raise 
开发者ID:Yelp,项目名称:mycroft,代码行数:19,代码来源:sqs_wrapper.py

示例3: throttling_retry

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def throttling_retry(func):
    """Retry when AWS is throttling API calls"""

    def retry_call(*args, **kwargs):
        retries = 0
        while True:
            try:
                retval = func(*args)
                return retval
            except BotoServerError as err:
                if (err.code == 'Throttling' or err.code == 'RequestLimitExceeded') and retries <= 3:
                    sleep = 3 * (2 ** retries)
                    print('Being throttled. Retrying after {} seconds..'.format(sleep))
                    time.sleep(sleep)
                    retries += 1
                else:
                    raise err

    return retry_call 
开发者ID:cfstacks,项目名称:stacks,代码行数:21,代码来源:aws.py

示例4: stack_resources

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def stack_resources(conn, stack_name, logical_resource_id=None):
    """List stack resources"""
    try:
        result = conn.describe_stack_resources(stack_name_or_id=stack_name,
                                               logical_resource_id=logical_resource_id)
    except BotoServerError as err:
        print(err.message)
        sys.exit(1)
    resources = []
    if logical_resource_id:
        resources.append([r.physical_resource_id for r in result])
    else:
        for r in result:
            columns = [
                r.logical_resource_id,
                r.physical_resource_id,
                r.resource_type,
                r.resource_status,
            ]
            resources.append(columns)

    if len(result) >= 1:
        return tabulate(resources, tablefmt='plain')
    return None 
开发者ID:cfstacks,项目名称:stacks,代码行数:26,代码来源:cf.py

示例5: stack_outputs

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def stack_outputs(conn, stack_name, output_name):
    """List stacks outputs"""
    try:
        result = conn.describe_stacks(stack_name)
    except BotoServerError as err:
        print(err.message)
        sys.exit(1)

    outputs = []
    outs = [s.outputs for s in result][0]
    for o in outs:
        if not output_name:
            columns = [o.key, o.value]
            outputs.append(columns)
        elif output_name and o.key == output_name:
            outputs.append([o.value])

    if len(result) >= 1:
        return tabulate(outputs, tablefmt='plain')
    return None 
开发者ID:cfstacks,项目名称:stacks,代码行数:22,代码来源:cf.py

示例6: delete_stack

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def delete_stack(conn, stack_name, region, profile, confirm):
    """Deletes stack given its name"""
    msg = ('You are about to delete the following stack:\n'
           'Name: {}\n'
           'Region: {}\n'
           'Profile: {}\n').format(stack_name, region, profile)
    if not confirm:
        print(msg)
        response = input('Are you sure? [y/N] ')
    else:
        response = 'yes'

    if response in YES:
        try:
            conn.delete_stack(stack_name)
        except BotoServerError as err:
            if 'does not exist' in err.message:
                print(err.message)
                sys.exit(0)
            else:
                print(err.message)
                sys.exit(1)
    else:
        sys.exit(0) 
开发者ID:cfstacks,项目名称:stacks,代码行数:26,代码来源:cf.py

示例7: setup_iam_ec2_role

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def setup_iam_ec2_role(self, role_name, policies):
        aws_role_name = self.to_aws_name(role_name)
        try:
            self.iam.create_role(aws_role_name, assume_role_policy_document=json.dumps({
                "Version": "2012-10-17",
                "Statement": [{
                    "Effect": "Allow",
                    "Principal": {"Service": ["ec2.amazonaws.com"]},
                    "Action": ["sts:AssumeRole"]}
                ]}))
        except BotoServerError as e:
            if e.status == 409 and e.error_code == 'EntityAlreadyExists':
                pass
            else:
                raise

        self.__setup_entity_policies(aws_role_name, policies,
                                     list_policies=self.iam.list_role_policies,
                                     delete_policy=self.iam.delete_role_policy,
                                     get_policy=self.iam.get_role_policy,
                                     put_policy=self.iam.put_role_policy)

        return aws_role_name 
开发者ID:DataBiosphere,项目名称:toil,代码行数:25,代码来源:context.py

示例8: create_cf_stack

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def create_cf_stack(cf_conn, stack_name, cf_template_path, availability_zone):
    try:
        if len(cf_conn.describe_stacks(stack_name)) > 0:
            print "Stack '{n}' already exists. Reusing.".format(n=stack_name)
            return
    except BotoServerError:
        # stack does not exist
        pass

    print "Creating stack with name '{n}'.".format(n=stack_name)
    with open(cf_template_path, 'r') as template_file:
        template_body = template_file.read()
    cf_conn.create_stack(stack_name, template_body=template_body,
                         parameters=[('KeyPairName', get_ec2_key_pair()),
                                     ('AZ', availability_zone)],
                         tags={'owner': getuser(),
                               'ec2_key_pair': get_ec2_key_pair()})
    wait_for_stack_status(cf_conn, stack_name, 'CREATE_COMPLETE') 
开发者ID:bigdatagenomics,项目名称:eggo,代码行数:20,代码来源:aws.py

示例9: create_session

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def create_session():
    metadata = request.app.config.meta_get('metadata', 'obj')
    token = _get_value(request, 'token')
    profile = _get_value(request, 'profile')

    if not token and not profile:
        response.status = 400
        return {
            'error': {
                'message': 'token and/or profile is required'
            }
        }

    if profile:
        metadata.profile_name = profile

    if token:
        try:
            request.app.config.meta_get('metadata', 'obj').get_session(token)
        except BotoServerError as e:
            response.status = e.status
            return {'error': {'message': e.message}}

    return get_session() 
开发者ID:dump247,项目名称:aws-mock-metadata,代码行数:26,代码来源:routes.py

示例10: main

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def main():
    if len(sys.argv) > 2:
        printUsage()
        raise SystemExit(1)

    try:
        section = sys.argv[1]
    except IndexError:
        section = 'default'

    credentials = CredentialsFile(section)

    iam = IAMConnection(
        aws_access_key_id=credentials.keyId,
        aws_secret_access_key=credentials.secretKey,
    )

    userName = getUserName(iam)
    deleteOldKeys(iam, credentials.keyId, userName)
    newKey = makeNewKey(iam, userName)

    iam = IAMConnection(
        aws_access_key_id=newKey['access_key_id'],
        aws_secret_access_key=newKey['secret_access_key'],
    )

    oldKey = credentials.keyId
    try:
        deactivateKey(iam, oldKey, userName)
    except BotoServerError as e:
        print(e)
        raise SystemExit(dedent('''
        Failed to deactivate the old key (%s) after one minute of
        retrying. Manual remediation will be required.
        %s
        ''' % (oldKey, ACCESS_KEY_DOCS)).strip())

    credentials.updateCredentials(
        newKey['access_key_id'],
        newKey['secret_access_key'],
    ) 
开发者ID:makethunder,项目名称:awsudo,代码行数:43,代码来源:rotate.py

示例11: get_messages

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def get_messages(self, num_messages, wait_time_seconds):
        if self.exception:
            raise BotoServerError(503, "test")
        return [] if self.msgs is None else self.msgs 
开发者ID:Yelp,项目名称:mycroft,代码行数:6,代码来源:test_sqs_wrapper.py

示例12: test_get_messages_exception_thrown_out

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def test_get_messages_exception_thrown_out(get_mock_boto):
    fake_conn = FakeConn()
    fake_queue = FakeQueue()
    fake_conn.set_queue(fake_queue)
    fake_queue.exception = True  # set it to throw boto error
    mock_obj = get_mock_boto
    mock_obj.return_value = fake_conn
    sqs = SQSWrapper("some-queue", None)
    with pytest.raises(BotoServerError):
        sqs.get_messages_from_queue()
    mock_obj.assert_called_once_with('us-west-2', **get_test_creds()) 
开发者ID:Yelp,项目名称:mycroft,代码行数:13,代码来源:test_sqs_wrapper.py

示例13: _does_stack_exist

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def _does_stack_exist(self, conn):
        try:
            if len(conn.describe_stacks(stack_name_or_id=self._stack_name)) > 0:
                return True
        except BotoServerError:
            # Describing will raise a server error if the stack doesn't exist
            pass
        return False 
开发者ID:Yelp,项目名称:mycroft,代码行数:10,代码来源:create_mycroft.py

示例14: get_stack_template

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def get_stack_template(conn, stack_name):
    """Return a template body of live stack"""
    try:
        template = conn.get_template(stack_name)
        return template['GetTemplateResponse']['GetTemplateResult']['TemplateBody'], []
    except BotoServerError as e:
        return None, [e.message] 
开发者ID:cfstacks,项目名称:stacks,代码行数:9,代码来源:aws.py

示例15: __new__

# 需要导入模块: from boto import exception [as 别名]
# 或者: from boto.exception import BotoServerError [as 别名]
def __new__(cls, *args, **kw):
        error = BotoServerError(*args, **kw)
        newclass = globals().get(error.error_code, ResponseError)
        obj = newclass.__new__(newclass, *args, **kw)
        obj.__dict__.update(error.__dict__)
        return obj 
开发者ID:VirtueSecurity,项目名称:aws-extender,代码行数:8,代码来源:exception.py


注:本文中的boto.exception.BotoServerError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。