Bug#885265: [py3] some fixes to get chirpw running with python3, Fixes #7431

2020-08-06 Thread Christoph Berg
Re: Arturo Borrero Gonzalez
> I tested chirp from the upstream mercurial repository (py3 branch) today in
> Debian testing bullseye, and I got it working with python3 with the attached 
> patch.

Hi Arturo,

thanks for picking this up. I had done some python3 hacking on chirp
earlier this year, but apparently never pushed the changes anywhere
since they weren't working.

> I was able to download the image from a baofeng UV-5RA, modify it and the 
> upload
> it again.

I confirm that my UV-5R works now as well. Cool.

Fwiw, I've tried to submit changes to the tracker on danplanet for
about half a dozen times and it always failed, so no idea where to
send my patches. If this mail gets through, the python3 patches are
there:

https://salsa.debian.org/debian-hamradio-team/chirp/-/tree/master/debian/patches

py3-print: print foo => print(foo) changes
py3-except: except Exception, e => except Exception as e changes
py3-fixes: the (small) rest

Only the UV-5R module is tested, there are many other issues remaining
in the other modules, but this is a start.

Thanks,
Christoph



Bug#885265: [py3] some fixes to get chirpw running with python3, Fixes #7431

2020-08-06 Thread Arturo Borrero Gonzalez
Hi there!

I tested chirp from the upstream mercurial repository (py3 branch) today in
Debian testing bullseye, and I got it working with python3 with the attached 
patch.

I was able to download the image from a baofeng UV-5RA, modify it and the upload
it again.

Please, consider merging the attached patch. If the patch requires any mangling
please do so yourself, I'm on vacations and I don't plan to follow-up on this.

regards.
# HG changeset patch
# User Arturo Borrero Gonzalez 
# Date 1596733882 -7200
#  Thu Aug 06 19:11:22 2020 +0200
# Branch py3
# Node ID 16906193cd4089786be642ce0af684a72e29cae9
# Parent  68534f20c1418ae8e4cc09f3ff468d0375ba843a
[py3] some fixes to get chirpw running with python3, Fixes #7431

This patch contains a couple of small changes to get chirpw running with
python3.

Signed-off-by: Arturo Borrero Gonzalez 

diff -r 68534f20c141 -r 16906193cd40 chirp/drivers/uv5r.py
--- a/chirp/drivers/uv5r.py	Thu Feb 13 16:35:52 2020 -0800
+++ b/chirp/drivers/uv5r.py	Thu Aug 06 19:11:22 2020 +0200
@@ -587,7 +587,7 @@
 data += _read_block(radio, i, 0x40, False)
 
 if append_model:
-data += radio.MODEL.ljust(8)
+data += bytes(radio.MODEL.ljust(8), 'utf-8')
 
 LOG.debug("done.")
 return memmap.MemoryMapBytes(data)
diff -r 68534f20c141 -r 16906193cd40 chirp/drivers/vx6.py
--- a/chirp/drivers/vx6.py	Thu Feb 13 16:35:52 2020 -0800
+++ b/chirp/drivers/vx6.py	Thu Aug 06 19:11:22 2020 +0200
@@ -871,5 +871,5 @@
 elif setting == "password":
 newval = self._encode_chars(newval, 4)
 setattr(_settings, setting, newval)
-except Exception, e:
+except:
 raise
diff -r 68534f20c141 -r 16906193cd40 chirp/ui/mainapp.py
--- a/chirp/ui/mainapp.py	Thu Feb 13 16:35:52 2020 -0800
+++ b/chirp/ui/mainapp.py	Thu Aug 06 19:11:22 2020 +0200
@@ -1137,7 +1137,7 @@
 
 query = "http://chirp.danplanet.com/query/rb/1.0/app_direct; \
 "?loc=%s=%s=%s" % (loc, band, dist)
-print query
+print(query)
 
 # Do this in case the import process is going to take a while
 # to make sure we process events leading up to this