本文整理汇总了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
示例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")
示例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#",
)
示例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)
示例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']))