• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python logger.warn函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中threepio.logger.warn函数的典型用法代码示例。如果您正苦于以下问题:Python warn函数的具体用法?Python warn怎么用?Python warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: validate_new_image

def validate_new_image(image_id, machine_request_id):
    machine_request = MachineRequest.objects.get(id=machine_request_id)
    machine_request.status = 'validating'
    machine_request.save()
    from service.instance import launch_esh_instance
    admin_driver = machine_request.new_admin_driver()
    admin_ident = machine_request.new_admin_identity()
    if not admin_driver:
        logger.warn("Need admin_driver functionality to auto-validate instance")
        return False
    if not admin_ident:
        logger.warn("Need to know the AccountProvider to auto-validate instance")
        return False
    # Attempt to launch using the admin_driver
    admin_driver.identity.user = admin_ident.created_by
    machine = admin_driver.get_machine(image_id)
    small_size = admin_driver.list_sizes()[0]
    (instance, token, password) = launch_esh_instance(
            admin_driver,
            machine.id,
            small_size.id,
            admin_ident,
            'Automated Image Verification - %s' % image_id,
            'atmoadmin',
            using_admin=True)
    return instance.id
开发者ID:420reich,项目名称:atmosphere,代码行数:26,代码来源:machine.py


示例2: get_cached_machine

def get_cached_machine(provider_alias, provider_id):
    if not ProviderMachine.cached_machines:
        build_cached_machines()
    cached_mach = ProviderMachine.cached_machines.get((int(provider_id), provider_alias))
    if not cached_mach:
        logger.warn("Cache does not have machine %s on provider %s" % (provider_alias, provider_id))
    return cached_mach
开发者ID:Cyberlusion,项目名称:Restoring-the-ecosystem,代码行数:7,代码来源:machine.py


示例3: set_instance_from_metadata

def set_instance_from_metadata(esh_driver, core_instance):
    """
    NOT BEING USED ANYMORE.. DEPRECATED..
    """
    # Fixes Dep. loop - Do not remove
    from api.serializers import InstanceSerializer
    # Breakout for drivers (Eucalyptus) that don't support metadata
    if not hasattr(esh_driver._connection, 'ex_get_metadata'):
        # logger.debug("EshDriver %s does not have function 'ex_get_metadata'"
        #            % esh_driver._connection.__class__)
        return core_instance
    try:
        esh_instance = esh_driver.get_instance(core_instance.provider_alias)
        if not esh_instance:
            return core_instance
        metadata = esh_driver._connection.ex_get_metadata(esh_instance)
    except Exception:
        logger.exception("Exception retrieving instance metadata for %s" %
                         core_instance.provider_alias)
        return core_instance

    # TODO: Match with actual instance launch metadata in service/instance.py
    # TODO: Probably best to redefine serializer as InstanceMetadataSerializer
    # TODO: Define a creator and their identity by the METADATA instead of
    # assuming its the person who 'found' the instance

    serializer = InstanceSerializer(core_instance, data=metadata,
                                    partial=True)
    if not serializer.is_valid():
        logger.warn("Encountered errors serializing metadata:%s"
                    % serializer.errors)
        return core_instance
    core_instance = serializer.save()
    core_instance.esh = esh_instance
    return core_instance
开发者ID:bollig,项目名称:atmosphere,代码行数:35,代码来源:instance.py


示例4: invalid_provider

def invalid_provider(provider_id):
    log_message = 'Provider %s is inactive, disabled, or does not exist.'\
        % (provider_id, )
    logger.warn(log_message)
    return failure_response(
        status.HTTP_401_UNAUTHORIZED,
        log_message)
开发者ID:xuhang57,项目名称:atmosphere,代码行数:7,代码来源:exceptions.py


示例5: run

    def run(self, node, client):
        """
        Server-side logging

        Optional Param: attempts - # of times to retry
        in the event of a Non-Zero exit status(code)
        """
        attempt = 0
        retry_time = 0
        while attempt < self.attempts:
            node = super(LoggedScriptDeployment, self).run(node, client)
            if self.exit_status == 0:
                break
            attempt += 1
            retry_time = 2 * 2**attempt  # 4,8,16..
            logger.debug(
                "WARN: Script %s on Node %s is non-zero."
                " Will re-try in %s seconds. Attempt: %s/%s"
                % (node.id, self.name, retry_time, attempt, self.attempts))
            time.sleep(retry_time)

        if self.stdout:
            logger.debug('%s (%s)STDOUT: %s' % (node.id, self.name,
                                                self.stdout))
        if self.stderr:
            logger.warn('%s (%s)STDERR: %s' % (node.id, self.name,
                                               self.stderr))
        return node
