Solve import order problem when POULibrary imports ConfigTreeNode because of UserAddressedException. Now UserAddressedException is declared in POULibrary.py, as a quick and dirty fix, but some independant module should be created for beremiz exceptions in general. svghmi
authorEdouard Tisserant
Tue, 26 May 2020 09:58:20 +0200
branchsvghmi
changeset 2971 f0a822ef9fa0
parent 2970 4a9b0df0602a
child 2972 1f043fdaa7fb
child 2976 99c4521bb844
Solve import order problem when POULibrary imports ConfigTreeNode because of UserAddressedException. Now UserAddressedException is declared in POULibrary.py, as a quick and dirty fix, but some independant module should be created for beremiz exceptions in general.
ConfigTreeNode.py
POULibrary.py
ProjectController.py
--- a/ConfigTreeNode.py	Thu May 21 11:29:45 2020 +0200
+++ b/ConfigTreeNode.py	Tue May 26 09:58:20 2020 +0200
@@ -46,6 +46,7 @@
 from xmlclass import GenerateParserFromXSDstring
 from PLCControler import LOCATION_CONFNODE
 from editors.ConfTreeNodeEditor import ConfTreeNodeEditor
+from POULibrary import UserAddressedException
 
 _BaseParamsParser = GenerateParserFromXSDstring("""<?xml version="1.0" encoding="ISO-8859-1" ?>
         <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
@@ -678,7 +679,3 @@
 
         raise UserAddressedException(message)
 
-# Exception type for problems that user has to take action in order to fix
-class UserAddressedException(Exception):
-    pass
-
--- a/POULibrary.py	Thu May 21 11:29:45 2020 +0200
+++ b/POULibrary.py	Tue May 26 09:58:20 2020 +0200
@@ -26,7 +26,10 @@
 from __future__ import absolute_import
 from weakref import ref
 
-from ConfigTreeNode import UserAddressedException
+# Exception type for problems that user has to take action in order to fix
+class UserAddressedException(Exception):
+    pass
+
 
 class POULibrary(object):
     def __init__(self, CTR, LibName, TypeStack):
--- a/ProjectController.py	Thu May 21 11:29:45 2020 +0200
+++ b/ProjectController.py	Tue May 26 09:58:20 2020 +0200
@@ -63,7 +63,8 @@
 import targets
 from runtime.typemapping import DebugTypesSize, UnpackDebugBuffer
 from runtime import PlcStatus
-from ConfigTreeNode import ConfigTreeNode, XSDSchemaErrorMessage, UserAddressedException
+from ConfigTreeNode import ConfigTreeNode, XSDSchemaErrorMessage
+from POULibrary import UserAddressedException
 
 base_folder = paths.AbsParentDir(__file__)