--- a/plugger.py Fri Oct 16 10:50:16 2009 +0200
+++ b/plugger.py Mon Oct 19 16:03:46 2009 +0200
@@ -231,7 +231,7 @@
}, ...]
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
"""
- self.logger.write_warning(".".join(map(lambda x:str(x), self.GetCurrentLocation())) + " -> Nothing to do\n")
+ self.GetPlugRoot().logger.write_warning(".".join(map(lambda x:str(x), self.GetCurrentLocation())) + " -> Nothing to do\n")
return [],"",False
def _Generate_C(self, buildpath, locations):
@@ -429,7 +429,7 @@
shutil.move(oldname, self.PlugPath())
# warn user he has two left hands
if DesiredName != res:
- self.logger.write_warning(_("A child names \"%s\" already exist -> \"%s\"\n")%(DesiredName,res))
+ self.GetPlugRoot().logger.write_warning(_("A child names \"%s\" already exist -> \"%s\"\n")%(DesiredName,res))
return res
def FindNewIEC_Channel(self, DesiredChannel):
@@ -454,14 +454,14 @@
if res < CurrentChannel: # Want to go down ?
res -= 1 # Test for n-1
if res < 0 :
- self.logger.write_warning(_("Cannot find lower free IEC channel than %d\n")%CurrentChannel)
+ self.GetPlugRoot().logger.write_warning(_("Cannot find lower free IEC channel than %d\n")%CurrentChannel)
return CurrentChannel # Can't go bellow 0, do nothing
else : # Want to go up ?
res += 1 # Test for n-1
# Finally set IEC Channel
self.BaseParams.setIEC_Channel(res)
if DesiredChannel != res:
- self.logger.write_warning(_("A child with IEC channel %d already exist -> %d\n")%(DesiredChannel,res))
+ self.GetPlugRoot().logger.write_warning(_("A child with IEC channel %d already exist -> %d\n")%(DesiredChannel,res))
return res
def OnPlugClose(self):
@@ -521,8 +521,6 @@
def __init__(_self):
# self is the parent
_self.PlugParent = self
- # self is the parent
- _self.logger = self.logger
# Keep track of the plugin type name
_self.PlugType = PlugType
# remind the help string, for more fancy display
@@ -599,8 +597,8 @@
self.MandatoryParams[1].loadXMLTree(basetree.childNodes[0])
basexmlfile.close()
except Exception, exc:
- self.logger.write_error(_("Couldn't load plugin base parameters %s :\n %s") % (PlugName, str(exc)))
- self.logger.write_error(traceback.format_exc())
+ self.GetPlugRoot().logger.write_error(_("Couldn't load plugin base parameters %s :\n %s") % (PlugName, str(exc)))
+ self.GetPlugRoot().logger.write_error(traceback.format_exc())
# Get the xml tree
if self.PlugParams:
@@ -610,8 +608,8 @@
self.PlugParams[1].loadXMLTree(tree.childNodes[0])
xmlfile.close()
except Exception, exc:
- self.logger.write_error(_("Couldn't load plugin parameters %s :\n %s") % (PlugName, str(exc)))
- self.logger.write_error(traceback.format_exc())
+ self.GetPlugRoot().logger.write_error(_("Couldn't load plugin parameters %s :\n %s") % (PlugName, str(exc)))
+ self.GetPlugRoot().logger.write_error(traceback.format_exc())
def LoadChilds(self):
# Iterate over all PlugName@PlugType in plugin directory, and try to open them
@@ -622,8 +620,8 @@
try:
self.PlugAddChild(pname, ptype)
except Exception, exc:
- self.logger.write_error(_("Could not add child \"%s\", type %s :\n%s\n")%(pname, ptype, str(exc)))
- self.logger.write_error(traceback.format_exc())
+ self.GetPlugRoot().logger.write_error(_("Could not add child \"%s\", type %s :\n%s\n")%(pname, ptype, str(exc)))
+ self.GetPlugRoot().logger.write_error(traceback.format_exc())
def EnableMethod(self, method, value):
for d in self.PluginMethods:
--- a/plugins/canfestival/canfestival.py Fri Oct 16 10:50:16 2009 +0200
+++ b/plugins/canfestival/canfestival.py Mon Oct 19 16:03:46 2009 +0200
@@ -200,12 +200,12 @@
buildpath = self._getBuildPath()
# Eventually create build dir
if not os.path.exists(buildpath):
- self.logger.write_error(_("Error: No PLC built\n"))
+ self.GetPlugRoot().logger.write_error(_("Error: No PLC built\n"))
return
masterpath = os.path.join(buildpath, "MasterGenerated.od")
if not os.path.exists(masterpath):
- self.logger.write_error(_("Error: No Master generated\n"))
+ self.GetPlugRoot().logger.write_error(_("Error: No Master generated\n"))
return
new_dialog = objdictedit(None, filesOpen=[masterpath])
--- a/plugins/python/modules/svgui/svgui.py Fri Oct 16 10:50:16 2009 +0200
+++ b/plugins/python/modules/svgui/svgui.py Mon Oct 19 16:03:46 2009 +0200
@@ -93,7 +93,7 @@
if os.path.isfile(svgpath):
shutil.copy(svgpath, self._getSVGpath())
else:
- self.logger.write_error(_("No such SVG file: %s\n")%svgpath)
+ self.GetPlugRoot().logger.write_error(_("No such SVG file: %s\n")%svgpath)
dialog.Destroy()
def _StartInkscape(self):
--- a/targets/Xenomai/__init__.py Fri Oct 16 10:50:16 2009 +0200
+++ b/targets/Xenomai/__init__.py Mon Oct 19 16:03:46 2009 +0200
@@ -11,9 +11,9 @@
# get xeno-config from target parameters
xeno_config = self.getXenoConfig()
- status, result, err_result = ProcessLogger(self.logger, xeno_config + " --xeno-ldflags", no_stdout=True).spin()
+ status, result, err_result = ProcessLogger(self.PluginsRootInstance.logger, xeno_config + " --xeno-ldflags", no_stdout=True).spin()
if status:
- self.logger.write_error(_("Unable to get Xenomai's LDFLAGS\n"))
+ self.PluginsRootInstance.logger.write_error(_("Unable to get Xenomai's LDFLAGS\n"))
xeno_ldlags = result.strip()
return toolchain_gcc.getBuilderLDFLAGS(self) + [xeno_ldlags, "-shared", "-lnative"]
@@ -22,9 +22,9 @@
# get xeno-config from target parameters
xeno_config = self.getXenoConfig()
- status, result, err_result = ProcessLogger(self.logger, xeno_config + " --xeno-cflags", no_stdout=True).spin()
+ status, result, err_result = ProcessLogger(self.PluginsRootInstance.logger, xeno_config + " --xeno-cflags", no_stdout=True).spin()
if status:
- self.logger.write_error(_("Unable to get Xenomai's CFLAGS\n"))
+ self.PluginsRootInstance.logger.write_error(_("Unable to get Xenomai's CFLAGS\n"))
xeno_cflags = result.strip()
return toolchain_gcc.getBuilderCFLAGS(self) + [xeno_cflags]
--- a/targets/toolchain_gcc.py Fri Oct 16 10:50:16 2009 +0200
+++ b/targets/toolchain_gcc.py Mon Oct 19 16:03:46 2009 +0200
@@ -12,7 +12,6 @@
"""
def __init__(self, PluginsRootInstance):
self.PluginsRootInstance = PluginsRootInstance
- self.logger = PluginsRootInstance.logger
self.exe = PluginsRootInstance.GetProjectName() + self.extension
self.buildpath = PluginsRootInstance._getBuildPath()
self.exe_path = os.path.join(self.buildpath, self.exe)
@@ -96,9 +95,9 @@
relink = False
for Location, CFilesAndCFLAGS, DoCalls in self.PluginsRootInstance.LocationCFilesAndCFLAGS:
if Location:
- self.logger.write(_("Plugin : ") + self.PluginsRootInstance.GetChildByIECLocation(Location).GetCurrentName() + " " + str(Location)+"\n")
+ self.PluginsRootInstance.logger.write(_("Plugin : ") + self.PluginsRootInstance.GetChildByIECLocation(Location).GetCurrentName() + " " + str(Location)+"\n")
else:
- self.logger.write(_("PLC :\n"))
+ self.PluginsRootInstance.logger.write(_("PLC :\n"))
for CFile, CFLAGS in CFilesAndCFLAGS:
bn = os.path.basename(CFile)
@@ -108,21 +107,21 @@
match = self.check_and_update_hash_and_deps(bn)
if match:
- self.logger.write(" [pass] "+bn+" -> "+obn+"\n")
+ self.PluginsRootInstance.logger.write(" [pass] "+bn+" -> "+obn+"\n")
else:
relink = True
- self.logger.write(" [CC] "+bn+" -> "+obn+"\n")
+ self.PluginsRootInstance.logger.write(" [CC] "+bn+" -> "+obn+"\n")
status, result, err_result = ProcessLogger(
- self.logger,
+ self.PluginsRootInstance.logger,
"\"%s\" -c \"%s\" -o \"%s\" %s %s"%
(self.compiler, CFile, objectfilename, Builder_CFLAGS, CFLAGS)
).spin()
if status :
self.srcmd5.pop(bn)
- self.logger.write_error(_("C compilation of %s failed.\n")%bn)
+ self.PluginsRootInstance.logger.write_error(_("C compilation of %s failed.\n")%bn)
return False
obns.append(obn)
@@ -130,7 +129,7 @@
######### GENERATE library FILE ########################################
# Link all the object files into one binary file
- self.logger.write(_("Linking :\n"))
+ self.PluginsRootInstance.logger.write(_("Linking :\n"))
if relink:
objstring = []
@@ -139,10 +138,10 @@
ALLldflags = ' '.join(self.getBuilderLDFLAGS())
- self.logger.write(" [CC] " + ' '.join(obns)+" -> " + self.exe + "\n")
+ self.PluginsRootInstance.logger.write(" [CC] " + ' '.join(obns)+" -> " + self.exe + "\n")
status, result, err_result = ProcessLogger(
- self.logger,
+ self.PluginsRootInstance.logger,
"\"%s\" %s -o \"%s\" %s"%
(self.linker,
listobjstring,
@@ -162,7 +161,7 @@
f.write(self.md5key)
f.close()
else:
- self.logger.write(" [pass] " + ' '.join(obns)+" -> " + self.exe + "\n")
+ self.PluginsRootInstance.logger.write(" [pass] " + ' '.join(obns)+" -> " + self.exe + "\n")
return True
--- a/wxPopen.py Fri Oct 16 10:50:16 2009 +0200
+++ b/wxPopen.py Mon Oct 19 16:03:46 2009 +0200
@@ -64,8 +64,8 @@
except:
err = self.retval
self.finished = True
- wx.CallAfter(self.endcallback, self.Proc.pid, err)
-
+ self.endcallback(self.Proc.pid, err)
+
class ProcessLogger:
def __init__(self, logger, Command, finish_callback=None, no_stdout=False, no_stderr=False, no_gui=True):
self.logger = logger
@@ -121,13 +121,19 @@
self.outdata += v
self.outlen += 1
if not self.no_stdout:
- wx.CallAfter(self.logger.write,v)
-
+ if wx.GetApp() is None:
+ self.logger.write(v)
+ else:
+ wx.CallAfter(self.logger.write,v)
+
def errors(self,v):
self.errdata += v
self.errlen += 1
if not self.no_stderr:
- wx.CallAfter(self.logger.write_warning,v)
+ if wx.GetApp() is None:
+ self.logger.write_warning(v)
+ else:
+ wx.CallAfter(self.logger.write_warning,v)
def log_the_end(self,ecode,pid):
self.logger.write(self.Command_str + "\n")
@@ -137,7 +143,10 @@
self.finished = True
self.exitcode = ecode
if self.exitcode != 0:
- wx.CallAfter(self.log_the_end,ecode,pid)
+ if wx.GetApp() is None:
+ self.log_the_end(ecode,pid)
+ else:
+ wx.CallAfter(self.log_the_end,ecode,pid)
if self.finish_callback is not None:
self.finish_callback(self,ecode,pid)
@@ -174,7 +183,9 @@
count += 1
if keyword and self.outdata.find(keyword)!=-1:
break
- wx.Yield()
+ app = wx.GetApp()
+ if app is not None:
+ app.Yield()
time.sleep(0.01)
if not self.outt.finished and kill_it: