Adding validity verifications on project folders opened
authorlbessard
Thu, 02 Aug 2007 16:48:58 +0200
changeset 3 6d8728efcdec
parent 2 ef2541ff1e68
child 4 e9d061c23e83
Adding validity verifications on project folders opened
Beremiz.py
config_utils.py
--- a/Beremiz.py	Thu Jul 26 17:17:50 2007 +0200
+++ b/Beremiz.py	Thu Aug 02 16:48:58 2007 +0200
@@ -1,10 +1,10 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-#This file is part of Beremiz, a library implementing an IEC 61131-3 editor
-#based on the plcopen standard. 
+#This file is part of Beremiz, a Integrated Development Environment for
+#programming IEC 61131-3 automates supporting plcopen standard and CanFestival. 
 #
-#Copyright (C): Edouard TISSERANT and Laurent BESSARD
+#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
 #
 #See COPYING file for copyrights details.
 #
@@ -16,7 +16,7 @@
 #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
-#Lesser General Public License for more details.
+#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
@@ -440,18 +440,18 @@
             projectpath = dialog.GetPath()
             dialog.Destroy()
             try:
-                if os.path.isdir(projectpath):
+                if not os.path.isdir(projectpath):
                     raise Exception
                 self.BusManagers = {}
                 configpath = os.path.join(projectpath, ".project")
                 if not os.path.isfile(configpath):
-                    raise
+                    raise Exception
                 file = open(configpath, "r")
                 lines = [line.strip() for line in file.readlines() if line.strip() != ""]
-                if line[0] != "Beremiz":
+                if lines[0] != "Beremiz":
                     file.close()
                     raise Exception
-                for bus_id, bus_type, bus_name in [line.split(" ") for line in lines]:
+                for bus_id, bus_type, bus_name in [line.split(" ") for line in lines[1:]]:
                     id = int(bus_id, 16)
                     if bus_type == "CanFestival":
                         manager = NodeManager(os.path.join(base_folder, "CanFestival-3", "objdictgen"))
@@ -506,6 +506,7 @@
         file.close()
         configpath = os.path.join(self.CurrentProjectPath, ".project")
         file = open(configpath, "w")
+        file.write("Beremiz\n")
         busidlist = self.BusManagers.keys()
         busidlist.sort()
         for id in busidlist:
--- a/config_utils.py	Thu Jul 26 17:17:50 2007 +0200
+++ b/config_utils.py	Thu Aug 02 16:48:58 2007 +0200
@@ -1,25 +1,26 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-#This file is part of CanFestival, a library implementing CanOpen Stack. 
+#This file is part of Beremiz, a Integrated Development Environment for
+#programming IEC 61131-3 automates supporting plcopen standard and CanFestival. 
 #
-#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD
+#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 Lesser General Public
+#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
-#Lesser General Public License for more details.
+#General Public License for more details.
 #
-#You should have received a copy of the GNU Lesser General Public
+#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
+#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
 from types import *