refactor(log): warning to warn

This commit is contained in:
New
2019-05-04 03:03:38 +08:00
parent 62858101ac
commit 9282b00e8e
6 changed files with 16 additions and 14 deletions
+2 -2
View File
@@ -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'))
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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 = '@'
+3 -1
View File
@@ -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 = '@'
+6 -6
View File
@@ -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=' ')