开发者ID:catdewey,项目名称:atmosphere,代码行数:28,代码来源:deploy.py


示例6: deploy_init_to

def deploy_init_to(driverCls, provider, identity, instance_id,
                   username=None, password=None, redeploy=False, *args, **kwargs):
    try:
        logger.debug("deploy_init_to task started at %s." % datetime.now())
        driver = get_driver(driverCls, provider, identity)
        instance = driver.get_instance(instance_id)
        if not instance:
            logger.debug("Instance has been teminated: %s." % instance_id)
            return
        image_metadata = driver._connection\
                               .ex_get_image_metadata(instance.machine)
        deploy_chain = get_deploy_chain(driverCls, provider, identity,
                                        instance, username, password, redeploy)
        deploy_chain.apply_async()
        #Can be really useful when testing.
        #if kwargs.get('delay'):
        #    async.get()
        logger.debug("deploy_init_to task finished at %s." % datetime.now())
    except SystemExit:
        logger.exception("System Exits are BAD! Find this and get rid of it!")
        raise Exception("System Exit called")
    except NonZeroDeploymentException:
        raise
    except Exception as exc:
        logger.warn(exc)
        deploy_init_to.retry(exc=exc)
开发者ID:prodigeni,项目名称:atmosphere,代码行数:26,代码来源:driver.py


示例7: _update_volume_metadata

def _update_volume_metadata(esh_driver, esh_volume,
                            metadata={}):
    """
    NOTE: This will NOT WORK for TAGS until openstack
    allows JSONArrays as values for metadata!
    NOTE: This will NOT replace missing metadata tags..
    ex:
    Start: ('a':'value','c':'value')
    passed: c=5
    End: ('a':'value', 'c':5)
    """
    if not esh_volume:
        return {}

    if not hasattr(esh_driver._connection, 'ex_update_volume_metadata'):
        logger.warn(
            "EshDriver %s does not have function 'ex_update_volume_metadata'" %
            esh_driver._connection.__class__)
        return {}
    data = esh_volume.extra.get('metadata', {})
    data.update(metadata)
    try:
        return esh_driver._connection.ex_update_volume_metadata(
            esh_volume,
            data)
    except Exception as e:
        logger.exception("Error updating the metadata")
        if 'incapable of performing the request' in e.message:
            return {}
        else:
            raise
开发者ID:George-wu509,项目名称:atmosphere,代码行数:31,代码来源:volume.py


示例8: patch

 def patch(self, request, provider_id, identity_id, machine_id):
     """
     TODO: Determine who is allowed to edit machines besides
     core_machine.owner
     """
     user = request.user
     data = request.DATA
     esh_driver = prepare_driver(request, provider_id, identity_id)
     if not esh_driver:
         return invalid_creds(provider_id, identity_id)
     esh_machine = esh_driver.get_machine(machine_id)
     core_machine = convert_esh_machine(esh_driver, esh_machine, provider_id)
     if not user.is_staff\
        and user is not core_machine.application.created_by:
         logger.warn('%s is Non-staff/non-owner trying to update a machine'
                     % (user.username))
         return failure_response(
             status.HTTP_401_UNAUTHORIZED,
             "Only Staff and the machine Owner "
             + "are allowed to change machine info.")
     core_machine.application.update(request.DATA)
     serializer = ProviderMachineSerializer(core_machine,
                                            data=data, partial=True)
     if serializer.is_valid():
         logger.info('metadata = %s' % data)
         update_machine_metadata(esh_driver, esh_machine, data)
         serializer.save()
         logger.info(serializer.data)
         return Response(serializer.data)
     return failure_response(
         status.HTTP_400_BAD_REQUEST,
         serializer.errors)
开发者ID:zhanghaihua,项目名称:atmosphere,代码行数:32,代码来源:machine.py


