New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openwrt 上跑该脚本 unicode出错 #11
Comments
我看一下,谢谢反馈。 |
用 if os.path.isfile(localfile.encode('utf-8')) 来代替原来的 if os.path.isfile(localfile) , 可以修正这个错误,不过相关变量太多,能否统一解决下? 估计是输入参数没有用utf-8强制encode导致的,仅供参考 |
有点奇怪,按理应该都是Unicode,不知道为啥不行。如果你说的能行,那我猜你把这一行:
改成:
能解决问题不? |
没有回应,先暂时关掉 ^.^ |
我试着把3558行的改成 uargs.append(arg.encode('utf-8')),也不行,在openwrt上 Traceback (most recent call last): Abort |
我在 def __downfile(self, remotefile, localfile): 第一行加入 localfile = localfile.encode('utf-8'),可以正常下载了。 |
感谢提供的这个修改。貌似这个可以解决Python 2.7下 |
@septs 感谢提供信息。 不过去AppleDNS那边看了一下,这个貌似还是OpenWRT的locale处理不太完美有关,其他的*nix没听说有这个问题。 |
鉴于这个好像还是要在OpenWRT上改,这里就不处理直接关闭了。 |
不知为何unicode还是有问题,能否帮忙检查下
OS:openwrt
ENV:
LANG='zh_CN.UTF-8'
LANGUAGE='zh_CN.UTF-8'
LC_ALL='zh_CN.UTF-8'
PYTHONIOENCODING='UTF-8'
TERM='linux'
root@CentiFLY:/mnt/sda3/Downloads# python bypy.py downfile test/测试3d.mp4 -d
Token file: '/root/.bypy.json'
Hash Cache file: '/root/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8
sys.stdout.encoding = UTF-8
Token loaded:
Downloading '/apps/bypy/test/测试3d.mp4' as '测试3d.mp4'
Getting info of remote file '/apps/bypy/test/测试3d.mp4' for later verification
__get_file_info(): rdir : /apps/bypy/test | rfile: 测试3d.mp4
GET https://pcs.baidu.com/rest/2.0/pcs/file
actargs: (u'/apps/bypy/test/\u6d4b\u8bd53d.mp4', {})
Params: {u'path': u'/apps/bypy/test', u'order': u'asc', u'method': u'list', u'by': u'name'}
HTTP Status Code: 200
Request OK, processing action
Request all goes fine
Checking if we already have the copy locally
[21:58:29] Exception occurred:
Traceback (most recent call last):
File "bypy.py", line 2463, in main
result = getattr(by, args.command[0])(*uargs)
File "bypy.py", line 1662, in downfile
result = self.__downfile(pcsrpath, localfile)
File "bypy.py", line 1599, in __downfile
if os.path.isfile(localfile):
File "/usr/lib/python2.7/genericpath.py", line 29, in isfile
st = os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
The text was updated successfully, but these errors were encountered: