[elbe-devel] [PATCH] projectmanager: fix handling of utf-8 characters in logfile lines

Manuel Traut manut at linutronix.de
Tue Feb 19 18:18:20 CET 2019


Hi Torben, Andreas,

thanks for analysation, debugging, fixing and testing of the issue!

On 10:16 Thu 14 Feb     , Andreas Messerschmid wrote:
> On 2/12/19 5:41 PM, Torben Hohn wrote:
> > ProjectManager.current_project_is_busy() returns str.
> > the result is returned as a String from ESoap.get_project_busy()
> > In reality spyne.model.primitive.String is Unicode, though.
> > When the return value can not be converted to Unicode, which is the
> > case, when a logline contains non ascii characters, the return value is
> > omitted from the xml result file.
> > 
> > This makes client.service.get_project_busy() return None in
> > WaitProjectBusyAction.execute() and this results in
> > the dubious "strange part: %d (skipped)" messages.
> > 
> > Fix this by calling logline.decode('utf-8','replace') and converting
> > the rest of the logline handling to unicode.
> > 
> > Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
> 
> Tested-by: Andreas Messerschmid <andreas.messerschmid at linutronix.de>
Reviewed-by: Manuel Traut <manut at linutronix.de>

and added to devel/elbe-3.0

  Manuel

> > ---
> >  elbepack/projectmanager.py | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
> > index 7738ee28..e848d9bf 100644
> > --- a/elbepack/projectmanager.py
> > +++ b/elbepack/projectmanager.py
> > @@ -527,14 +527,15 @@ class ProjectManager(object):
> >              logline = None
> >              with open(os.path.join(ep.builddir, 'log.txt'), 'r', 0) as lf:
> >                  for logline in lf:
> > +                    logline = logline.decode('utf-8','replace')
> >                      if count == part:
> > -                        logline = str(part + 1) + '###' + str(logline)
> > -                        return self.db.is_busy(ep.builddir), str(logline)
> > +                        logline = unicode(part + 1) + u'###' + logline
> > +                        return self.db.is_busy(ep.builddir), logline
> >                      count = count + 1
> >              # don't crash if logfile doesn't exist
> >              if not logline:
> > -                logline = None
> > -            logline = str(part) + '###' + str(logline)
> > +                logline = u'None'
> > +            logline = unicode(part) + u'###' + logline
> >              return self.db.is_busy(ep.builddir), logline
> >  
> >      def _get_current_project(self, userid, allow_busy=True):
> > 
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel



More information about the elbe-devel mailing list