tbird20d / grabserial

Grabserial - python-based serial dump and timing program - good for embedded Linux development
GNU General Public License v2.0
195 stars 77 forks source link

Python3 compatibility #18

Closed ikv closed 6 years ago

ikv commented 6 years ago

Fixes python3 TabError's:

$ python3 grabserial
  File "grabserial", line 314
    if opt in ["--crtonewline"]:
                               ^
TabError: inconsistent use of tabs and spaces in indentation

Python3 renames thread to _thread, so we need to import accordingly. Also, raw_input was renamed to input.

Adds proper handling of bytes vs strings, because in python3 you cannot write bytes to stdout and strings to open('wb') file

ikv commented 6 years ago

@tbird20d ping?

tbird20d commented 6 years ago

Sorry - I had hoped to get this done before the Christmas holidays, but ran out of time.I've been out-of-the-office for the last week or so. I did take a look at portions of it, but didn't finish everything.  I read up on some of the Python 3 string/byte handling.  It looks pretty good.  I hope to get to it in the nextfew days. Thanks for the submission. -- Tim

On Wednesday, December 27, 2017, 4:02:51 PM PST, Ilya Kuzmich <notifications@github.com> wrote:  

@tbird20d ping?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub, or mute the thread.

tbird20d commented 6 years ago

I accepted two of the patches here:

I rejected two of the patches here:

tbird20d commented 6 years ago

BTW - thanks for the patches. It inspired me to add some linters to the code, and I'm fixing a lot of source errors now. See test.sh for some tests I'm adding to my release process.

ikv commented 6 years ago

the one for using #!/usr/bin/env - this has some disadvantages that I don't like, over the static, absolute path to the python binary.

Why? Not every environment installs python to /usr/bin/python

Regarding strings handling: python3 str is more like python2 unicode, and python3 bytes is almost like python2 str. Grabserial receives bytes from pyserial, but stdout is in text mode, not binary, therefore writing to stdout requires decoding.