diff --git a/dns/alidns.py b/dns/alidns.py index aaf8f4a..af8c2b8 100644 --- a/dns/alidns.py +++ b/dns/alidns.py @@ -11,7 +11,7 @@ from hmac import new as hmac from uuid import uuid4 from base64 import b64encode from json import loads as jsondecode -from logging import debug, info, warn +from logging import debug, info, warning from datetime import datetime try: @@ -80,7 +80,7 @@ def request(param=None, **params): conn.close() if response.status < 200 or response.status >= 300: - warn('%s : error:%s', params['Action'], data) + warning('%s : error:%s', params['Action'], data) raise Exception(data) else: data = jsondecode(data.decode('utf8')) diff --git a/dns/cloudflare.py b/dns/cloudflare.py index 4c083b1..b8d805f 100644 --- a/dns/cloudflare.py +++ b/dns/cloudflare.py @@ -7,7 +7,7 @@ https://api.cloudflare.com/#dns-records-for-a-zone-properties """ from json import loads as jsondecode, dumps as jsonencode -from logging import debug, info, warn +from logging import debug, info try: # python 2 diff --git a/dns/dnscom.py b/dns/dnscom.py index b79e709..1db4351 100644 --- a/dns/dnscom.py +++ b/dns/dnscom.py @@ -9,7 +9,7 @@ http://open.dns.com/ from hashlib import md5 from json import loads as jsondecode -from logging import debug, info, warn +from logging import debug, info from time import mktime from datetime import datetime diff --git a/dns/dnspod.py b/dns/dnspod.py index c79af0c..0e35d38 100644 --- a/dns/dnspod.py +++ b/dns/dnspod.py @@ -7,7 +7,7 @@ http://www.dnspod.cn/docs/domains.html """ from json import loads as jsondecode -from logging import debug, info, warn +from logging import debug, info, warning try: # python 2 from httplib import HTTPSConnection @@ -51,7 +51,7 @@ def request(action, param=None, **params): conn.close() if response.status < 200 or response.status >= 300: - warn('%s : error:%s', action, res) + warning('%s : error:%s', action, res) raise Exception(res) else: data = jsondecode(res.decode('utf8')) @@ -81,7 +81,7 @@ def get_domain_info(domain): sub = ".".join(domain_split) break else: - warn('domain_id: %s, sub: %s', did, sub) + warning('domain_id: %s, sub: %s', did, sub) return None, None if not sub: # root domain根域名https://github.com/NewFuture/DDNS/issues/9 sub = '@' diff --git a/dns/dnspod_com.py b/dns/dnspod_com.py index 3c7af61..0160578 100644 --- a/dns/dnspod_com.py +++ b/dns/dnspod_com.py @@ -7,7 +7,7 @@ http://www.dnspod.com/docs/domains.html """ from json import loads as jsondecode -from logging import debug, info, warn +from logging import debug, info, warning try: # python 2 from httplib import HTTPSConnection @@ -55,6 +55,7 @@ def request(action, param=None, **params): conn.close() if response.status < 200 or response.status >= 300: + warning('%s : error:%s', action, res) raise Exception(res) else: data = jsondecode(res.decode('utf8')) @@ -84,6 +85,7 @@ def get_domain_info(domain): sub = ".".join(domain_split) break else: + warning('domain_id: %s, sub: %s', did, sub) return None, None if not sub: # root domain根域名https://github.com/NewFuture/DDNS/issues/9 sub = '@' diff --git a/run.py b/run.py index c6818df..e0f8e9c 100755 --- a/run.py +++ b/run.py @@ -11,7 +11,7 @@ from json import load as loadjson, dump as dumpjson from time import ctime from os import path, environ, stat, name as os_name from tempfile import gettempdir -from logging import info, DEBUG, basicConfig +from logging import DEBUG, basicConfig, info, warning, error import sys @@ -45,10 +45,10 @@ def get_config(key=None, default=None, path="config.json"): get_config.config = loadjson(configfile) get_config.time = stat(path).st_mtime except IOError: - print('Config file %s does not appear to exist.' % path) + error(' Config file `%s` does not exist!' % path) with open(path, 'w') as configfile: configure = { - "$schema": "https://ddns.newfuture.cc/schema.json", + "$schema": "https://ddns.newfuture.cc/schema/v2.json", "id": "YOUR ID or EAMIL for DNS Provider", "token": "YOUR TOKEN or KEY for DNS Provider", "dns": "dnspod", @@ -66,7 +66,7 @@ def get_config(key=None, default=None, path="config.json"): "debug": False, } dumpjson(configure, configfile, indent=2, sort_keys=True) - sys.exit("New template configure file [%s] is generated!" % path) + sys.exit("New template configure file `%s` is generated." % path) except: sys.exit('fail to load config from file: %s' % path) if key: @@ -104,7 +104,7 @@ def change_dns_record(dns, proxy_list, **kw): try: return dns.update_record(domain, kw['ip'], record_type=record_type) except Exception as e: - print(e) + error(e) return False @@ -159,7 +159,7 @@ def main(): cache = get_config('cache', True) and Cache(CACHE_FILE) if cache is False: - print("Cache is disabled!") + warning("Cache is disabled!") elif len(cache) < 1 or get_config.time >= cache.time: cache.clear() print("=" * 25, ctime(), "=" * 25, sep=' ')