From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Jan Lübbe" <jlu@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 2/4] bbremote: Convert to python3
Date: Thu, 8 Sep 2022 10:16:33 +0200 [thread overview]
Message-ID: <20220908081633.GA24324@pengutronix.de> (raw)
In-Reply-To: <1019c1be5617830df3edd0a47b7f7fbd9bc2a311.camel@pengutronix.de>
On Tue, Sep 06, 2022 at 03:02:34PM +0200, Jan Lübbe wrote:
> On Tue, 2022-09-06 at 12:20 +0200, Sascha Hauer wrote:
> > This is the long overdue conversion from python2 to python3.
> >
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> > scripts/bbremote | 2 +-
> > scripts/remote/controller.py | 21 +++++++++++----------
> > scripts/remote/main.py | 8 ++++----
> > scripts/remote/messages.py | 15 +++++++++++++--
> > scripts/remote/ratp.py | 4 ++--
> > scripts/remote/ratpfs.py | 4 ++--
> > scripts/remote/threadstdio.py | 4 ++--
> > 7 files changed, 35 insertions(+), 23 deletions(-)
> >
> > diff --git a/scripts/bbremote b/scripts/bbremote
> > index bc5351dbae..1eeabd08d1 100755
> > --- a/scripts/bbremote
> > +++ b/scripts/bbremote
> > @@ -1,3 +1,3 @@
> > -#!/usr/bin/env python2
> > +#!/usr/bin/env python3
> >
> > import remote.main
> > diff --git a/scripts/remote/controller.py b/scripts/remote/controller.py
> > index b4493591dd..a3ae260558 100644
> > --- a/scripts/remote/controller.py
> > +++ b/scripts/remote/controller.py
> > @@ -1,4 +1,4 @@
> > -#!/usr/bin/env python2
> > +#!/usr/bin/env python3
> > # -*- coding: utf-8 -*-
> >
> > from __future__ import absolute_import, division, print_function
> > @@ -8,7 +8,7 @@ import logging
> > import sys
> > import os
> > from threading import Thread
> > -from Queue import Queue, Empty
> > +from queue import Queue, Empty
> > from .ratpfs import RatpFSServer
> > from .messages import *
> > from .ratp import RatpError
> > @@ -105,7 +105,7 @@ class Controller(Thread):
> > self.rxq = None
> > self.conn.connect(timeout=5.0)
> > self._txq = Queue()
> > - self._stop = False
> > + self._stopit = False
>
> Is this rename needed?
Yes. It seems the Thread class now has a member _stop itself, see:
https://github.com/python/cpython/blob/3.10/Lib/threading.py#L1028
Without this rename we get:
Traceback (most recent call last):
File "/ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/./scripts/bbremote", line 3, in <module>
import remote.main
File "/ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/scripts/remote/main.py", line 281, in <module>
res = args.func(args)
File "/ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/scripts/remote/main.py", line 185, in handle_console
ctrl.stop()
File "/ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/scripts/remote/controller.py", line 239, in stop
self.join()
File "/usr/lib/python3.9/threading.py", line 1033, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.9/threading.py", line 1051, in _wait_for_tstate_lock
self._stop()
TypeError: 'bool' object is not callable
> >
> > def _unpack_payload(self, payload):
> > + assert isinstance(payload, bytes)
> > self.cmd = payload
> >
> > def _pack_payload(self):
> > @@ -94,6 +97,8 @@ class BBPacketCommandReturn(BBPacket):
> >
> > class BBPacketConsoleMsg(BBPacket):
> > def __init__(self, raw=None, text=None):
> > + if text != None:
>
> Use 'if text is not None:'.
Ok.
> > +++ b/scripts/remote/ratpfs.py
> > @@ -1,4 +1,4 @@
> > -#!/usr/bin/env python2
> > +#!/usr/bin/env python3
> > # -*- coding: utf-8 -*-
> >
> > from __future__ import absolute_import, division, print_function
> > @@ -97,7 +97,7 @@ class RatpFSServer(object):
> > os.O_TRUNC)
> > path = params[4:]
> > try:
> > - f = os.open(self._resolve(path), flags, 0666)
> > + f = os.open(self._resolve(path), flags, 0o666)
>
> This looks like an unrelated fix.
It depends how you see it. This was accepted in python2, but no longer in python3,
so this is a step to python3 conversion.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2022-09-08 8:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-06 10:20 [PATCH 0/4] RATP updates Sascha Hauer
2022-09-06 10:20 ` [PATCH 1/4] remove local pyserial Sascha Hauer
2022-09-06 10:20 ` [PATCH 2/4] bbremote: Convert to python3 Sascha Hauer
2022-09-06 13:02 ` Jan Lübbe
2022-09-08 8:16 ` Sascha Hauer [this message]
2022-09-06 10:20 ` [PATCH 3/4] ratp: getenv: Do not crash on non-existing variables Sascha Hauer
2022-09-06 10:20 ` [PATCH 4/4] ratp: i2c: Do not return error Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220908081633.GA24324@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=jlu@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox