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

Python logger.debug函数代码示例

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

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



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

示例1: logout

def logout(request):
    logger.debug(request)
    django_logout(request)
    if request.POST.get('cas', False):
        return cas_logoutRedirect()
    RequestContext(request)
    return HttpResponseRedirect(settings.REDIRECT_URL+'/login')
开发者ID:Angelfirenze,项目名称:atmosphere,代码行数:7,代码来源:views.py


示例2: cas_proxyCallback

def cas_proxyCallback(request):
    """
    This is a placeholder for a proxyCallback service
    needed for CAS authentication
    """
    logger.debug("Incoming request to CASPROXY (Proxy Callback):")
    return HttpResponse("I am at a RSA-2 or VeriSigned SSL Cert. website.")
开发者ID:420reich,项目名称:atmosphere,代码行数:7,代码来源:cas.py


示例3: _get_openstack_name_map

def _get_openstack_name_map(status_name, task_name, tmp_status):
    new_status = None
    if task_name:
        new_status = OPENSTACK_TASK_STATUS_MAP.get(task_name)

    if new_status:
        logger.debug("Task provided:%s, Status maps to %s"
                     % (task_name, new_status))
    elif tmp_status:
        # ASSERT: task_name = None
        new_status = OPENSTACK_TASK_STATUS_MAP.get(tmp_status)
        logger.debug(
            "Tmp_status provided:%s, Status maps to %s" %
            (tmp_status, new_status))
    if not new_status:
        # ASSERT: tmp_status = None
        return status_name
    # ASSERT: new_status exists.
    # Determine precedence/override based on status_name.
    if status_name in OPENSTACK_ACTIVE_STATES:
        return new_status
    else:
        # This covers cases like 'shutoff - deploy_error' being marked as
        # 'shutoff'
        return status_name
开发者ID:bollig,项目名称:atmosphere,代码行数:25,代码来源:instance.py


示例4: 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


示例5: delete_project_member

 def delete_project_member(self, groupname, username, adminRole=False):
     """
     Retrieves the project and user object
     Removes user of the admin/member role
     Returns True on success
     Invalid username, groupname, rolename:
         raise keystoneclient.exceptions.NotFound
     """
     project = self.get_project(groupname)
     user = self.get_user(username)
     #FIXME: Hardcoded values
     if adminRole:
         role = self.get_role('admin')
     else:
         role = self.get_role('defaultMemberRole')
     if not project or not user:
         return True
     try:
         project.remove_user(user, role)
         return True
     except NotFound as no_role_for_user:
         logger.debug('Error - %s: User-role combination does not exist' %
                      no_role_for_user)
         return True
     except Exception, e:
         logger.exception(e)
         raise
开发者ID:iPlantCollaborativeOpenSource,项目名称:rtwo,代码行数:27,代码来源:openstack_user.py


示例6: get_context_user

def get_context_user(serializer, kwargs, required=False):
    context = kwargs.get('context',{})
    user = context.get('user')
    request = context.get('request')
    if not user and not request:
        print_str = "%s was initialized"\
                    " without appropriate context."\
                    " Sometimes, like on imports, this is normal."\
                    " For complete results include the \"context\" kwarg,"\
                    " with key \"request\" OR \"user\"."\
                    " (e.g. context={\"user\":user,\"request\":request})"\
                    % (serializer,)
        if required:
            raise Exception(print_str)
        else:
            logger.debug("Incomplete Data Warning:%s" % print_str)
            return None
    if user:
        #NOTE: Converting str to atmosphere user is easier when debugging
        if type(user) == str:
            user = AtmosphereUser.objects.get(
                    username=user)
        elif type(user) not in [AnonymousUser,AtmosphereUser]:
            raise Exception("This Serializer REQUIRES the \"user\" "
                            "to be of type str or AtmosphereUser")
    elif request:
        user = request.user
    if user:
        logger.debug("%s initialized with user %s"
                     % (serializer, user))
    return user
开发者ID:Spencerx,项目名称:atmosphere,代码行数:31,代码来源:serializers.py


示例7: wait_for

def wait_for(instance_alias, driverCls, provider, identity, status_query,
        tasks_allowed=False, return_id=False, **task_kwargs):
    """
    #Task makes 250 attempts to 'look at' the instance, waiting 15sec each try
    Cumulative time == 1 hour 2 minutes 30 seconds before FAILURE

    status_query = "active" Match only one value, active
    status_query = ["active","suspended"] or match multiple values.
    """
    from service import instance as instance_service
    try:
        logger.debug("wait_for task started at %s." % datetime.now())
        if app.conf.CELERY_ALWAYS_EAGER:
            logger.debug("Eager task - DO NOT return until its ready!")
            return _eager_override(wait_for, _is_instance_ready, 
                                    (driverCls, provider, identity,
                                     instance_alias, status_query,
                                     tasks_allowed, return_id), {})

        result = _is_instance_ready(driverCls, provider, identity,
                                  instance_alias, status_query,
                                  tasks_allowed, return_id)
        return result
    except Exception as exc:
        if "Not Ready" not in str(exc):
            # Ignore 'normal' errors.
            logger.exception(exc)
        wait_for.retry(exc=exc)