示例9: get_allocation_result_for

def get_allocation_result_for(
        provider, username, print_logs=False, start_date=None, end_date=None):
    """
    Given provider and username:
    * Find the correct identity for the user
    * Create 'Allocation' using core representation
    * Calculate the 'AllocationResult' and return both
    """
    identity = _get_identity_from_tenant_name(provider, username)
    # Attempt to run through the allocation engine
    try:
        allocation_result = _get_allocation_result(
            identity, start_date, end_date,
            print_logs=print_logs)
        logger.debug("Result for Username %s: %s"
                     % (username, allocation_result))
        return allocation_result
    except IdentityMembership.DoesNotExist:
        logger.warn(
            "WARNING: User %s does not"
            "have IdentityMembership on this database" % (username, ))
        return _empty_allocation_result()
    except:
        logger.exception("Unable to monitor Identity:%s"
                         % (identity,))
        raise
开发者ID:catdewey,项目名称:atmosphere,代码行数:26,代码来源:monitoring.py


示例10: get

 def get(self, request, provider_id=None, identity_id=None, action=None):
     """
     """
     if not action:
         errorObj = failureJSON([{
             'code': 400,
             'message': 'Action is not supported.'}])
         return Response(errorObj, status=status.HTTP_400_BAD_REQUEST)
     esh_driver = prepare_driver(request, identity_id)
     esh_meta = esh_driver.meta()
     try:
         if 'test_links' in action:
             test_links = esh_meta.test_links()
             return Response(test_links, status=status.HTTP_200_OK)
     except InvalidCredsError:
         logger.warn('Authentication Failed. Provider-id:%s Identity-id:%s'
                     % (provider_id, identity_id))
         errorObj = failureJSON([{
             'code': 401,
             'message': 'Identity/Provider Authentication Failed'}])
         return Response(errorObj, status=status.HTTP_401_UNAUTHORIZED)
     except NotImplemented, ne:
         logger.exception(ne)
         errorObj = failureJSON([{
             'code': 404,
             'message':
             'The requested resource %s is not available on this provider'
             % action}])
         return Response(errorObj, status=status.HTTP_404_NOT_FOUND)
开发者ID:nickeddy,项目名称:atmosphere,代码行数:29,代码来源:meta.py


示例11: validate_new_image

def validate_new_image(image_id, machine_request_id):
    machine_request = MachineRequest.objects.get(id=machine_request_id)
    machine_request.status = "validating"
    machine_request.save()
    from service.instance import launch_esh_instance

    admin_driver = machine_request.new_admin_driver()
    admin_ident = machine_request.new_admin_identity()
    if not admin_driver:
        logger.warn("Need admin_driver functionality to auto-validate instance")
        return False
    if not admin_ident:
        logger.warn("Need to know the AccountProvider to auto-validate instance")
        return False
    # Update the admin driver's User (Cannot be initialized via. Chromogenic)
    admin_driver.identity.user = admin_ident.created_by
    # Update metadata on rtwo/libcloud machine -- NOT a glance machine
    machine = admin_driver.get_machine(image_id)
    small_size = admin_driver.list_sizes()[0]
    (instance_id, token, password) = launch_esh_instance(
        admin_driver,
        machine.id,
        small_size.id,
        admin_ident,
        "Automated Image Verification - %s" % image_id,
        "atmoadmin",
        using_admin=True,
    )
    return instance_id
开发者ID:prodigeni,项目名称:atmosphere,代码行数:29,代码来源:machine.py


示例12: validate_new_image

def validate_new_image(image_id, machine_request_id):
    machine_request = MachineRequest.objects.get(id=machine_request_id)
    new_status, _ = StatusType.objects.get_or_create(name="validating")
    machine_request.status = new_status
    machine_request.old_status = 'validating'
    machine_request.save()
    accounts = get_account_driver(machine_request.new_machine.provider)
    accounts.clear_cache()
    from service.instance import launch_machine_instance
    admin_driver = accounts.admin_driver
    admin_ident = machine_request.new_admin_identity()
    if not admin_driver:
        logger.warn(
            "Need admin_driver functionality to auto-validate instance")
        return False
    if not admin_ident:
        logger.warn(
            "Need to know the AccountProvider to auto-validate instance")
        return False
    # Attempt to launch using the admin_driver
    admin_driver.identity.user = admin_ident.created_by
    machine = admin_driver.get_machine(image_id)
    small_size = admin_driver.list_sizes()[0]
    instance = launch_machine_instance(
        admin_driver, admin_ident,
        machine, small_size,
        'Automated Image Verification - %s' % image_id,
        username='atmoadmin',
        using_admin=True)
    return instance.id
