--- a/objdictgen/nodelist.py Mon Sep 10 08:04:32 2007 +0200
+++ b/objdictgen/nodelist.py Mon Sep 10 14:32:07 2007 +0200
@@ -23,7 +23,7 @@
from node import *
import eds_utils
-import os, shutil
+import os, shutil, types
#-------------------------------------------------------------------------------
# Definition of NodeList Object
@@ -102,11 +102,13 @@
result = self.LoadEDS(file)
if result != None:
return result
-
+
+ print "Load Master"
result = self.LoadMasterNode(netname)
if result != None:
return result
+ print "Load Slaves"
result = self.LoadSlaveNodes(netname)
if result != None:
return result
@@ -163,9 +165,12 @@
else:
masterpath = os.path.join(self.Root, "master.od")
if os.path.isfile(masterpath):
- return self.Manager.OpenFileInCurrent(masterpath)
- else:
- return self.Manager.CreateNewNode("MasterNode", 0x00, "master", "", "None", "", "heartbeat", ["DS302"])
+ result = self.Manager.OpenFileInCurrent(masterpath)
+ else:
+ result = self.Manager.CreateNewNode("MasterNode", 0x00, "master", "", "None", "", "heartbeat", ["DS302"])
+ if not isinstance(result, types.IntType):
+ return result
+ return None
def SaveMasterNode(self, netname = None):
if netname:
--- a/objdictgen/nodemanager.py Mon Sep 10 08:04:32 2007 +0200
+++ b/objdictgen/nodemanager.py Mon Sep 10 14:32:07 2007 +0200
@@ -247,7 +247,7 @@
node.SetSpecificMenu(AddMenuEntries)
return None
except:
- return "Syntax Error\nBad OD Profile file!."
+ return "Syntax Error\nBad OD Profile file!"
else:
# Default profile
node.SetProfileName("None")
@@ -259,15 +259,18 @@
Open a file and store it in a new buffer
"""
def OpenFileInCurrent(self, filepath):
- # Open and load file
- file = open(filepath, "r")
- node = load(file)
- file.close()
- self.CurrentNode = node
- # Add a new buffer and defining current state
- index = self.AddNodeBuffer(self.CurrentNode.Copy(), True)
- self.SetCurrentFilePath(filepath)
- return index
+ try:
+ # Open and load file
+ file = open(filepath, "r")
+ node = load(file)
+ file.close()
+ self.CurrentNode = node
+ # Add a new buffer and defining current state
+ index = self.AddNodeBuffer(self.CurrentNode.Copy(), True)
+ self.SetCurrentFilePath(filepath)
+ return index
+ except:
+ return "Unable to load file \"%s\"!"%filepath
"""
Save current node in a file