本文整理汇总了Python中Session.Session.getAuthData方法的典型用法代码示例。如果您正苦于以下问题:Python Session.getAuthData方法的具体用法?Python Session.getAuthData怎么用?Python Session.getAuthData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session.Session
的用法示例。
在下文中一共展示了Session.getAuthData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Session import Session [as 别名]
# 或者: from Session.Session import getAuthData [as 别名]
class WWMCore:
def __init__(self):
self.connectionManager = YowsupConnectionManager()
self.connectionManager.setAutoPong(Config.keepAlive)
self.signalsInterface = self.connectionManager.getSignalsInterface()
self.methodsInterface = self.connectionManager.getMethodsInterface()
self.yowsupRanOnce = 0
self.listener = None
self.sender = None
self.session = None
self.httpRequestHandler = None
self.instanceId = None
self.status = Constants.INSTANCESTATUS_INITED
self.dbi = DBI() #Use this for HTTP requests only. For every other case, Go ahead and create a different connection for now
self.callbackDBI = CallbackDBI() #Extra care for preventing interference
#self.dbiCursor = None
self.yowsupStarted = 0
#Just to keep track of the instances created
def registerInstance(self, procId):
timeNow = time.time()
procId = os.getpid()
status = Constants.INSTANCESTATUS_STARTED
authStatus = Constants.AUTHSTATUS_IDLE
self.dbiCursor.execute("INSERT INTO pythoninstances (phone, procId, lastUpdated,status, authStatus) VALUES(%s, %s, %s, %s)", (self.session.phone, procId, timeNow, status,authStatus))
#self.instanceId =
def genAESKey(self, str):
#md5 hash of reverse of str
return hashlib.md5(str[::-1]).hexdigest()
def initSender(self):
if self.sender==None:
self.sender= Sender(self)
def initListener(self):
if self.listener==None:
self.listener = Listener(self)
#deprecated
def initDBI(self):
print "Call to Core.initDBI which is deprecated"
'''
try:
self.dbi = MySQLdb.connect('localhost','root','','webwhatsapp')
self.dbiCursor = self.dbi.cursor(MySQLdb.cursors.DictCursor)
except MySQLdb.Error, e:
raise WWMException("MySQL could not connect: %s" %e)
'''
def getDBICursor(self): #returns dbi and cursor
return self.dbiCursor
#This method is called from session
def initSession(self, phone, AESKey):
print "Core.initSession called"
if self.session == None or self.session.authStatus == Constants.AUTHSTATUS_IDLE: #self.yowsupStarted==0 and
self.yowsupStarted = 1
if self.session == None:
self.session = Session(self, phone, AESKey)
self.session.getAuthData()
self.signalsInterface.registerListener("disconnected", self.onDisconnected)
self.session.login()
else:
print "\nPretty sure yowsup is already started."
def authCallback(self,isSuccess): #Called manually from Session
if isSuccess:
self.yowsupRanOnce==1 #Very important flag
#This is done earlier in initSession with the above flag to differentiate between pre auth disco and post auth disco
#self.signalsInterface.registerListener("disconnected", self.onDisconnected)
self.status = Constants.INSTANCESTATUS_RUNNING
self.yowsupStarted=1
else:
self.yowsupStarted= 0
def onDisconnected(self, reason):
print "Core.onDisconnected called"
if self.status==Constants.INSTANCESTATUS_WRAPPEDUP:
print "Core.onDisconnected: Disconnected and wrapping up"
return #And die
self.yowsupStarted = 0
self.session.authStatus = Constants.AUTHSTATUS_IDLE
#self.session.updateAuthStatus(Constants.AUTHSTATUS_IDLE)
if self.yowsupRanOnce==0:
print "Could not connect. Rerun startYowsup to try again"
return
#.........这里部分代码省略.........