shinysdr icon indicating copy to clipboard operation
shinysdr copied to clipboard

Python 3 support for ShinySDR

Open quentinmit opened this issue 3 years ago • 15 comments

I can't promise everything works but all the basic functionality seems to be there and working in my tests. I kept each logical change as a separate commit so you can easily review them. I believe all of these changes are backwards-compatible to Python 2.7. Several of the tests are failing but it seems like that was true before these commits as well. I can start trying to knock off the tests in this PR if you'd like, or I can leave that for another PR.

quentinmit avatar Jul 21 '20 09:07 quentinmit

My computer(s) are a bit in disarray right now, so I may be a while giving this a proper code review. So, thanks for doing this, and I'll give you some quick cheap observations. Unfortunately, the Travis CI integration seems to have not posted results here (I may have reauthorized it now, but I'm not sure) but here they are. There are two simple lints:

shinysdr/i/network/webapp.py:79:1: E305 expected 2 blank lines after class or function definition, found 0
shinysdr/i/network/export_http.py:35:1: F401 'shinysdr.i.pycompat.defaultstr' imported but unused

And there are several test failures in the Python 2.7 environment, all looking like they have to do with details of web serving (probably str/bytes/unicode confusion). It's okay to go from failing to failing on Python 3, but the tests must remain passing under Python 2 (until we drop Python 2 support, which will come no sooner than adding GNU Radio 3.8 support).

kpreid avatar Jul 22 '20 01:07 kpreid

My computer(s) are a bit in disarray right now, so I may be a while giving this a proper code review. So, thanks for doing this, and I'll give you some quick cheap observations. Unfortunately, the Travis CI integration seems to have not posted results here (I may have reauthorized it now, but I'm not sure) but here they are. There are two simple lints:

shinysdr/i/network/webapp.py:79:1: E305 expected 2 blank lines after class or function definition, found 0
shinysdr/i/network/export_http.py:35:1: F401 'shinysdr.i.pycompat.defaultstr' imported but unused

And there are several test failures in the Python 2.7 environment, all looking like they have to do with details of web serving (probably str/bytes/unicode confusion). It's okay to go from failing to failing on Python 3, but the tests must remain passing under Python 2 (until we drop Python 2 support, which will come no sooner than adding GNU Radio 3.8 support).

I don't have a good Python 2 GR environment anymore. I guess I could see how many tests run without being able to import gnuradio. I'll take a stab at trying to fix the bytes confusion.

I didn't mention it in the PR description but this also runs on GNU Radio 3.8.

quentinmit avatar Jul 22 '20 02:07 quentinmit

OK, when I have my GR development environment back, I'll see if I can contribute any tweaks to get it working on both — or perhaps merge whatever subset of these commits are straightforwardly compatible.

kpreid avatar Jul 22 '20 02:07 kpreid

OK, when I have my GR development environment back, I'll see if I can contribute any tweaks to get it working on both — or perhaps merge whatever subset of these commits are straightforwardly compatible.

I just pushed a fix to the only test that I could find broken on 2.7 (shinysdr.i.test_db.TestDatabaseResource). And the lint fixes. With that I get:

Ran 547 tests in 7.796s

PASSED (skips=12, successes=535)

There are definitely still test failures left on Python 3.8, though.

I don't know how disarrayed your computers are right now, but if you have a computer that can run Docker you can pull the w1xm/shinysdr Docker image if you want a Python 3.8 + GR 3.8 + ShinySDR dev environment. There's also w1xm/base:python2 if you want GR 3.8 + Python 2.7, though it doesn't have ShinySDR preinstalled.

quentinmit avatar Jul 22 '20 09:07 quentinmit

I can't leave it alone, so I ran trial3 inside docker and got it down to:

Ran 547 tests in 11.684s

FAILED (skips=5, failures=3, successes=539)

trial2 is still passing as well, and running it on Py3.8 + GR3.8 seems to cursorily work. As part of the most recent commit I think I fixed the OsmoSDR source (we don't use it, though, so I can't be sure).

The only remaining failing tests on Python 3.8 are:

shinysdr.i.network.test_export_ws.TestStateStream.test_two_references
shinysdr.i.test_main.TestMain.test_minimal
shinysdr.i.test_main.TestMain.test_persistence

AFAICT the last two (and maybe also the first?) appear to be testing the order of items in a dictionary, which was not defined behavior and changed in Python 3.7.

quentinmit avatar Jul 22 '20 11:07 quentinmit

@kpreid Hey, this has been sitting for a couple weeks... any chance to look at this yet?

quentinmit avatar Aug 08 '20 05:08 quentinmit

It's been three weeks, have you had a chance to get your GR development environment working yet?

quentinmit avatar Oct 11 '20 04:10 quentinmit

Sorry, I've been very busy dealing with various further life complications, and also a bit of obsession with another project. This is still on my todo list.

kpreid avatar Oct 11 '20 04:10 kpreid

I’ve been checking back here from time to time. I’d like to add shinysdr back to DragonOS (project of mine). It’s already got python3/gnuradio 3.8 included. Just curious if there’s any movement planned on this or if I should just try to piece it together based on this PR and test it that way? Thanks

alphafox02 avatar Jan 16 '21 15:01 alphafox02

Tested it real quick and found that it works rather well. Thanks for doing this PR. I went ahead and also installed gr-air-modes and gr-dad. I had pretty much everything else that was needed, except gr-radioteletype which looks to be for an older gnuradio.

One thing I noticed, I can see mode S info in the terminal but am I supposed to be seeing the messages decoded somewhere in the shinysdr GUI? I have the map up and do not see anything there.

alphafox02 avatar Jan 16 '21 17:01 alphafox02

I think I figured out that for whatever reason I’m not getting positions on Adsb, but I do see mode S messages.

Another note, I thought I’d get lucky and this would work,

https://github.com/mcapdeville/gr-radioteletype/commit/69b6b182e67a85ddce581037a10f176e3516d833

But after installing the 3.8 version shiny SDR would not start till I uninstalled gr-radioteletype. Thought maybe I’d have all the features working, so close.

alphafox02 avatar Jan 17 '21 01:01 alphafox02

Love this project. I hope this branch gets completed and this project upgraded to python 3!

NeuroForLunch avatar May 01 '21 18:05 NeuroForLunch

我现在正在开始的迁移工作,从gnuradio3.7+python2.7迁移到gnuradio3.9+python3.8 正在迁移的过程中,目前通过python setup.py build 和 sudo python setup.py install 返回的错误提示修改了两处位置。

  1. 在setup.py 中 urllib改成了urllib.request
  2. 关于rational_resampler #from gnuradio.filter import rational_resampler

try: from gnuradio.filter import rational_resampler except ImportError: dirname, filename = os.path.split(os.path.abspath(file)) path.append(os.path.join(dirname, "bindings")) from gnuradio.filter.filter_python import rational_resampler

并且升级了 Twisted six txWS PyEphem pyserial等相关依赖,但是目前还是存在问题。 是否有成功的给与我一些建议。谢谢。 `

revivec avatar Feb 18 '23 03:02 revivec

Hi, are there any plans to merge this PR?

s-martin avatar May 20 '23 18:05 s-martin

Be even better to see if support gr 3.9+

alphafox02 avatar May 20 '23 19:05 alphafox02