开发者ID:prodigeni,项目名称:atmosphere,代码行数:28,代码来源:driver.py


示例8: sync_cloud_access

def sync_cloud_access(accounts, img, project_names=None):
    domain_id = accounts.credentials.get('domain_name', 'default')
    approved_projects = accounts.get_image_members(img.id)
    # Any names who aren't already on the image should be added
    # Find names who are marked as 'sharing' on DB but not on OpenStack
    for project_name in project_names:
        # FIXME: Remove .strip() when 'bug' has been fixed
        group_name = project_name.strip(
        )    # FIXME: This code should be changed when user-group-project associations change.
        try:
            group = models.Group.objects.get(name=group_name)
        except:
            raise Exception("Invalid group name: %s" % group_name)
        for identity_membership in group.identitymembership_set.all():
            if identity_membership.identity.provider != accounts.core_provider:
                logger.debug(
                    "Skipped %s -- Wrong provider" %
                    identity_membership.identity
                )
                continue
            # Get project name from the identity's credential-list
            identity = identity_membership.identity
            project_name = identity.get_credential('ex_project_name')
            project = accounts.get_project(project_name, domain_id=domain_id)
            if not project or project in approved_projects:
                logger.debug("Skipped Project: %s -- Already shared" % project)
                continue
            project = accounts.share_image_with_identity(img, identity)
            approved_projects.append(project)
    return approved_projects
开发者ID:iPlantCollaborativeOpenSource,项目名称:atmosphere,代码行数:30,代码来源:machine.py


示例9: get_default_provider

def get_default_provider(username):
    """
    Return default provider given 
    """
    try:
        from core.models.group import get_user_group
        group = get_user_group(username)
        provider = group.providers.filter(
            Q(end_date=None) | Q(end_date__gt=timezone.now()),
            active=True, type__name="OpenStack")
        if provider:
            provider = provider[0]
        else:
            logger.error("get_default_provider could not find "
                         "a valid Provider")
            return None
        logger.debug(
            "default provider is %s " % provider)
        return provider
    except IndexError:
        logger.info("No provider found for %s" % username)
        return None
    except Exception, e:
        logger.exception(e)
        return None
开发者ID:420reich,项目名称:atmosphere,代码行数:25,代码来源:user.py


示例10: 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 Retrieved:%s Does not exist." % (token,))
        return False
    if auth_token.is_expired():
        if request and request.META['REQUEST_METHOD'] == 'POST':
            #See if the user (Or the user who is emulating a user) can be re-authed.
            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.info("Token %s expired, User %s "
                            "could not be reauthenticated in CAS"
                            % (token, user))
                return False
        else:
            logger.debug("Token %s EXPIRED, but allowing User %s to GET data.."
                         % (token, user))
            return True
    else:
        return True
开发者ID:LatinQueen4Life,项目名称:atmosphere,代码行数:35,代码来源:token.py


示例11: _launch_machine

def _launch_machine(driver, identity, machine, size,
        name, userdata_content=None, network=None,
        password=None, token=None, **kwargs):
    if isinstance(driver.provider, EucaProvider):
        #Create/deploy the instance -- NOTE: Name is passed in extras
        logger.info("EUCA -- driver.create_instance EXTRAS:%s" % kwargs)
        esh_instance = driver\
            .create_instance(name=name, image=machine, size=size,
                    ex_userdata=userdata_contents, **kwargs)
    elif isinstance(driver.provider, OSProvider):
        deploy = True
        #ex_metadata, ex_keyname
        extra_args = _extra_openstack_args(identity)
        kwargs.update(extra_args)
        logger.debug("OS driver.create_instance kwargs: %s" % kwargs)
        esh_instance = driver.create_instance(
                name=name, image=machine, size=size,
                token=token, 
                networks=[network], ex_admin_pass=password,
                **kwargs)
        #Used for testing.. Eager ignores countdown
        if app.conf.CELERY_ALWAYS_EAGER:
            logger.debug("Eager Task, wait 1 minute")
            time.sleep(1*60)
    elif isinstance(driver.provider, AWSProvider):
        #TODO:Extra stuff needed for AWS provider here
        esh_instance = driver.deploy_instance(
                name=name, image=machine,
                size=size, deploy=True,
                token=token, **kwargs)
    else:
        raise Exception("Unable to launch with this provider.")
    return (esh_instance, token, password)
开发者ID:Angelfirenze,项目名称:atmosphere,代码行数:33,代码来源:instance.py


示例12: 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


示例13: validate_user

 def validate_user(self, user):
     """
     Validates an account based on the business logic assigned by jetstream.
     In this example:
     * Accounts are *ONLY* valid if they have 1+ 'jetstream' allocations.
     * All other allocations are ignored.
     """
     driver = TASAPIDriver()
     try:
         project_allocations = fill_user_allocation_source_for(driver, user)
         if not project_allocations:
             return False
         return True
     except (NoTaccUserForXsedeException, NoAccountForUsernameException):
         logger.exception('User is invalid: %s', user)
         return False
     except TASAPIException:
         logger.exception(
             'Some other error happened while trying to validate user: %s',
             user
         )
         active_allocation_count = UserAllocationSource.objects.filter(
             only_current_user_allocations() & Q(user=user)
         ).count()
         logger.debug(
             'user: %s, active_allocation_count: %d', user,
             active_allocation_count
         )
         return active_allocation_count > 0
开发者ID:iPlantCollaborativeOpenSource,项目名称:atmosphere,代码行数:29,代码来源:validation.py


示例14: running_instances

def running_instances(network_name, all_instances):
    for instance in all_instances:
        if network_name in instance.extra['addresses'].keys():
            logger.debug("Network %s is in use" % network_name)
            return True
    logger.debug("Network %s is NOT in use" % network_name)
    return False
开发者ID:420reich,项目名称:atmosphere,代码行数:7,代码来源:accounts.py


示例15: provider_filtered_machines

def provider_filtered_machines(request, provider_uuid,
                               identity_uuid, request_user=None):
    """
    Return all filtered machines. Uses the most common,
    default filtering method.
    """
    identity = Identity.objects.filter(uuid=identity_uuid)
    if not identity:
        raise ObjectDoesNotExist()

    try:
        esh_driver = prepare_driver(request, provider_uuid, identity_uuid)
    except Exception:
        # TODO: Observe the change of 'Fail loudly' here
        # and clean up the noise, rather than hide it.
        logger.exception(
            "Driver could not be prepared - Provider: %s , Identity: %s"
            % (provider_uuid, identity_uuid))
        esh_driver = None

    if not esh_driver:
        raise LibcloudInvalidCredsError()

    logger.debug(esh_driver)

    return list_filtered_machines(esh_driver, provider_uuid, request_user)
开发者ID:xuhang57,项目名称:atmosphere,代码行数:26,代码来源:machine.py


示例16: test_capacity

def test_capacity(hypervisor_hostname, instance, hypervisor_stats):
    """
    Test that the hypervisor has the capacity to bring an inactive instance
    back online on the compute node
    """
    #CPU tests first (Most likely bottleneck)
    cpu_total = hypervisor_stats['vcpus']
    cpu_used = hypervisor_stats['vcpus_used']
    cpu_needed = instance.size.cpu
    log_str = "Resource:%s Used:%s Additional:%s Total:%s"\
            % ("cpu", cpu_used, cpu_needed, cpu_total)
    logger.debug(log_str)
    if cpu_used + cpu_needed > cpu_total:
        raise HypervisorCapacityError(hypervisor_hostname, "Hypervisor is over-capacity. %s" % log_str)

    # ALL MEMORY VALUES IN MB
    mem_total = hypervisor_stats['memory_mb']
    mem_used = hypervisor_stats['memory_mb_used']
    mem_needed = instance.size.ram
    log_str = "Resource:%s Used:%s Additional:%s Total:%s"\
            % ("mem", mem_used, mem_needed, mem_total)
    logger.debug(log_str)
    if mem_used + mem_needed > mem_total:
        raise HypervisorCapacityError(hypervisor_hostname, "Hypervisor is over-capacity. %s" % log_str)

    # ALL DISK VALUES IN GB
    disk_total = hypervisor_stats['local_gb']
    disk_used = hypervisor_stats['local_gb_used']
    disk_needed = instance.size.disk + instance.size.ephemeral
    log_str = "Resource:%s Used:%s Additional:%s Total:%s"\
            % ("disk", disk_used, disk_needed, disk_total)
    if disk_used + disk_needed > disk_total:
        raise HypervisorCapacityError(hypervisor_hostname, "Hypervisor is over-capacity. %s" % log_str)
开发者ID:xingningdu,项目名称:atmosphere,代码行数:33,代码来源:instance.py


示例17: get

 def get(self, request, provider_uuid, identity_uuid):
     """
     Using provider and identity, getlist of machines
     TODO: Cache this request
     """
     try:
         request_user = request.user
         logger.debug("filtered_machine_list")
         filtered_machine_list = provider_filtered_machines(request,
                                                            provider_uuid,
                                                            identity_uuid,
                                                            request_user)
     except ProviderNotActive as pna:
         return inactive_provider(pna)
     except LibcloudInvalidCredsError:
         return invalid_creds(provider_uuid, identity_uuid)
     except LibcloudBadResponseError:
         return malformed_response(provider_uuid, identity_uuid)
     except (socket_error, ConnectionFailure):
         return connection_failure(provider_uuid, identity_uuid)
     except ObjectDoesNotExist:
         return invalid_provider_identity(provider_uuid, identity_uuid)
     except Exception as e:
         logger.exception("Unexpected exception for user:%s"
                          % request_user)
         return failure_response(status.HTTP_409_CONFLICT,
                                 e.message)
     serialized_data = ProviderMachineSerializer(filtered_machine_list,
                                                 request_user=request.user,
                                                 many=True).data
     response = Response(serialized_data)
     return response
开发者ID:xuhang57,项目名称:atmosphere,代码行数:32,代码来源:machine.py


示例18: monitor_sizes_for

def monitor_sizes_for(provider_id, print_logs=False):
    """
    Run the set of tasks related to monitoring sizes for a provider.
    Optionally, provide a list of usernames to monitor
    While debugging, print_logs=True can be very helpful.
    start_date and end_date allow you to search a 'non-standard' window of time.
    """
    from service.driver import get_admin_driver

    if print_logs:
        import logging
        import sys
        consolehandler = logging.StreamHandler(sys.stdout)
        consolehandler.setLevel(logging.DEBUG)
        logger.addHandler(consolehandler)

    provider = Provider.objects.get(id=provider_id)
    admin_driver = get_admin_driver(provider)
    # Non-End dated sizes on this provider
    db_sizes = Size.objects.filter(only_current(), provider=provider)
    all_sizes = admin_driver.list_sizes()
    seen_sizes = []
    for cloud_size in all_sizes:
        core_size = convert_esh_size(cloud_size, provider.uuid)
        seen_sizes.append(core_size)

    now_time = timezone.now()
    needs_end_date = [size for size in db_sizes if size not in seen_sizes]
    for size in needs_end_date:
        logger.debug("End dating inactive size: %s" % size)
        size.end_date = now_time
        size.save()

    if print_logs:
        logger.removeHandler(consolehandler)
开发者ID:EmilyCressey,项目名称:atmosphere,代码行数:35,代码来源:monitoring.py


示例19: _task_to_status

 def _task_to_status(self, task_name):
     task_status_map = {
         # Terminate tasks
         #'deleting': 'active',
         # Suspend tasks
         "resuming": "build",
         "suspending": "suspended",
         # Shutdown tasks
         "powering-on": "active",
         "powering-off": "suspended",
         # Instance launch tasks
         "initializing": "build",
         "scheduling": "build",
         "spawning": "build",
         # Atmosphere Task-specific lines
         "networking": "build",
         "deploying": "build",
         "deploy_error": "build",
         # There are more.. Must find table..
     }
     new_status = task_status_map.get(task_name)
     logger.debug(
         "Instance:%s History - Task provided:%s, Status should be %s" % (self.provider_alias, task_name, new_status)
     )
     return new_status
开发者ID:kmeiern,项目名称:atmosphere,代码行数:25,代码来源:instance.py


示例20: update_credential

 def update_credential(cls, identity, c_key, c_value, replace=False):
     from core.models import Credential
     test_key_exists = Credential.objects.filter(
         identity=identity, key=c_key
     )
     if len(test_key_exists) > 1:
         if not replace:
             raise ValueError(
                 "Found multiple entries for Credential: %s on Identity: %s"
                 % (c_key, identity)
             )
         test_key_exists.delete()
     elif test_key_exists:
         # Single selection
         test_key_exists = test_key_exists.get()
         if test_key_exists.value != c_value:
             logger.debug(
                 "Conflicting Key Error: Key:%s Value:%s %s Value:%s" % (
                     c_key, test_key_exists.value,
                     "(to replace with new value, set replace=True) New"
                     if not replace else "Replacement", c_value
                 )
             )
         # No Dupes... But should we really throw an Exception here?
         if not replace:
             return test_key_exists
         test_key_exists.value = c_value
         test_key_exists.save()
         return test_key_exists
     return Credential.objects.get_or_create(
         identity=identity, key=c_key, value=c_value
     )[0]
开发者ID:iPlantCollaborativeOpenSource,项目名称:atmosphere,代码行数:32,代码来源:identity.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python logger.error函数代码示例发布时间:2022-05-27
下一篇:
Python celery_logger.warn函数代码示例发布时间: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