Skip to content

Commit

Permalink
1. 修复微信消息参数传递的bug
Browse files Browse the repository at this point in the history
2. 修复微信消息,redis无法连接时导致消息无法发送的bug
  • Loading branch information
gateray committed Oct 12, 2017
1 parent 28e84e9 commit 33bd0eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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.")
Expand Down

0 comments on commit 33bd0eb

Please sign in to comment.