diff -r 6431f26aa501 -r 3291024e00da util/ProcessLogger.py --- a/util/ProcessLogger.py Thu Feb 16 14:34:40 2017 +0500 +++ b/util/ProcessLogger.py Thu Feb 16 14:35:12 2017 +0500 @@ -1,27 +1,26 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -#This file is part of Beremiz, a Integrated Development Environment for -#programming IEC 61131-3 automates supporting plcopen standard and CanFestival. -# -#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD -# -#See COPYING file for copyrights details. -# -#This library is free software; you can redistribute it and/or -#modify it under the terms of the GNU General Public -#License as published by the Free Software Foundation; either -#version 2.1 of the License, or (at your option) any later version. -# -#This library is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -#General Public License for more details. -# -#You should have received a copy of the GNU General Public -#License along with this library; if not, write to the Free Software -#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - +# This file is part of Beremiz, a Integrated Development Environment for +# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. +# +# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD +# +# See COPYING file for copyrights details. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import time import wx @@ -109,6 +108,7 @@ self.errdata = [] self.keyword = keyword self.kill_it = kill_it + self.startsem = Semaphore(0) self.finishsem = Semaphore(0) self.endlock = Lock() @@ -145,6 +145,7 @@ self.Proc.stderr, self.errors) self.errt.start() + self.startsem.release() def output(self,v): @@ -165,9 +166,11 @@ def log_the_end(self,ecode,pid): self.logger.write(self.Command_str + "\n") - self.logger.write_warning(_("exited with status %s (pid %s)\n")%(str(ecode),str(pid))) + self.logger.write_warning(_("exited with status {a1} (pid {a2})\n").format(a1 = str(ecode), a2 = str(pid))) def finish(self, pid,ecode): + # avoid running function before start is finished + self.startsem.acquire() if self.timeout: self.timeout.cancel() self.exitcode = ecode @@ -179,6 +182,10 @@ self.finishsem.release() def kill(self,gently=True): + # avoid running kill before start is finished + self.startsem.acquire() + self.startsem.release() + self.outt.killed = True self.errt.killed = True if wx.Platform == '__WXMSW__':