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


Python logger.debug函数代码示例

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


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

示例1: add_user_to_registered_group

def add_user_to_registered_group(sender, **kwargs):
    """
    Add any user created on the system to the `registered` group.

    This signal must be called by the post_save signal from the User class.
    This signal also creates a public profile for the user if it does not exist.
    """
    if 'created' in kwargs and kwargs['created'] is True:

        user = kwargs['instance']

        # Add user to registered group
        group, created = Group.objects.get_or_create(name='registered')
        user.groups.add(group)

        sid = transaction.savepoint()

        # Create Public Profile
        try:
            profile, created = Profile.objects.get_or_create(user=user)
            profile.save()
            transaction.savepoint_commit(sid)
        except:
            logger.debug("User profile not created.")
            transaction.savepoint_rollback(sid)

    transaction.commit()
开发者ID:hfeeki,项目名称:transifex,代码行数:27,代码来源:listeners.py

示例2: search

def search(request):
    query_string = prepare_solr_query_string(request.GET.get('q', ""))
    search_terms = query_string.split()
    index_query = SearchQuerySet().models(Project)
    spelling_suggestion = None

    if not FULLTEXT:
        try:
            results = index_query.auto_query(query_string)
            count = results.count()
        except TypeError:
            count = 0
    else:
        try:
            qfilter = fulltext_project_search_filter(query_string)
            results = index_query.filter(qfilter)
            spelling_suggestion = results.spelling_suggestion(query_string)
            count = results.count()
        except TypeError:
            results = []
            count = 0

    logger.debug("Searched for %s. Found %s results." % (query_string, count))
    return render_to_response("search.html",
        {'query': query_string,
         'terms': search_terms,
         'results': results,
         'spelling_suggestion': spelling_suggestion},
          context_instance = RequestContext(request))
开发者ID:593in,项目名称:transifex,代码行数:29,代码来源:views.py

示例3: post_resource_save_handler

def post_resource_save_handler(sender, instance, created, user, **kwargs):
    if settings.ENABLE_NOTICES:
        resource = instance
        project = resource.project
        users = [
            watch.user
            for watch in notification.ObservedItem.objects.filter(
                content_type__model="project", object_id=project.id, signal="project_changed"
            ).select_related("user")
        ]
        for user in users:
            try:
                notification.ObservedItem.objects.get_for(resource.project, user, "project_changed")
                if created:
                    for signal in resource_signals:
                        try:
                            notification.ObservedItem.objects.get_for(resource, user, signal)
                        except notification.ObservedItem.DoesNotExist:
                            notification.observe(resource, user, signal, signal)
                    nt = "project_resource_added"
                else:
                    nt = "project_resource_changed"
                project = resource.project
                _notify_resourcewatchers(project, resource, nt)
            except notification.ObservedItem.DoesNotExist, e:
                logger.debug("Watches: %s" % unicode(e))
开发者ID:qikh,项目名称:transifex,代码行数:26,代码来源:handlers.py

示例4: msgfmt_check

def msgfmt_check(po_contents, ispot=False, with_exceptions=True):
    """
    Run a `msgfmt -c` on the file contents.

    Raise a FileCheckError in case the stderror has errors/warnings or
    the command execution returns Error.
    """
    try:
        if ispot:
            command = "msgfmt -o /dev/null --check-format --check-domain -"
        else:
            command = "msgfmt -o /dev/null -c -"
        status, stdout, stderr = run_command(
            command, _input=po_contents, with_extended_output=True, with_exceptions=with_exceptions
        )
        # Not sure why msgfmt sends its output to stderr instead of stdout
        # if 'warning:' in stderr or 'too many errors, aborting' in stderr:
        if "too many errors, aborting" in stderr:
            raise CommandError(command, status, stderr)
    except CommandError:
        logger.debug("pofile: The 'msgfmt -c' check failed.")
        raise FileCheckError, ugettext(
            "Your file failed a correctness check "
            "(msgfmt -c). Please run this command on "
            "your system to see the errors."
        )
