From b6961974ba39a912cd685c11264e9a1611a73c47 Mon Sep 17 00:00:00 2001 From: falseen Date: Fri, 11 Sep 2015 20:23:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9py3=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF=EF=BC=8C=E5=8A=A0?= =?UTF-8?q?=E8=BD=BDlibcrypto=E6=A8=A1=E5=9D=97=E5=A4=B1=E8=B4=A5=E6=97=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=AF=A6=E7=BB=86=E9=94=99=E8=AF=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正语法错误:` except Exception, e: ` 是旧版本的语法,py2.6之后的版本已不再使用此语法。 加载libcrypto模块失败时显示详细错误。 --- db_transfer.py | 6 +++--- server_pool.py | 14 +++++++------- shadowsocks/crypto/util.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/db_transfer.py b/db_transfer.py index a62c30f..ae65939 100644 --- a/db_transfer.py +++ b/db_transfer.py @@ -79,7 +79,7 @@ class DbTransfer(object): try: import switchrule keys = switchrule.getKeys() - except Exception, e: + except Exception as e: keys = ['port', 'u', 'd', 'transfer_enable', 'passwd', 'enable' ] conn = cymysql.connect(host=Config.MYSQL_HOST, port=Config.MYSQL_PORT, user=Config.MYSQL_USER, passwd=Config.MYSQL_PASS, db=Config.MYSQL_DB, charset='utf8') @@ -102,13 +102,13 @@ class DbTransfer(object): #需要动态载入switchrule,以便实时修改规则 try: import switchrule - except Exception, e: + except Exception as e: logging.error('load switchrule.py fail') cur_servers = {} for row in rows: try: allow = switchrule.isTurnOn(row) and row['enable'] == 1 and row['u'] + row['d'] < row['transfer_enable'] - except Exception, e: + except Exception as e: allow = False port = row['port'] diff --git a/server_pool.py b/server_pool.py index ee0e86b..90101bd 100644 --- a/server_pool.py +++ b/server_pool.py @@ -120,7 +120,7 @@ class ServerPool(object): if a_config['server_ipv6'] == "::": ipv6_ok = True - except Exception, e: + except Exception as e: logging.warn("IPV6 %s " % (e,)) if 'server' in self.config: @@ -142,7 +142,7 @@ class ServerPool(object): udp_server.add_to_loop(self.loop) self.udp_servers_pool.update({port: udp_server}) - except Exception, e: + except Exception as e: if not ipv6_ok: logging.warn("IPV4 %s " % (e,)) @@ -155,7 +155,7 @@ class ServerPool(object): udpsock = socket(AF_INET, SOCK_DGRAM) udpsock.sendto('%s:%s:0:0' % (Config.MANAGE_PASS, port), (Config.MANAGE_BIND_IP, Config.MANAGE_PORT)) udpsock.close() - except Exception, e: + except Exception as e: logging.warn(e) return True @@ -169,12 +169,12 @@ class ServerPool(object): try: self.tcp_servers_pool[port].close(False) del self.tcp_servers_pool[port] - except Exception, e: + except Exception as e: logging.warn(e) try: self.udp_servers_pool[port].close(False) del self.udp_servers_pool[port] - except Exception, e: + except Exception as e: logging.warn(e) if 'server_ipv6' in self.config: @@ -185,12 +185,12 @@ class ServerPool(object): try: self.tcp_ipv6_servers_pool[port].close(False) del self.tcp_ipv6_servers_pool[port] - except Exception, e: + except Exception as e: logging.warn(e) try: self.udp_ipv6_servers_pool[port].close(False) del self.udp_ipv6_servers_pool[port] - except Exception, e: + except Exception as e: logging.warn(e) return True diff --git a/shadowsocks/crypto/util.py b/shadowsocks/crypto/util.py index a16baba..4deb637 100644 --- a/shadowsocks/crypto/util.py +++ b/shadowsocks/crypto/util.py @@ -88,7 +88,7 @@ def find_library(possible_lib_names, search_symbol, library_name): logging.warn('can\'t find symbol %s in %s', search_symbol, path) except ValueError as e: - print(e) + logging.error(e) return None