liuwons / wxBot

Deprecated
Apache License 2.0
5.36k stars 1.63k forks source link

运行出错 #3

Closed keeleys closed 8 years ago

keeleys commented 8 years ago

mac os 10.11.3

> python -V
Python 2.7.10
> python wxBot/test.py
[INFO] Please use WeCaht to scan the QR code .
[ERROR] WeChat login timeout .
[INFO] Please confirm to login .
23
[ERROR] WeChat login timeout .
Traceback (most recent call last):
  File "wxBot/test.py", line 28, in <module>
    main()
  File "wxBot/test.py", line 24, in main
    bot.run()
  File "/Users/keeley/Documents/github/wxBot/wxbot.py", line 528, in run
    if self.login():
  File "/Users/keeley/Documents/github/wxBot/wxbot.py", line 596, in login
    r = self.session.get(self.redirect_uri)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 480, in get
    return self.request('GET', url, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 454, in request
    prep = self.prepare_request(req)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 388, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/Library/Python/2.7/site-packages/requests/models.py", line 293, in prepare
    self.prepare_url(url, params)
  File "/Library/Python/2.7/site-packages/requests/models.py", line 353, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL '': No schema supplied. Perhaps you meant http://?
liuwons commented 8 years ago

是每次运行都这样吗?还是偶尔出现? 在我这是偶尔会出现这种问题(Windows7/Ubuntu12.04, Python2.7.9), 初步分析是网络问题导致的redirect_url获取失败。

keeleys commented 8 years ago

@liuwons 是每次运行都这样呢,网络正常哇

liuwons commented 8 years ago

@keeleys 那在你机子上能登陆Web 微信吗?

keeleys commented 8 years ago

http://7vzs7q.com1.z0.glb.clouddn.com/screenshot%202016-03-05%2009.46.52.png

liuwons commented 8 years ago

@keeleys 好奇怪,我找找原因。。

keeleys commented 8 years ago

@liuwons 就是在[INFO] Please use WeCaht to scan the QR code . 这一行会卡住 是否因为打开二维码的图片的操作命令不对。

liuwons commented 8 years ago

@keeleys 在这行卡住是正常的,微信扫了二维码之后才会进入下一步打印"Please confirm to login ."

keeleys commented 8 years ago

@liuwons 但是程序在这一行没有打开任何可以给我扫描的地方。

liuwons commented 8 years ago

@keeleys 程序所在目录下面没有生成qr.png文件吗?

keeleys commented 8 years ago

@liuwons 是的 没有这个文件

liuwons commented 8 years ago

_test.py_ 里的 bot.conf['qr'] = 'png' 换成 bot.conf['qr'] = 'tty'会有二维码吗?

keeleys commented 8 years ago

@liuwons 找到原因了 因为我的命令行在wxBot文件夹外面运行的,所以生成到外面去了。然后图片又不会自动打开 我就傻了。还有个问题这个图片只有45*45分辨率,在retina下面看着好小。

liuwons commented 8 years ago

嗯,因为我把二维码的色块调到最小了,图片可以放大再扫描的~

keeleys commented 8 years ago

可以加点代码然后让操作系统自动打开二维码图片,然后二维码怎么调放大点哇在电脑上扫描方便点。

 f = open(QRImagePath, 'wb')
    f.write(response.read())
    f.close()

    if sys.platform.find('darwin') >= 0:
        subprocess.call(['open', QRImagePath])
    elif sys.platform.find('linux') >= 0:
        subprocess.call(['xdg-open', QRImagePath])
    else:
        os.startfile(QRImagePath)

    print('请使用微信扫描二维码以登录')
liuwons commented 8 years ago

@keeleys 嗯,这个可以有^_^

keeleys commented 8 years ago

@liuwons 我自己加上然后推送咯 好用的话你在改改优化下 辛苦了😁

liuwons commented 8 years ago

好的,我等会看看^-^

keeleys commented 8 years ago

试了10来分钟。 有几次网络不好断了一下 就不会自动回复了, 也不报错 重连功能加上就好了。 😁

liuwons commented 8 years ago

嗯,这个问题一直存在的。微信服务器端如果一段时间没有收到数据就会判定为客户端下线了。