All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile
@ 2019-12-20 14:23 Ola x Nilsson
  2019-12-20 14:23 ` [PATCH 2/2] bitbake-layers: Keep loglevel in colored logger Ola x Nilsson
  2019-12-20 17:22 ` [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile Peter Kjellerstedt
  0 siblings, 2 replies; 6+ messages in thread
From: Ola x Nilsson @ 2019-12-20 14:23 UTC (permalink / raw)
  To: bitbake-devel

Signed-off-by: Ola x Nilsson <olani@axis.com>
---
 lib/prserv/serv.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
index 3124b079..708b2e0a 100644
--- a/lib/prserv/serv.py
+++ b/lib/prserv/serv.py
@@ -353,9 +353,8 @@ def start_daemon(dbfile, host, port, logfile):
     ip = socket.gethostbyname(host)
     pidfile = PIDPREFIX % (ip, port)
     try:
-        pf = open(pidfile,'r')
-        pid = int(pf.readline().strip())
-        pf.close()
+        with open(pidfile) as pf:
+            pid = int(pf.readline().strip())
     except IOError:
         pid = None
 
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] bitbake-layers: Keep loglevel in colored logger
  2019-12-20 14:23 [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile Ola x Nilsson
@ 2019-12-20 14:23 ` Ola x Nilsson
  2019-12-20 17:22 ` [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile Peter Kjellerstedt
  1 sibling, 0 replies; 6+ messages in thread
From: Ola x Nilsson @ 2019-12-20 14:23 UTC (permalink / raw)
  To: bitbake-devel

Signed-off-by: Ola x Nilsson <olani@axis.com>
---
 bin/bitbake-layers | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bin/bitbake-layers b/bin/bitbake-layers
index a884dc1f..149f1b1a 100755
--- a/bin/bitbake-layers
+++ b/bin/bitbake-layers
@@ -52,7 +52,9 @@ def main():
 
     # Need to re-run logger_create with color argument
     # (will be the same logger since it has the same name)
-    bb.msg.logger_create('bitbake-layers', output=sys.stdout, color=global_args.color)
+    bb.msg.logger_create('bitbake-layers', output=sys.stdout,
+                         color=global_args.color,
+                         level=logger.getEffectiveLevel())
 
     plugins = []
     tinfoil = bb.tinfoil.Tinfoil(tracking=True)
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile
  2019-12-20 14:23 [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile Ola x Nilsson
  2019-12-20 14:23 ` [PATCH 2/2] bitbake-layers: Keep loglevel in colored logger Ola x Nilsson
@ 2019-12-20 17:22 ` Peter Kjellerstedt
  2019-12-30 11:00   ` Richard Purdie
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Kjellerstedt @ 2019-12-20 17:22 UTC (permalink / raw)
  To: Ola x Nilsson, bitbake-devel

> -----Original Message-----
> From: bitbake-devel-bounces@lists.openembedded.org <bitbake-devel-
> bounces@lists.openembedded.org> On Behalf Of Ola x Nilsson
> Sent: den 20 december 2019 15:23
> To: bitbake-devel@lists.openembedded.org
> Subject: [bitbake-devel] [PATCH 1/2] bitbake: prserv/serv: Use with while
> reading pidfile
> 
> Signed-off-by: Ola x Nilsson <olani@axis.com>
> ---
>  lib/prserv/serv.py | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
> index 3124b079..708b2e0a 100644
> --- a/lib/prserv/serv.py
> +++ b/lib/prserv/serv.py
> @@ -353,9 +353,8 @@ def start_daemon(dbfile, host, port, logfile):
>      ip = socket.gethostbyname(host)
>      pidfile = PIDPREFIX % (ip, port)
>      try:
> -        pf = open(pidfile,'r')
> -        pid = int(pf.readline().strip())
> -        pf.close()
> +        with open(pidfile) as pf:
> +            pid = int(pf.readline().strip())
>      except IOError:
>          pid = None
> 
> --
> 2.11.0

This only half the patch. Please add the following:

@@ -292,10 +292,9 @@ class PRServer(SimpleXMLRPCServer):
         logger.addHandler(streamhandler)
 
         # write pidfile
-        pid = str(os.getpid()) 
-        pf = open(self.pidfile, 'w')
-        pf.write("%s\n" % pid)
-        pf.close()
+        pid = str(os.getpid())
+        with open(self.pidfile, 'w') as pf:
+            pf.write("%s\n" % pid)
 
         self.work_forever()
         self.delpid()

//Peter



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile
  2019-12-20 17:22 ` [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile Peter Kjellerstedt
@ 2019-12-30 11:00   ` Richard Purdie
  2019-12-30 12:20     ` Peter Kjellerstedt
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Purdie @ 2019-12-30 11:00 UTC (permalink / raw)
  To: Peter Kjellerstedt, Ola x Nilsson, bitbake-devel

On Fri, 2019-12-20 at 17:22 +0000, Peter Kjellerstedt wrote:
> > -----Original Message-----
> > From: bitbake-devel-bounces@lists.openembedded.org <bitbake-devel-
> > bounces@lists.openembedded.org> On Behalf Of Ola x Nilsson
> > Sent: den 20 december 2019 15:23
> > To: bitbake-devel@lists.openembedded.org
> > Subject: [bitbake-devel] [PATCH 1/2] bitbake: prserv/serv: Use with
> > while
> > reading pidfile
> > 
> > Signed-off-by: Ola x Nilsson <olani@axis.com>
> > ---
> >  lib/prserv/serv.py | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
> > index 3124b079..708b2e0a 100644
> > --- a/lib/prserv/serv.py
> > +++ b/lib/prserv/serv.py
> > @@ -353,9 +353,8 @@ def start_daemon(dbfile, host, port, logfile):
> >      ip = socket.gethostbyname(host)
> >      pidfile = PIDPREFIX % (ip, port)
> >      try:
> > -        pf = open(pidfile,'r')
> > -        pid = int(pf.readline().strip())
> > -        pf.close()
> > +        with open(pidfile) as pf:
> > +            pid = int(pf.readline().strip())
> >      except IOError:
> >          pid = None
> > 
> > --
> > 2.11.0
> 
> This only half the patch. Please add the following:
> 
> @@ -292,10 +292,9 @@ class PRServer(SimpleXMLRPCServer):
>          logger.addHandler(streamhandler)
>  
>          # write pidfile
> -        pid = str(os.getpid()) 
> -        pf = open(self.pidfile, 'w')
> -        pf.write("%s\n" % pid)
> -        pf.close()
> +        pid = str(os.getpid())
> +        with open(self.pidfile, 'w') as pf:
> +            pf.write("%s\n" % pid)
>  
>          self.work_forever()
>          self.delpid()
> 

I've handled this but asking me to manually merge hunks of patches
together before applying them seems a little potentially error prone?

Cheers,

Richard



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile
  2019-12-30 11:00   ` Richard Purdie
@ 2019-12-30 12:20     ` Peter Kjellerstedt
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Kjellerstedt @ 2019-12-30 12:20 UTC (permalink / raw)
  To: Richard Purdie, Ola x Nilsson, bitbake-devel

> -----Original Message-----
> From: Richard Purdie <richard.purdie@linuxfoundation.org>
> Sent: den 30 december 2019 12:00
> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>; Ola x Nilsson
> <Ola.x.Nilsson@axis.com>; bitbake-devel@lists.openembedded.org
> Subject: Re: [bitbake-devel] [PATCH 1/2] bitbake: prserv/serv: Use with
> while reading pidfile
> 
> On Fri, 2019-12-20 at 17:22 +0000, Peter Kjellerstedt wrote:
> > > -----Original Message-----
> > > From: bitbake-devel-bounces@lists.openembedded.org <bitbake-devel-
> > > bounces@lists.openembedded.org> On Behalf Of Ola x Nilsson
> > > Sent: den 20 december 2019 15:23
> > > To: bitbake-devel@lists.openembedded.org
> > > Subject: [bitbake-devel] [PATCH 1/2] bitbake: prserv/serv: Use with
> > > while
> > > reading pidfile
> > >
> > > Signed-off-by: Ola x Nilsson <olani@axis.com>
> > > ---
> > >  lib/prserv/serv.py | 5 ++---
> > >  1 file changed, 2 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
> > > index 3124b079..708b2e0a 100644
> > > --- a/lib/prserv/serv.py
> > > +++ b/lib/prserv/serv.py
> > > @@ -353,9 +353,8 @@ def start_daemon(dbfile, host, port, logfile):
> > >      ip = socket.gethostbyname(host)
> > >      pidfile = PIDPREFIX % (ip, port)
> > >      try:
> > > -        pf = open(pidfile,'r')
> > > -        pid = int(pf.readline().strip())
> > > -        pf.close()
> > > +        with open(pidfile) as pf:
> > > +            pid = int(pf.readline().strip())
> > >      except IOError:
> > >          pid = None
> > >
> > > --
> > > 2.11.0
> >
> > This only half the patch. Please add the following:
> >
> > @@ -292,10 +292,9 @@ class PRServer(SimpleXMLRPCServer):
> >          logger.addHandler(streamhandler)
> >
> >          # write pidfile
> > -        pid = str(os.getpid())
> > -        pf = open(self.pidfile, 'w')
> > -        pf.write("%s\n" % pid)
> > -        pf.close()
> > +        pid = str(os.getpid())
> > +        with open(self.pidfile, 'w') as pf:
> > +            pf.write("%s\n" % pid)
> >
> >          self.work_forever()
> >          self.delpid()
> >
> 
> I've handled this but asking me to manually merge hunks of patches
> together before applying them seems a little potentially error prone?
> 
> Cheers,
> 
> Richard

Well, I mainly meant for Ola to send an updated patch with both hunks, but 
I guess I should have stated that in my response. Anyway, thanks for taking 
care of it.

//Peter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile
@ 2019-10-21  9:07 Ola x Nilsson
  0 siblings, 0 replies; 6+ messages in thread
From: Ola x Nilsson @ 2019-10-21  9:07 UTC (permalink / raw)
  To: bitbake-devel

Signed-off-by: Ola x Nilsson <olani@axis.com>
---
 lib/prserv/serv.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
index be3acec3..2bc68904 100644
--- a/lib/prserv/serv.py
+++ b/lib/prserv/serv.py
@@ -379,9 +379,8 @@ def stop_daemon(host, port):
     ip = socket.gethostbyname(host)
     pidfile = PIDPREFIX % (ip, port)
     try:
-        pf = open(pidfile,'r')
-        pid = int(pf.readline().strip())
-        pf.close()
+        with open(pidfile) as pf:
+            pid = int(pf.readline().strip())
     except IOError:
         pid = None
 
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-12-30 12:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 14:23 [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile Ola x Nilsson
2019-12-20 14:23 ` [PATCH 2/2] bitbake-layers: Keep loglevel in colored logger Ola x Nilsson
2019-12-20 17:22 ` [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile Peter Kjellerstedt
2019-12-30 11:00   ` Richard Purdie
2019-12-30 12:20     ` Peter Kjellerstedt
  -- strict thread matches above, loose matches on Subject: below --
2019-10-21  9:07 Ola x Nilsson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.