Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

Problem when edit a package from python 2 to 3

I am working on editing this package from python 2 to python 3 because I need use KivyMD, which only support python3. source code can be found here: [https://github.com/groner/pythinkgear/tree/master/thinkgear]

When running under python 2, it can output the desired results like this:

DEBUG:__main__:ASIC EEG Power: EEGPowerData(delta=3656, theta=5612, lowalpha=697, highalpha=3450, lowbeta=6125, highbeta=5826, lowgamma=2728, midgamma=53552)
DEBUG:__main__:ATTENTION eSense: 0
DEBUG:__main__:MEDITATION eSense: 0
DEBUG:__main__:POOR SIGNAL: 200
DEBUG:__main__:ASIC EEG Power: EEGPowerData(delta=1340, theta=5046, lowalpha=4464, highalpha=5822, lowbeta=2467, highbeta=4815, lowgamma=8844, midgamma=57809)
DEBUG:__main__:ATTENTION eSense: 0
DEBUG:__main__:MEDITATION eSense: 0

In order to make it run on python 3, I edited line 31 to this:

from io import StringIO ## for Python 3

and line 91 from:

_bytelog.debug('%04X  '+' '.join(('%02X',)*len(buf[o:o+16])), o, *( ord(c) for c in buf[o:o+16] ))

to this:

_bytelog.debug('%04X  '+' '.join(('%02X',)*len(buf[o:o+16])), o, *(c for c in buf[o:o+16]))

also I have changed all "xrange" function to "range".

But the result I get(without any error reported) is this:

DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'x04' while syncing
DEBUG:__main__:discarding b'x80' while syncing
DEBUG:__main__:discarding b'x02' while syncing
DEBUG:__main__:discarding b'x00' while syncing
DEBUG:__main__:discarding b'-' while syncing
DEBUG:__main__:discarding b'P' while syncing
DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'x04' while syncing
DEBUG:__main__:discarding b'x80' while syncing
DEBUG:__main__:discarding b'x02' while syncing
DEBUG:__main__:discarding b'x00' while syncing
DEBUG:__main__:discarding b'Q' while syncing
DEBUG:__main__:discarding b',' while syncing
DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'x04' while syncing

all are binary code instead of numerical result. Can anyone please tell me the reason? or is there any place I still need edit in order to make this package work in python 3? Thank you very much!!!

question from:https://stackoverflow.com/questions/65952734/problem-when-edit-a-package-from-python-2-to-3

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...