Example #1
0
 def waitForAuth(self, conf):
     qrcodeManager = QrcodeManager(conf)
     try:
         qrcodeManager.Show(self.getQrcode())
         x, y = 1, 1
         while True:
             time.sleep(3)
             authStatus = self.getAuthStatus()
             if '二维码未失效' in authStatus:
                 if x:
                     INFO('等待二维码扫描及授权...')
                     x = 0
             elif '二维码认证中' in authStatus:
                 if y:
                     INFO('二维码已扫描,等待授权...')
                     y = 0
             elif '二维码已失效' in authStatus:
                 WARN('二维码已失效, 重新获取二维码')
                 qrcodeManager.Show(self.getQrcode())
                 x, y = 1, 1
             elif '登录成功' in authStatus:
                 INFO('已获授权')
                 items = authStatus.split(',')
                 self.nick = str(items[-1].split("'")[1])
                 self.qq = str(int(self.session.cookies['superuin'][1:]))
                 self.urlPtwebqq = items[2].strip().strip("'")
                 conf.qq = self.qq
                 break
             else:
                 CRITICAL('获取二维码扫描状态时出错, html="%s"', authStatus)
                 sys.exit(1)
     finally:
         qrcodeManager.Destroy()
Example #2
0
 def waitForAuth(self, conf):
     qrcodeManager = QrcodeManager(conf)
     try:
         qrcodeManager.Show(self.getQrcode())
         x, y = 1, 1
         while True:
             time.sleep(3)
             authStatus = self.getAuthStatus()
             if '二维码未失效' in authStatus:
                 if x:
                     INFO('等待二维码扫描及授权...')
                     x = 0
             elif '二维码认证中' in authStatus:
                 if y:
                     INFO('二维码已扫描,等待授权...')
                     y = 0
             elif '二维码已失效' in authStatus:
                 WARN('二维码已失效, 重新获取二维码')
                 qrcodeManager.Show(self.getQrcode())
                 x, y = 1, 1
             elif '登录成功' in authStatus:
                 INFO('已获授权')
                 items = authStatus.split(',')
                 self.nick = str(items[-1].split("'")[1])
                 self.qq = str(int(self.session.cookies['superuin'][1:]))
                 self.urlPtwebqq = items[2].strip().strip("'")
                 t = time.strftime('%Y-%m-%d-%H-%M-%S',
                                   time.localtime(time.time()))
                 self.dbbasename = '%s-%s-contact.db' % (t, self.qq)
                 self.dbname = conf.absPath(self.dbbasename)
                 conf.SetQQ(self.qq)
                 break
             else:
                 CRITICAL('获取二维码扫描状态时出错, html="%s"', authStatus)
                 sys.exit(1)
     finally:
         qrcodeManager.Destroy()