开发者ID:hfeeki,项目名称:transifex,代码行数:26,代码来源:pofile.py

示例5: handle_exception_mailing

def handle_exception_mailing(request, exception):
    """Handle an exception if in production mode."""
    exc_info = sys.exc_info()
    subject, message = exception_email(request, exc_info)
    if not settings.DEBUG:
        logger.debug('Sending handled exception to admins.')
        mail_admins(('%s - %s') % (subject, exception.message), message,
            fail_silently=True)
开发者ID:593in,项目名称:transifex,代码行数:8,代码来源:__init__.py

示例6: priority_creation

def priority_creation(**kwargs):
    """Create the default priority on Resource creation."""
    if 'created' in kwargs and kwargs['created'] is True:
        resource = kwargs['instance']
        if resource:
            ResourcePriority.objects.create(resource=resource)
            logger.debug("Resource %s: New ResourcePriority created." % (
                         resource.name))
开发者ID:593in,项目名称:transifex,代码行数:8,代码来源:handlers.py

示例7: delete

 def delete(self, *args, **kwargs):
     """
     Delete file from filesystem even if object has not been saved yet.
     """
     try:
         os.remove(self.get_storage_path())
     except OSError, e:
         if self.id:
             logger.debug("Error deleting StorageFile: %s" % str(e))
开发者ID:rvanlaar,项目名称:easy-transifex,代码行数:9,代码来源:models.py

示例8: _get_stats

 def _get_stats(self, request, pslug, rslug, lang_code):
     try:
         resource = Resource.objects.get(project__slug=pslug, slug=rslug)
     except Resource.DoesNotExist, e:
         logger.debug(
             "Resource %s.%s requested, but it does not exist" % (pslug, rslug),
             exc_info=True
         )
         return rc.NOT_FOUND
开发者ID:tymofij,项目名称:adofex,代码行数:9,代码来源:__init__.py

示例9: combine_strings

 def combine_strings(source_entities, language):
     source_entities = list(source_entities)
     result = old_get_strings(source_entities, language)
     for entity in source_entities:
         if not result.get(entity, None):
             trans = handler._get_translation(entity, source_language, 5)
             if trans:
                 logger.debug(trans.string)
                 result[entity] = trans.string
     return result
开发者ID:rmoorman,项目名称:transifex-adofex,代码行数:10,代码来源:views.py

示例10: _notify_resourcewatchers

def _notify_resourcewatchers(project, resource, signal):
    """
    Notify watchers of a resource add/change
    """
    context = {"project": project, "resource": resource}
    logger.debug("addon-watches: Sending notification for '%s'" % resource)
    if signal == "project_resource_added":
        observed_instance = project
    else:
        observed_instance = resource
    txnotification.send_observation_notices_for(observed_instance, signal=signal, extra_context=context)
开发者ID:qikh,项目名称:transifex,代码行数:11,代码来源:handlers.py

示例11: delete

 def delete(self, request, uuid=None, api_version=1):
     """
     Deletes file by storage UUID
     """
     if request.user.is_anonymous():
         return rc.FORBIDDEN
     try:
         StorageFile.objects.get(uuid=uuid, user=request.user).delete()
     except StorageFile.DoesNotExist:
         return rc.NOT_FOUND
     logger.debug("Deleted file %s" % uuid)
     return rc.DELETED
开发者ID:rvanlaar,项目名称:easy-transifex,代码行数:12,代码来源:api.py

示例12: _notify_translationwatchers

def _notify_translationwatchers(resource, language):
    """
    Notify the watchers for a specific TranslationWatch
    """
    context = {"project": resource.project, "resource": resource, "language": language}

    twatch = TranslationWatch.objects.get_or_create(resource=resource, language=language)[0]

    logger.debug("addon-watches: Sending notification for '%s'" % twatch)
    txnotification.send_observation_notices_for(
        twatch, signal="project_resource_translation_changed", extra_context=context
    )
开发者ID:qikh,项目名称:transifex,代码行数:12,代码来源:handlers.py

