--- a/PLCOpenEditor.py Tue Jul 17 21:20:09 2012 +0200
+++ b/PLCOpenEditor.py Tue Jul 17 21:23:21 2012 +0200
@@ -262,6 +262,19 @@
# Helper Functions
#-------------------------------------------------------------------------------
+import base64
+
+def EncodeFileSystemPath(path, use_base64=True):
+ path = path.encode(sys.getfilesystemencoding())
+ if use_base64:
+ return base64.encodestring(path)
+ return path
+
+def DecodeFileSystemPath(path, is_base64=True):
+ if is_base64:
+ path = base64.decodestring(path)
+ return unicode(path, sys.getfilesystemencoding())
+
# Compatibility function for wx versions < 2.6
def AppendMenu(parent, help, id, kind, text):
if wx.VERSION >= (2, 6, 0):
@@ -783,21 +796,23 @@
projects = {}
try:
if self.Config.HasEntry("projects"):
- projects = cPickle.loads(str(self.Config.Read("projects")))
+ projects = cPickle.loads(self.Config.Read("projects"))
except:
pass
- return projects.get(os.path.realpath(self.Controler.GetFilePath()), {})
+ return projects.get(
+ EncodeFileSystemPath(os.path.realpath(self.Controler.GetFilePath())), {})
def SavePageState(self, page):
state = page.GetState()
if state is not None:
if self.Config.HasEntry("projects"):
- projects = cPickle.loads(str(self.Config.Read("projects")))
+ projects = cPickle.loads(self.Config.Read("projects"))
else:
projects = {}
- project_infos = projects.setdefault(os.path.realpath(self.Controler.GetFilePath()), {})
+ project_infos = projects.setdefault(
+ EncodeFileSystemPath(os.path.realpath(self.Controler.GetFilePath())), {})
editors_state = project_infos.setdefault("editors_state", {})
if page.IsDebugging():
@@ -981,11 +996,12 @@
projects = {}
try:
if self.Config.HasEntry("projects"):
- projects = cPickle.loads(str(self.Config.Read("projects")))
+ projects = cPickle.loads(self.Config.Read("projects"))
except:
pass
- project_infos = projects.setdefault(os.path.realpath(self.Controler.GetFilePath()), {})
+ project_infos = projects.setdefault(
+ EncodeFileSystemPath(os.path.realpath(self.Controler.GetFilePath())), {})
project_infos["tabs"] = self.SaveTabLayout(self.TabsOpened)
if self.EnableDebug:
project_infos["debug_vars"] = self.DebugVariablePanel.GetDebugVariables()
@@ -2667,16 +2683,18 @@
result = None
# Open the filepath if defined
- if fileOpen is not None and os.path.isfile(fileOpen):
- # Create a new controller
- controler = PLCControler()
- result = controler.OpenXMLFile(fileOpen)
- if result is None:
- self.Controler = controler
- self.LibraryPanel.SetController(controler)
- self.ProjectTree.Enable(True)
- self.PouInstanceVariablesPanel.SetController(controler)
- self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
+ if fileOpen is not None:
+ fileOpen = DecodeFileSystemPath(fileOpen, False)
+ if os.path.isfile(fileOpen):
+ # Create a new controller
+ controler = PLCControler()
+ result = controler.OpenXMLFile(fileOpen)
+ if result is None:
+ self.Controler = controler
+ self.LibraryPanel.SetController(controler)
+ self.ProjectTree.Enable(True)
+ self.PouInstanceVariablesPanel.SetController(controler)
+ self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
# Define PLCOpenEditor icon
self.SetIcon(wx.Icon(os.path.join(CWD, "Images", "poe.ico"),wx.BITMAP_TYPE_ICO))