// offending code· 3 files flaggedpatterns: 14
--- domain_admin-1.6.78/setup.py (excerpt) ---
# -*- coding: utf-8 -*-
# @Date : 2019-06-26
# @Author : Peng Shiyu
from __future__ import print_function, unicode_literals, absolute_import, division
import glob
import io
import os
from setuptools import setup, find_packages
"""
## 本地测试
安装测试
python setup.py develop
python setup.py develop --uninstall
卸载
pip uninstall spideradmin -y
## 打包上传
先升级打包工具
pip install --upgrade setuptools wheel twine
打包
python setup.py sdist bdist_wheel
检查
twine check dist/*
上传pypi
twine upload dist/*
命令整合
rm -rf dist build *.egg-info \
&& python setup.py sdist bdist_wheel \
&& twine check dist/* \
&& twine upload dist/*
## 下载测试
安装测试
pip3 install -U domain-admin -i https://pypi.org/simple
打包的用的setup必须引入
参考:
https://packaging.python.org/guides/making-a-pypi-friendly-readme/
"""
# 版本号
version_file = glob.glob("*/version.py")[0]
with io.open(version_file, 'rb') as f:
version_var = {}
exec(f.read(), version_var)
VERSION = version_var['VERSION']
with io.open("README.md", 'r', encoding='utf-8') as f:
long_description = f.read()
with io.open("requirements/production.txt", 'r') as f:
install_requires = f.read().split(os.sep)
setup(
name='domain-admin',
version=VERSION,
description="a domain ssl cert admin",
keywords='domain,ssl,cert,web,monitor',
author='Peng Shiyu',
author_email='pengshiyuyx@gmail.com',
license='MIT',
url="https://github.com/dromara/domain-admin",
long_description=long_description,
long_description_con
--- domain_admin-1.6.78/domain_admin/utils/open_api/aliyun_domain_api.py (excerpt) ---
# -*- coding: utf-8 -*-
"""
@File : aliyun_domain_api.py
@Date : 2024-06-17
"""
from aliyunsdkalidns.request.v20150109.AddDomainRecordRequest import AddDomainRecordRequest
from aliyunsdkcore.auth.credentials import AccessKeyCredential
from aliyunsdkcore.client import AcsClient
from domain_admin.log import logger
class RecordTypeEnum:
"""
记录类型枚举
ref: https://help.aliyun.com/zh/dns/dns-record-types
"""
A = 'A'
TXT = 'TXT'
def add_domain_record(
access_key_id, access_key_secret,
domain_name, record_key, record_type, record_value
):
"""
添加域名解析记录
doc:
https://next.api.aliyun.com/api-tools/sdk/Alidns?version=2015-01-09&language=python&tab=primer-doc
https://next.api.aliyun.com/api/Alidns/2015-01-09/AddDomainRecord?sdkStyle=old&tab=DEMO&lang=PYTHON
:param access_key_id: key
:param access_key_secret: secret
:param domain_name: 域名名称
:param record_key: 主机记录
:param record_type: 解析记录类型 RecordTypeEnum
:param record_value: 记录值
:return:
"""
logger.info("%s", {
'access_key_id': access_key_id,
'access_key_secret': access_key_secret,
'domain_name': domain_name,
'record_key': record_key,
'record_type': record_type,
'record_value': record_value,
})
# Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set.
credentials = AccessKeyCredential(
access_key_id=acces
--- domain_admin-1.6.78/domain_admin/utils/open_api/ding_talk_api.py (excerpt) ---
# -*- coding: utf-8 -*-
"""
@File : ding_talk_api.py
@Date : 2023-06-22
钉钉开放API接口
"""
from __future__ import print_function, unicode_literals, absolute_import, division
import requests
def get_access_token(appkey, appsecret):
"""
获取access_token
https://open.dingtalk.com/document/orgapp/obtain-orgapp-token
:param appkey: 应用的唯一标识key
:param appsecret: 应用的密钥
:return:
{
"errcode": 0,
"access_token": "96fc7a7axxx",
"errmsg": "ok",
"expires_in": 7200
}
"""
url = 'https://oapi.dingtalk.com/gettoken'
params = {
'appkey': appkey,
'appsecret': appsecret
}
res = requests.get(url, params=params)
return res.json()
def send_message(access_token, body):
"""
发送应用消息
https://open.dingtalk.com/document/orgapp/asynchronous-sending-of-enterprise-session-messages
:param access_token:
:param body: 消息体
:return:
{
"errcode":0,
"task_id":256271667526,
"request_id":"4jzllmte0wau"
}
"""
url = 'https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2'
params = {
'access_token': access_token,
}
res = requests.post(url, params=params, json=body)
return res.json()
--- dynamic destinations ---
→ smtp.163.com (via hostname-var)