This commit is contained in:
yumoqing 2022-03-25 20:44:26 +08:00
parent f701dc2fb9
commit 1cafb4067c
3 changed files with 22 additions and 6 deletions

View File

@ -40,7 +40,7 @@ class AcrossNat(object):
return x['NewExternalIPAddress'] return x['NewExternalIPAddress']
try: try:
return get('https://api.ipify.org').text return get('https://api.ipify.org').text
except: except:/Users/ymq/pydev/github/appPublic/appPublic
return get('https://ipapi.co/ip/').text return get('https://ipapi.co/ip/').text
def upnp_check_external_port(self, eport, protocol='TCP'): def upnp_check_external_port(self, eport, protocol='TCP'):
@ -69,7 +69,7 @@ class AcrossNat(object):
NewProtocol=protocol, NewProtocol=protocol,
NewInternalPort=inner_port, NewInternalPort=inner_port,
NewInternalClient=ip, NewInternalClient=ip,
NewEnabled=1, NewEnabled='1',
NewPortMappingDescription=desc, NewPortMappingDescription=desc,
NewLeaseDuration=0 NewLeaseDuration=0
) )

View File

@ -10,18 +10,34 @@ levels={
"critical":logging.CRITICAL "critical":logging.CRITICAL
} }
defaultfmt = '%(asctime)s[%(name)s][%(filename)s:%(lineno)s]%(message)s' defaultfmt = '%(asctime)s[%(name)s][%(filename)s:%(lineno)s]%(message)s'
logfile = -1
level = None
def create_logger(name, formater=defaultfmt, levelname='info', file=None): def create_logger(name, formater=defaultfmt, levelname='info', file=None):
global logfile, level
if logfile == -1:
logfile = file
ret = logging.getLogger(name) ret = logging.getLogger(name)
level = levels.get(levelname, levels.get('debug')) if level is None:
level = levels.get(levelname, levels.get('debug'))
ret.setLevel(level) ret.setLevel(level)
format = logging.Formatter(formater) format = logging.Formatter(formater)
file_handler = None file_handler = None
if file is not None: if logfile is not None:
file_handler = logging.FileHandler(file) file_handler = logging.FileHandler(logfile)
else: else:
file_handler = logging.StreamHandler() file_handler = logging.StreamHandler()
file_handler.setFormatter(format) file_handler.setFormatter(format)
ret.addHandler(file_handler) ret.addHandler(file_handler)
return ret return ret
class AppLogger:
def __init__(self):
self.logger = create_logger(self.__class__.__name__)
self.debug = self.logger.debug
self.info = self.logger.info
self.warning = self.logger.warning
self.error = self.logger.error
self.critical = self.logger.critical
self.exception = self.logger.exception

View File

@ -11,7 +11,7 @@ except ImportError:
# python setup.py bdist_egg generate a egg file # python setup.py bdist_egg generate a egg file
# Release information about eway # Release information about eway
version = "5.1.3" version = "5.1.4"
name = "appPublic" name = "appPublic"
description = "appPublic" description = "appPublic"
author = "yumoqing" author = "yumoqing"