Merge pull request #129 from yanxurui/master
optimize: support directly open QRcode image on mac osx
This commit is contained in:
@@ -11,6 +11,7 @@ import time
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import random
|
import random
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import platform
|
import platform
|
||||||
@@ -156,11 +157,13 @@ class WebWeixin(object):
|
|||||||
def genQRCode(self):
|
def genQRCode(self):
|
||||||
#return self._showQRCodeImg()
|
#return self._showQRCodeImg()
|
||||||
if sys.platform.startswith('win'):
|
if sys.platform.startswith('win'):
|
||||||
self._showQRCodeImg()
|
self._showQRCodeImg('win')
|
||||||
|
elif sys.platform.find('darwin') >= 0:
|
||||||
|
self._showQRCodeImg('macos')
|
||||||
else:
|
else:
|
||||||
self._str2qr('https://login.weixin.qq.com/l/' + self.uuid)
|
self._str2qr('https://login.weixin.qq.com/l/' + self.uuid)
|
||||||
|
|
||||||
def _showQRCodeImg(self):
|
def _showQRCodeImg(self, os):
|
||||||
url = 'https://login.weixin.qq.com/qrcode/' + self.uuid
|
url = 'https://login.weixin.qq.com/qrcode/' + self.uuid
|
||||||
params = {
|
params = {
|
||||||
't': 'webwx',
|
't': 'webwx',
|
||||||
@@ -171,7 +174,12 @@ class WebWeixin(object):
|
|||||||
if data == '':
|
if data == '':
|
||||||
return
|
return
|
||||||
QRCODE_PATH = self._saveFile('qrcode.jpg', data, '_showQRCodeImg')
|
QRCODE_PATH = self._saveFile('qrcode.jpg', data, '_showQRCodeImg')
|
||||||
os.startfile(QRCODE_PATH)
|
if os == 'win':
|
||||||
|
os.startfile(QRCODE_PATH)
|
||||||
|
elif os == 'macos':
|
||||||
|
subprocess.call(["open", QRCODE_PATH])
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
def waitForLogin(self, tip=1):
|
def waitForLogin(self, tip=1):
|
||||||
time.sleep(tip)
|
time.sleep(tip)
|
||||||
|
|||||||
Reference in New Issue
Block a user