optimize: support directly open QRcode image on mac osx

This commit is contained in:
yanxurui
2016-11-21 13:51:53 +08:00
parent c8025896da
commit 13358093be
+10 -2
View File
@@ -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')
if os == 'win':
os.startfile(QRCODE_PATH) 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)