--- a/Beremiz.py Wed Apr 24 10:03:47 2013 +0200
+++ b/Beremiz.py Wed Apr 24 17:27:08 2013 +0200
@@ -980,7 +980,6 @@
self._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES)
def OnQuitMenu(self, event):
--- a/ConfigTreeNode.py Wed Apr 24 10:03:47 2013 +0200
+++ b/ConfigTreeNode.py Wed Apr 24 17:27:08 2013 +0200
@@ -73,10 +73,12 @@
return os.path.join(self.CTNParent.ConfNodePath(), self.CTNType)
- def CTNPath(self,CTNName=None):
+ def CTNPath(self,CTNName=None,project_path=None): - return os.path.join(self.CTNParent.CTNPath(),
+ project_path = self.CTNParent.CTNPath() + return os.path.join(project_path, CTNName + NameTypeSeparator + self.CTNType)
@@ -113,7 +115,7 @@
def RemoteExec(self, script, **kwargs):
return self.CTNParent.RemoteExec(script, **kwargs)
+ def OnCTNSave(self, from_project_path=None): #Default, do nothing and return success
@@ -155,7 +157,7 @@
- def CTNRequestSave(self):
+ def CTNRequestSave(self, from_project_path=None): if self.GetCTRoot().CheckProjectPathPerm(False):
# If confnode do not have corresponding directory
@@ -178,7 +180,7 @@
# Call the confnode specific OnCTNSave method
- result = self.OnCTNSave()
+ result = self.OnCTNSave(from_project_path) return _("Error while saving \"%s\"\n")%self.CTNPath()
@@ -186,7 +188,8 @@
self.ChangesToSave = False
# go through all children and do the same
for CTNChild in self.IterChildren():
- result = CTNChild.CTNRequestSave()
+ result = CTNChild.CTNRequestSave( + CTNChild.CTNPath(project_path=from_project_path)) --- a/ProjectController.py Wed Apr 24 10:03:47 2013 +0200
+++ b/ProjectController.py Wed Apr 24 17:27:08 2013 +0200
@@ -234,7 +234,9 @@
- def _getProjectFilesPath(self):
+ def _getProjectFilesPath(self, project_path=None): + if project_path is not None: + return os.path.join(project_path, "project_files") projectfiles_path = os.path.join(self.GetProjectPath(), "project_files")
if not os.path.exists(projectfiles_path):
os.mkdir(projectfiles_path)
@@ -348,14 +350,19 @@
+ def SaveProject(self, from_project_path=None): if self.CheckProjectPathPerm(False):
+ if from_project_path is not None: + old_projectfiles_path = self._getProjectFilesPath(from_project_path) + if os.path.isdir(old_projectfiles_path): + shutil.copytree(old_projectfiles_path, + self._getProjectFilesPath(self.ProjectPath)) self.SaveXMLFile(os.path.join(self.ProjectPath, 'plc.xml'))
- result = self.CTNRequestSave()
+ result = self.CTNRequestSave(from_project_path) self.logger.write_error(result)
- def SaveProjectAs(self, dosave=True):
+ def SaveProjectAs(self): # Ask user to choose a path with write permissions
if wx.Platform == '__WXMSW__':
path = os.getenv("USERPROFILE")
@@ -367,9 +374,8 @@
newprojectpath = dirdialog.GetPath()
if os.path.isdir(newprojectpath):
- self.ProjectPath = newprojectpath
+ self.ProjectPath, old_project_path = newprojectpath, self.ProjectPath + self.SaveProject(old_project_path) self._setBuildPath(self.BuildPath)
--- a/c_ext/c_ext.py Wed Apr 24 10:03:47 2013 +0200
+++ b/c_ext/c_ext.py Wed Apr 24 17:27:08 2013 +0200
@@ -144,7 +144,7 @@
def CTNTestModified(self):
return self.ChangesToSave or not self.CFileIsSaved()
+ def OnCTNSave(self, from_project_path=None): filepath = self.CFileName()
text = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
--- a/canfestival/canfestival.py Wed Apr 24 10:03:47 2013 +0200
+++ b/canfestival/canfestival.py Wed Apr 24 17:27:08 2013 +0200
@@ -1,4 +1,4 @@
base_folder = os.path.split(sys.path[0])[0]
CanFestivalPath = os.path.join(base_folder, "CanFestival-3")
@@ -154,7 +154,7 @@
def CTNTestModified(self):
return self.ChangesToSave or self.OneFileHasChanged()
+ def OnCTNSave(self, from_project_path=None): return self.SaveCurrentInFile(self.GetSlaveODPath())
def SetParamsAttribute(self, path, value):
@@ -378,8 +378,10 @@
def CTNTestModified(self):
return self.ChangesToSave or self.HasChanged()
+ def OnCTNSave(self, from_project_path=None): self.SetRoot(self.CTNPath())
+ shutil.copytree(self.GetEDSFolder(from_project_path), return self.SaveProject() is None
def CTNGenerate_C(self, buildpath, locations):
--- a/py_ext/PythonFileCTNMixin.py Wed Apr 24 10:03:47 2013 +0200
+++ b/py_ext/PythonFileCTNMixin.py Wed Apr 24 17:27:08 2013 +0200
@@ -48,7 +48,7 @@
def CTNTestModified(self):
return self.ChangesToSave or not self.PythonIsSaved()
+ def OnCTNSave(self, from_project_path=None): filepath = self.PythonFileName()
text = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
--- a/svgui/svgui.py Wed Apr 24 10:03:47 2013 +0200
+++ b/svgui/svgui.py Wed Apr 24 17:27:08 2013 +0200
@@ -5,12 +5,13 @@
from POULibrary import POULibrary
from docutil import open_svg
+from py_ext import PythonFileCTNMixin class SVGUILibrary(POULibrary):
def GetLibraryPath(self):
return os.path.join(os.path.split(__file__)[0], "pous.xml")
+class SVGUI(PythonFileCTNMixin): @@ -26,13 +27,21 @@
return os.path.join(os.path.dirname(__file__))
- # define name for IEC raw code file
- return os.path.join(self.CTNPath(), "gui.svg")
+ def _getSVGpath(self, project_path=None): + if project_path is None: + project_path = self.CTNPath() + # define name for SVG file containing gui layout + return os.path.join(project_path, "gui.svg") def _getSVGUIserverpath(self):
return os.path.join(os.path.dirname(__file__), "svgui_server.py")
+ def OnCTNSave(self, from_project_path=None): + if from_project_path is not None: + shutil.copyfile(self._getSVGpath(from_project_path), + return PythonFileCTNMixin.OnCTNSave(self, from_project_path) def CTNGenerate_C(self, buildpath, locations):
Return C code generated by iec2c compiler
--- a/wxglade_hmi/wxglade_hmi.py Wed Apr 24 10:03:47 2013 +0200
+++ b/wxglade_hmi/wxglade_hmi.py Wed Apr 24 17:27:08 2013 +0200
@@ -1,5 +1,5 @@
from xml.dom import minidom
from py_ext import PythonFileCTNMixin
@@ -16,9 +16,11 @@
return os.path.join(os.path.dirname(__file__))
- def _getWXGLADEpath(self):
- # define name for IEC raw code file
- return os.path.join(self.CTNPath(), "hmi.wxg")
+ def _getWXGLADEpath(self, project_path=None): + if project_path is None: + project_path = self.CTNPath() + # define name for wxGlade gui file + return os.path.join(project_path, "hmi.wxg") def launch_wxglade(self, options, wait=False):
from wxglade import __file__ as fileName
@@ -29,6 +31,11 @@
mode = {False:os.P_NOWAIT, True:os.P_WAIT}[wait]
os.spawnv(mode, sys.executable, ["\"%s\""%sys.executable] + [glade] + options)
+ def OnCTNSave(self, from_project_path=None): + if from_project_path is not None: + shutil.copyfile(self._getWXGLADEpath(from_project_path), + self._getWXGLADEpath()) + return PythonFileCTNMixin.OnCTNSave(self, from_project_path) def CTNGenerate_C(self, buildpath, locations):
@@ -128,3 +135,4 @@
if wx.Platform == '__WXMSW__':
wxg_filename = "\"%s\""%wxg_filename
self.launch_wxglade([wxg_filename])