當前位置: 首頁>>代碼示例>>Python>>正文


Python config.DOMAIN屬性代碼示例

本文整理匯總了Python中config.DOMAIN屬性的典型用法代碼示例。如果您正苦於以下問題:Python config.DOMAIN屬性的具體用法?Python config.DOMAIN怎麽用?Python config.DOMAIN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在config的用法示例。


在下文中一共展示了config.DOMAIN屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_from_dict

# 需要導入模塊: import config [as 別名]
# 或者: from config import DOMAIN [as 別名]
def create_from_dict(cls, d, persist=True):
        new_employee = cls()
        new_employee.username = d['username']
        new_employee.user = users.User('{user}@{domain}'.format(user=new_employee.username, domain=config.DOMAIN))
        new_employee.update_from_dict(d)

        if persist is True:
            new_employee.put()

        return new_employee 
開發者ID:Yelp,項目名稱:love,代碼行數:12,代碼來源:employee.py

示例2: wellknown_webfinger

# 需要導入模塊: import config [as 別名]
# 或者: from config import DOMAIN [as 別名]
def wellknown_webfinger() -> Any:
    """Exposes/servers WebFinger data."""
    resource = request.args.get("resource")
    if resource not in [f"acct:{config.USERNAME}@{config.DOMAIN}", config.ID]:
        abort(404)

    out = {
        "subject": f"acct:{config.USERNAME}@{config.DOMAIN}",
        "aliases": [config.ID],
        "links": [
            {
                "rel": "http://webfinger.net/rel/profile-page",
                "type": "text/html",
                "href": config.ID,
            },
            {"rel": "self", "type": "application/activity+json", "href": config.ID},
            {
                "rel": "http://ostatus.org/schema/1.0/subscribe",
                "template": config.BASE_URL + "/authorize_follow?profile={uri}",
            },
            {"rel": "magic-public-key", "href": config.KEY.to_magic_key()},
            {
                "href": config.ICON_URL,
                "rel": "http://webfinger.net/rel/avatar",
                "type": mimetypes.guess_type(config.ICON_URL)[0],
            },
        ],
    }

    return jsonify(out, "application/jrd+json; charset=utf-8") 
開發者ID:tsileo,項目名稱:microblog.pub,代碼行數:32,代碼來源:well_known.py

示例3: nodeinfo

# 需要導入模塊: import config [as 別名]
# 或者: from config import DOMAIN [as 別名]
def nodeinfo() -> Any:
    """NodeInfo endpoint."""
    q = {
        "box": Box.OUTBOX.value,
        "meta.deleted": False,
        "type": {"$in": [ap.ActivityType.CREATE.value, ap.ActivityType.ANNOUNCE.value]},
    }

    out = {
        "version": "2.1",
        "software": {
            "name": "microblogpub",
            "version": config.VERSION,
            "repository": "https://github.com/tsileo/microblog.pub",
        },
        "protocols": ["activitypub"],
        "services": {"inbound": [], "outbound": []},
        "openRegistrations": False,
        "usage": {"users": {"total": 1}, "localPosts": DB.activities.count(q)},
        "metadata": {
            "nodeName": f"@{config.USERNAME}@{config.DOMAIN}",
            "version": config.VERSION,
            "versionDate": config.VERSION_DATE,
        },
    }

    return jsonify(
        out,
        "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.1#",
    ) 
開發者ID:tsileo,項目名稱:microblog.pub,代碼行數:32,代碼來源:well_known.py

示例4: gen_pic_url

# 需要導入模塊: import config [as 別名]
# 或者: from config import DOMAIN [as 別名]
def gen_pic_url(path):
    if not path.startswith('/'):
        path = '/' + path
    return '{}{}'.format(DOMAIN, path) 
開發者ID:dongweiming,項目名稱:weapp-zhihulive,代碼行數:6,代碼來源:schemas.py

示例5: run

# 需要導入模塊: import config [as 別名]
# 或者: from config import DOMAIN [as 別名]
def run(self):
        # Set up logger
        logger = logging.getLogger()
        logger.setLevel(logging.INFO)
        formatter = logging.Formatter('[%(asctime)s %(levelname)s] %(message)s')
        if self._args['-d'] == None:
            handler = logging.StreamHandler()
        else:
            handler = logging.handlers.RotatingFileHandler(self._args['-l'],
                                                           maxBytes=1*1024*1024,
                                                           backupCount=1)
        handler.setFormatter(formatter)
        logger.addHandler(handler)

        bapi = BaseAPI(config.LOGIN_EMAIL, config.LOGIN_PASSWORD)
        dapi = DomainAPI(bapi)
        rapi = RecordAPI(bapi)
        domain = dapi.info(domain=config.DOMAIN)
        record_list = rapi.list(domain.id)
        record = None
        for rec in record_list:
            if rec.sub_domain == config.SUB_DOMAIN and \
               rec.record_type == Record.TYPE_A:
                record = rec
                break
        if record == None:
            logger.error("Couldn't get A record of domain: %s.%s",
                         config.SUB_DOMAIN, config.DOMAIN)
            return

        last_ip = record.value
        while True:
            try:
                current_ip = get_ip()
            except socket.error, e:
                logger.error('Get current IP error: %s', e)
            else:
                if current_ip != last_ip:
                    logger.info('IP change from %s to %s, update DNS record',
                                last_ip, current_ip)
                    rapi.ddns(record.domain_id, record.id, record.sub_domain,
                              record.record_line, current_ip)
                    last_ip = current_ip
                else:
                    logger.info('IP not change, check after %d seconds',
                                int(self._args['-t']))
            time.sleep(int(self._args['-t'])) 
開發者ID:leeyiw,項目名稱:dnspod_ddns,代碼行數:49,代碼來源:dnspod_ddns.py


注:本文中的config.DOMAIN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。