示例13: update_template_cache

def update_template_cache(template_name, fragment_names, key_vars, context):
    """Update the template cache with the new data.

    The caches will be invalidated in the order given.
    """
    logger.debug("Invalidating %s in %s" % (fragment_names, template_name))
    t = get_template(template_name)
    nodes = t.nodelist.get_nodes_by_type(CacheNode)
    for f_name in fragment_names:
        for node in nodes:
            if f_name == node.fragment_name:
                set_fragment_content(node, key_vars, context)
                break
开发者ID:593in,项目名称:transifex,代码行数:13,代码来源:cache.py

示例14: test_pseudo_file_api_calls

    def test_pseudo_file_api_calls(self):
        """Test Pseudo translation requests through the API."""
        source_language = self.project.resources.all()[0].source_language
        for i18n_type, v in FORMATS.items():
            resource_slug = 'resource_%s' % i18n_type.lower()
            resource_url = reverse('apiv2_resources', kwargs={
                    'project_slug': self.project.slug})

            # Creating resource using the API
            f = open(v['file'])
            res = self.client['maintainer'].post(
                resource_url,
                data={
                    'slug': resource_slug,
                    'name': resource_slug,
                    'i18n_type': i18n_type,
                    'attachment': f},
                )
            f.close()

            logger.debug('-----------------------')
            logger.debug(i18n_type)
            logger.debug(settings.I18N_METHODS[i18n_type]['mimetype'])
            logger.debug(res.content)
            logger.debug('-----------------------')

            # Pseudo file API URL
            url = reverse('apiv2_pseudo_content', args=[self.project.slug,
                resource_slug])

            for pseudo_type in settings.PSEUDO_TYPES:
                # Get resource file using a specific pseudo type
                resp = self.client['registered'].get(url, data={'pseudo_type':pseudo_type})

                # Get response and check encoding
                resp_content = eval(resp.content)['content']
                if type(resp_content) != unicode:
                    try:
                        resp_content = resp_content.decode('utf-8')
                    except UnicodeDecodeError:
                        resp_content = resp_content.decode('iso-8859-1')

                #FIXME: We have a bug related to spaces being escaped in
                # .properties files. This can be dropped after fixing it.
                if i18n_type == 'PROPERTIES' and \
                    pseudo_type in ['PLANGUAGE', 'UNICODE']:
                    resp_content = resp_content.replace('\\ ', ' ')

                # Assert expected value in the generated file
                for message in v['pseudo_messages'][pseudo_type]:
                    self.assertTrue(message in resp_content)
开发者ID:rvanlaar,项目名称:easy-transifex,代码行数:51,代码来源:pseudo.py

示例15: create

    def create(self):
        """
        Creates a new translation from file.

        Returns:
            A dict with information for the translation.

        Raises:
            BadRequestError: There was a problem with the request.
            NoContentError: There was no file in the request.
        """
        if not self.request.FILES:
            raise NoContentError("No file has been uploaded.")

        submitted_file = self.request.FILES.values()[0]
        name = str(submitted_file.name)
        size = submitted_file.size

        try:
            file_ = tempfile.NamedTemporaryFile(
                mode='wb',
                suffix=name[name.rfind('.'):],
                delete=False
            )
            for chunk in submitted_file.chunks():
                file_.write(chunk)
            file_.close()

            parser = registry.appropriate_handler(
                self.resource,
                language=self.language,
                filename=name
            )
            parser.bind_file(file_.name)
            if parser is None:
                raise BadRequestError("Unknown file type")
            if size == 0:
                raise BadRequestError("Empty file")

            try:
                parser.is_content_valid()
                logger.debug("Uploaded file %s" % file_.name)
            except (FileCheckError, ParseError), e:
                raise BadRequestError("Error uploading file: %s" % e)
            except Exception, e:
                logger.error(unicode(e), exc_info=True)
                raise BadRequestError("A strange error happened.")
开发者ID:tymofij,项目名称:adofex,代码行数:47,代码来源:__init__.py


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