开发者ID:singkorn,项目名称:atmosphere,代码行数:30,代码来源:machine.py


示例13: _update_machine

    def _update_machine(self, request, provider_uuid, identity_uuid, machine_id):
        # TODO: Determine who is allowed to edit machines besides
        # core_machine.owner
        user = request.user
        data = request.DATA
        esh_driver = prepare_driver(request, provider_uuid, identity_uuid)
        if not esh_driver:
            return invalid_creds(provider_uuid, identity_uuid)
        esh_machine = esh_driver.get_machine(machine_id)
        core_machine = convert_esh_machine(esh_driver, esh_machine, provider_uuid, user)
        if not user.is_staff and user is not core_machine.application_version.application.created_by:
            logger.warn("%s is Non-staff/non-owner trying to update a machine" % (user.username))
            return failure_response(
                status.HTTP_401_UNAUTHORIZED, "Only Staff and the machine Owner " "are allowed to change machine info."
            )

        partial_update = True if request.method == "PATCH" else False
        serializer = ProviderMachineSerializer(
            core_machine, request_user=request.user, data=data, partial=partial_update
        )
        if serializer.is_valid():
            logger.info("metadata = %s" % data)
            update_machine_metadata(esh_driver, esh_machine, data)
            machine = serializer.save()
            if "created_by_identity" in request.DATA:
                identity = machine.created_by_identity
                update_application_owner(core_machine.application_version.application, identity)
            logger.info(serializer.data)
            return Response(serializer.data)
        return failure_response(status.HTTP_400_BAD_REQUEST, serializer.errors)
开发者ID:EmilyCressey,项目名称:atmosphere,代码行数:30,代码来源:machine.py


示例14: lookupEmail

def lookupEmail(userid):
    """
    Grabs email for the user based on LDAP attrs
    """
    try:
        logger.debug(type(userid))
        if isinstance(userid, WSGIRequest):
            raise Exception("WSGIRequest invalid.")
        attr = _search_ldap(userid)
        emailaddr = attr[0][1]["mail"][0]
        return emailaddr
    except Exception as e:
        logger.warn("Error occurred looking up email for user: %s" % userid)
        logger.exception(e)
        import traceback
        import sys
        import inspect

        s = inspect.stack()
        for i in range(0, 4):
            logger.debug(s[i])
        etype, value, tb = sys.exc_info()
        logger.error("TB = %s" % traceback.format_tb(tb))

        return None
开发者ID:420reich,项目名称:atmosphere,代码行数:25,代码来源:ldap.py


示例15: has_permission

 def has_permission(self, request, view):
     auth_user = request.user
     project_uuid = view.kwargs.get("project_uuid")
     if not project_uuid:
         logger.warn("Could not find kwarg:'project_uuid'")
         return False
     return any(group for group in auth_user.group_set.all() if group.projects.filter(uuid=project_uuid))
开发者ID:Angelfirenze,项目名称:atmosphere,代码行数:7,代码来源:permissions.py


示例16: glance_image_owner

def glance_image_owner(provider_uuid, identifier, glance_image=None):
    try:
        prov = Provider.objects.get(uuid=provider_uuid)
        accounts = get_account_driver(prov)
        if not glance_image:
            accounts.clear_cache()
            glance_image = accounts.get_image(identifier)
        project = accounts.user_manager.get_project_by_id(
            glance_image.get('owner')
        )
    except Exception as e:
        logger.exception(e)
        project = None

    if not project:
        return None
    try:
        image_owner = Identity.objects.get(
            provider__uuid=provider_uuid, created_by__username=project.name
        )
    except Identity.DoesNotExist:
        logger.warn(
            "Could not find a username %s on Provider %s" %
            (project.name, provider_uuid)
        )
        image_owner = None
    return image_owner
