Skip to content

Commit

Permalink
Merge pull request Urinx#129 from yanxurui/master
Browse files Browse the repository at this point in the history
optimize: support directly open QRcode image on mac osx
  • Loading branch information
Urinx authored Jan 16, 2017
2 parents c802589 + 1335809 commit 17a8a07
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions weixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import re
import sys
import os
import subprocess
import random
import multiprocessing
import platform
Expand Down Expand Up @@ -156,11 +157,13 @@ def getUUID(self):
def genQRCode(self):
#return self._showQRCodeImg()
if sys.platform.startswith('win'):
self._showQRCodeImg()
self._showQRCodeImg('win')
elif sys.platform.find('darwin') >= 0:
self._showQRCodeImg('macos')
else:
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
params = {
't': 'webwx',
Expand All @@ -171,7 +174,12 @@ def _showQRCodeImg(self):
if data == '':
return
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):
time.sleep(tip)
Expand Down

0 comments on commit 17a8a07

Please sign in to comment.