-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (27 loc) · 1013 Bytes
/
main.py
File metadata and controls
33 lines (27 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import logging
import os
from alisdk.ali_sdk_consumer import Consumer
from crawl.crawl_client import Client
# 日志配置
logging.basicConfig(filename='log.log',
format='%(asctime)s - %(name)s - %(levelname)s -%(module)s: %(message)s',
datefmt='%Y-%m-%d %H:%M:%S %p',
level=10)
logger = logging.getLogger(__name__)
setting_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'settings.json')
"""
程序入口
"""
if __name__ == '__main__':
logging.info("程序开始")
ip = Client.get_my_ip()
consumer = Consumer(setting_file)
list = consumer.get_dns_list()
for item in list:
old_ip = item['Value'];
if(old_ip != ip):
logging.info("旧ip:%s,与新ip:%s存在差异,更新域名解析为新ip:%s",old_ip,ip,ip)
consumer.update_dns_resolve(ip, item['RecordId'], item['Type'])
else:
logging.info("ip一致无需修改")
logging.info("程序结束")