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


Python Domain.get_domain_by_name方法代码示例

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


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

示例1: get_count

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
    def get_count(self, key, domain_name, expiration, get_count_method):
        cache_key = '%s-%s' % (self.get_domain_name(domain_name), key)

        count = self.redis.get(cache_key)

        if count is not None:
            return int(count)

        domain = domain_name
        if domain and not isinstance(domain, Domain):
            domain = Domain.get_domain_by_name(domain_name, self.db)

        if domain is None:
            count = Page.get_page_count(self.db)
        else:
            count = get_count_method(domain)

        cache_key = '%s-%s' % (self.get_domain_name(domain), key)

        self.redis.setex(
            cache_key,
            expiration,
            value=int(count)
        )

        return int(count)
开发者ID:ricardodani,项目名称:holmes-api,代码行数:28,代码来源:cache.py

示例2: get

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
    def get(self, domain_name, key_category_id):
        domain = Domain.get_domain_by_name(domain_name, self.db)

        if not domain:
            self.set_status(404, 'Domain %s not found' % domain_name)
            return

        violation_defs = self.application.violation_definitions

        top_violations = yield self.cache.get_top_in_category_for_domain(
            domain,
            key_category_id,
            self.application.config.get('TOP_CATEGORY_VIOLATIONS_LIMIT')
        )

        violations = []
        for key_name, count in top_violations:
            violations.append({
                'title': violation_defs[key_name]['title'],
                'count': count
            })

        result = {
            "domainId": domain.id,
            'domainName': domain.name,
            'domainURL': domain.url,
            'categoryId': key_category_id,
            'violations': violations
        }

        self.write_json(result)
开发者ID:ricardodani,项目名称:holmes-api,代码行数:33,代码来源:domains.py

示例3: get

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
    def get(self, domain_name):
        domain = Domain.get_domain_by_name(domain_name, self.db)

        if not domain:
            self.set_status(404, self._('Domain %s not found') % domain_name)
            return

        prefs = DomainsViolationsPrefs.get_domains_violations_prefs_by_domain(
            self.db, domain.name
        )

        violation_defs = self.application.violation_definitions

        result = []

        for pref in prefs:
            key = violation_defs.get(pref.get('key'))

            if key is None:
                continue

            result.append({
                'key': pref.get('key'),
                'title': key.get('default_value_description', None),
                'category': key.get('category', None),
                'value': pref.get('value'),
                'default_value': key.get('default_value', None),
                'unit': key.get('unit', None)
            })

        self.write_json(result)
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:33,代码来源:domains_violations_prefs.py

示例4: post

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
    def post(self, domain_name):
        domain = Domain.get_domain_by_name(domain_name, self.db)

        if not domain:
            self.set_status(404, 'Domain %s not found' % domain_name)
            return

        domain.is_active = not domain.is_active
开发者ID:ricardodani,项目名称:holmes-api,代码行数:10,代码来源:domains.py

示例5: test_can_set_domain_to_active

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
    def test_can_set_domain_to_active(self):
        domain = DomainFactory.create(url="http://www.domain.com", name="domain.com", is_active=False)

        response = yield self.http_client.fetch(
            self.get_url(r'/domains/%s/change-status/' % domain.name),
            method='POST',
            body=''
        )
        expect(response.code).to_equal(200)
        domain_from_db = Domain.get_domain_by_name(domain.name, self.db)
        expect(domain_from_db.is_active).to_be_true()
开发者ID:ricardodani,项目名称:holmes-api,代码行数:13,代码来源:test_domains.py

示例6: test_can_set_domain_to_inactive

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
    def test_can_set_domain_to_inactive(self):
        domain = DomainFactory.create(url="http://www.domain.com", name="domain.com", is_active=True)

        response = yield self.authenticated_fetch(
            '/domains/%s/change-status/' % domain.name,
            method='POST',
            body=''
        )
        expect(response.code).to_equal(200)
        domain_from_db = Domain.get_domain_by_name(domain.name, self.db)
        expect(domain_from_db.is_active).to_be_false()
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:13,代码来源:test_domains.py

示例7: handle

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
        def handle(has_key):
            domain = domain_name
            if domain and not isinstance(domain, Domain):
                domain = Domain.get_domain_by_name(domain_name, self.db)

            if has_key:
                self.redis.incrby(key, increment, callback=callback)
            else:
                if domain is None:
                    value = Page.get_page_count(self.db) + increment - 1
                else:
                    value = get_default_method(domain) + increment - 1

                self.redis.set(key, value, callback=callback)
开发者ID:marcelometal,项目名称:holmes-api,代码行数:16,代码来源:cache.py

示例8: increment_count

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
    def increment_count(self, key, domain_name, get_default_method, increment=1):
        key = '%s-%s' % (self.get_domain_name(domain_name), key)

        has_key = self.has_key(key)

        domain = domain_name
        if domain and not isinstance(domain, Domain):
            domain = Domain.get_domain_by_name(domain_name, self.db)

        if has_key:
            self.redis.incrby(key, increment)
        else:
            if domain is None:
                value = Page.get_page_count(self.db) + increment - 1
            else:
                value = get_default_method(domain) + increment - 1

            self.redis.set(key, value)
开发者ID:ricardodani,项目名称:holmes-api,代码行数:20,代码来源:cache.py

示例9: get

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
    def get(self, key_name):
        current_page = int(self.get_argument("current_page", 1))
        page_size = int(self.get_argument("page_size", 10))
        domain_filter = self.get_argument("domain_filter", None)
        page_filter = self.get_argument("page_filter", None)

        domain = None
        if domain_filter is not None:
            domain = Domain.get_domain_by_name(domain_filter, self.db)
            if not domain:
                self.set_status(404, self._("Domain %s not found") % domain_filter)
                self.finish()
                return

        violations = self.application.violation_definitions
        if key_name not in violations:
            self.set_status(404, self._("Invalid violation key %s") % key_name)
            self.finish()
            return

        violation_title = violations[key_name]["title"]
        key_id = violations[key_name]["key"].id

        violation = yield self.application.search_provider.get_by_violation_key_name(
            key_id=key_id, current_page=current_page, page_size=page_size, domain=domain, page_filter=page_filter
        )

        if "error" in violation:
            self.set_status(violation["error"]["status_code"], violation["error"]["reason"])
            self.finish()
            return

        if "reviewsCount" not in violation:
            if not domain and not page_filter:
                violation["reviewsCount"] = Review.count_by_violation_key_name(self.db, key_id)
            else:
                violation["reviewsCount"] = None

        violation["title"] = violation_title

        self.write_json(violation)
        self.finish()
开发者ID:skyonamine,项目名称:holmes-api,代码行数:44,代码来源:violation.py

示例10: post

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
    def post(self, domain_name):
        if not self.validate_superuser():
            return

        domain = Domain.get_domain_by_name(domain_name, self.db)

        if not domain:
            self.set_status(404, self._('Domain %s not found') % domain_name)
            return

        post_data = loads(self.request.body)

        DomainsViolationsPrefs.update_by_domain(
            self.db, self.cache, domain, post_data
        )

        self.write_json({
            'reason': self._('Preferences successfully saved!'),
            'description': self._('Preferences successfully saved!')
        })
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:22,代码来源:domains_violations_prefs.py

示例11: test_can_get_domain_by_name

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
    def test_can_get_domain_by_name(self):
        domain = DomainFactory.create()

        loaded_domain = Domain.get_domain_by_name(domain.name, self.db)

        expect(loaded_domain.id).to_equal(domain.id)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:8,代码来源:test_domain.py

示例12: test_invalid_domain_returns_None

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
    def test_invalid_domain_returns_None(self):
        domain_name = 'domain-details.com'
        domain = Domain.get_domain_by_name(domain_name, self.db)

        expect(domain).to_be_null()
开发者ID:pombredanne,项目名称:holmes-api,代码行数:7,代码来源:test_domain.py

示例13: get_domain

# 需要导入模块: from holmes.models import Domain [as 别名]
# 或者: from holmes.models.Domain import get_domain_by_name [as 别名]
 def get_domain(self, domain_name):
     domain = domain_name
     if domain and not isinstance(domain, Domain):
         domain = Domain.get_domain_by_name(domain_name, self.db)
     return domain
开发者ID:ricardodani,项目名称:holmes-api,代码行数:7,代码来源:cache.py


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