开发者ID:iPlantCollaborativeOpenSource,项目名称:atmosphere,代码行数:27,代码来源:openstack.py


示例17: _send_instance_email

def _send_instance_email(driverCls, provider, identity, instance_id):
    try:
        logger.debug("_send_instance_email task started at %s." %
                     datetime.now())
        driver = get_driver(driverCls, provider, identity)
        instance = driver.get_instance(instance_id)
        #Breakout if instance has been deleted at this point
        if not instance:
            logger.debug("Instance has been teminated: %s." % instance_id)
            return
        username = identity.user.username
        profile = UserProfile.objects.get(user__username=username)
        if profile.send_emails:
            #Only send emails if allowed by profile setting
            created = datetime.strptime(instance.extra['created'],
                                        "%Y-%m-%dT%H:%M:%SZ")
            send_instance_email(username,
                                instance.id,
                                instance.name,
                                instance.ip,
                                created,
                                username)
        else:
            logger.debug("User %s elected NOT to receive new instance emails"
                         % username)

        logger.debug("_send_instance_email task finished at %s." %
                     datetime.now())
    except Exception as exc:
        logger.warn(exc)
        _send_instance_email.retry(exc=exc)
开发者ID:prodigeni,项目名称:atmosphere,代码行数:31,代码来源:driver.py


示例18: update_instance_metadata

def update_instance_metadata(esh_driver, esh_instance, data={}, replace=True):
    """
    NOTE: This will NOT WORK for TAGS until openstack
    allows JSONArrays as values for metadata!
    """
    wait_time = 1
    if not esh_instance:
        return {}
    instance_id = esh_instance.id

    if not hasattr(esh_driver._connection, 'ex_set_metadata'):
        logger.warn("EshDriver %s does not have function 'ex_set_metadata'"
                    % esh_driver._connection.__class__)
        return {}
    if esh_instance.extra['status'] == 'build':
        raise Exception("Metadata cannot be applied while EshInstance %s is in"
                        " the build state." % (esh_instance,))
    # ASSERT: We are ready to update the metadata
    if data.get('name'):
        esh_driver._connection.ex_set_server_name(esh_instance, data['name'])
    try:
        return esh_driver._connection.ex_set_metadata(esh_instance, data,
                replace_metadata=replace)
    except Exception, e:
        logger.exception("Error updating the metadata")
        if 'incapable of performing the request' in e.message:
            return {}
        else:
            raise
开发者ID:xingningdu,项目名称:atmosphere,代码行数:29,代码来源:instance.py


示例19: validate

 def validate(self, core_identity):
     identity_creds = core_identity.get_all_credentials()
     if 'router_name' not in identity_creds.keys():
         logger.warn("Credential 'router_name' missing:"
                     "cannot create user network")
         raise Exception("Identity %s has not been assigned a 'router_name'" % core_identity)
     return True
开发者ID:xuhang57,项目名称:atmosphere,代码行数:7,代码来源:networking.py


示例20: validate_token

def validate_token(token, request=None):
    """
    Validates the token attached to the request (SessionStorage, GET/POST)
    If token has expired,
    CAS will attempt to reauthenticate the user and refresh token.
    Expired Tokens can be used for GET requests ONLY!
    """

    #Existence test
    try:
        auth_token = AuthToken.objects.get(key=token)
        user = auth_token.user
    except AuthToken.DoesNotExist:
        #logger.info("AuthToken <%s> does not exist." % token)
        return False
    if auth_token.is_expired():
        if request and request.META['REQUEST_METHOD'] == 'POST':
            user_to_auth = request.session.get('emulated_by', user)
            if cas_validateUser(user_to_auth):
                #logger.debug("Reauthenticated user -- Token updated")
                auth_token.update_expiration()
                auth_token.save()
                return True
            else:
                logger.warn("Could not reauthenticate user")
                return False
        else:
            #logger.debug("%s using EXPIRED token to GET data.." % user)
            return True
    else:
        return True
开发者ID:Tomasbruno,项目名称:atmosphere,代码行数:31,代码来源:token.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python thrift.TSerialization类代码示例发布时间:2022-05-27
下一篇:
Python logger.info函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap