pep8 fix
This commit is contained in:
parent
1e14bee907
commit
3a78cbba72
2 changed files with 7 additions and 5 deletions
|
@ -61,7 +61,7 @@ def exception_handle(self_, err_msg=None, exit_code=None,
|
|||
destroy=False, conn_err=False):
|
||||
# self_: if function passes self as first arg
|
||||
|
||||
def process_exception(self, e):
|
||||
def process_exception(e, self=None):
|
||||
print_exception(e)
|
||||
if err_msg:
|
||||
logging.error(err_msg)
|
||||
|
@ -72,8 +72,9 @@ def exception_handle(self_, err_msg=None, exit_code=None,
|
|||
return
|
||||
|
||||
if conn_err:
|
||||
addr, port = self._client_address[0], self._client_address[1]
|
||||
logging.error('%s when handling connection from %s:%d' %
|
||||
(e, self._client_address[0], self._client_address[1]))
|
||||
(e, addr, port))
|
||||
if self._config['verbose']:
|
||||
traceback.print_exc()
|
||||
if destroy:
|
||||
|
@ -86,14 +87,14 @@ def exception_handle(self_, err_msg=None, exit_code=None,
|
|||
try:
|
||||
func(self, *args, **kwargs)
|
||||
except Exception as e:
|
||||
process_exception(self, e)
|
||||
process_exception(e, self)
|
||||
else:
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
func(*args, **kwargs)
|
||||
except Exception as e:
|
||||
process_exception(self, e)
|
||||
process_exception(e)
|
||||
|
||||
return wrapper
|
||||
return decorator
|
||||
|
|
|
@ -399,8 +399,9 @@ class TCPRelayHandler(object):
|
|||
@shell.exception_handle(self_=True)
|
||||
def _handle_dns_resolved(self, result, error):
|
||||
if error:
|
||||
addr, port = self._client_address[0], self._client_address[1]
|
||||
logging.error('%s when handling connection from %s:%d' %
|
||||
(error, self._client_address[0], self._client_address[1]))
|
||||
(error, addr, port))
|
||||
self.destroy()
|
||||
return
|
||||
if not (result and result[1]):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue