diff --git a/app.py b/app.py index 7ba439e..a8bf2aa 100644 --- a/app.py +++ b/app.py @@ -23,9 +23,8 @@ def getRedisConn(self): redisConn.connect() self.redisConn = redisConn return self.redisConn - except Exception: + except: self.redisConn = None - raise def getSMTPConn(self): try: import smtplib diff --git a/models.py b/models.py index d179f45..cd6ee82 100644 --- a/models.py +++ b/models.py @@ -36,7 +36,7 @@ def send(self): class WeiXinQYMessage(Message): def __init__(self, redisConn, title="", content="", **qywxSettings): - super(WeiXinQYMessage, self).__init__(title, content) + super(WeiXinQYMessage, self).__init__(title=title, content=content) self.baseUrl = qywxSettings.get("baseUrl") self.corpid = qywxSettings.get("corpid") self.corpsecret = qywxSettings.get("corpsecret") @@ -62,7 +62,10 @@ def refreshToken(self): return "" try: accessToken = json.loads(response.body).get("access_token") - yield tornado.gen.Task(self.__redis.setex, redisKeys["WXQY_ACCESS_TOKEN"], 7200, accessToken) + try: + yield tornado.gen.Task(self.__redis.setex, redisKeys["WXQY_ACCESS_TOKEN"], 7200, accessToken) + except: + pass return accessToken except json.JSONDecodeError: print("JSON decode error, fail to get access_token.")