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


Python logger.debug函数代码示例

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


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


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