fix error if non-latin character was entered in initial value in
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 28 Apr 2016 15:21:02 +0300
changeset 1508 4c645e6b8c98
parent 1507 d7f474d10210
child 1509 7aaf850d8d1c
fix error if non-latin character was entered in initial value in
data type element

Traceback (most recent call last):
File "/home/beremiz/editors/DataTypeEditor.py", line 575, in OnStructureElementsGridCellChange
value = self.StructureElementsTable.GetValue(row, col)
File "/home/beremiz/editors/DataTypeEditor.py", line 80, in GetValue
return str(value)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
Traceback (most recent call last):
File "/home/beremiz/editors/DataTypeEditor.py", line 80, in GetValue
return str(value)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
Traceback (most recent call last):
File "/home/beremiz/editors/DataTypeEditor.py", line 80, in GetValue
return str(value)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
PLCControler.py
editors/DataTypeEditor.py
--- a/PLCControler.py	Thu Apr 28 13:05:57 2016 +0300
+++ b/PLCControler.py	Thu Apr 28 15:21:02 2016 +0300
@@ -1972,7 +1972,7 @@
                         else:
                             element_infos["Type"] = element_type_type.upper()
                         if element.initialValue is not None:
-                            element_infos["Initial Value"] = str(element.initialValue.getvalue())
+                            element_infos["Initial Value"] = element.initialValue.getvalue()
                         else:
                             element_infos["Initial Value"] = ""
                         infos["elements"].append(element_infos)
@@ -1983,7 +1983,7 @@
                         else basetype_content_type.upper())
 
                 if datatype.initialValue is not None:
-                    infos["initial"] = str(datatype.initialValue.getvalue())
+                    infos["initial"] = datatype.initialValue.getvalue()
                 else:
                     infos["initial"] = ""
                 return infos
--- a/editors/DataTypeEditor.py	Thu Apr 28 13:05:57 2016 +0300
+++ b/editors/DataTypeEditor.py	Thu Apr 28 15:21:02 2016 +0300
@@ -74,10 +74,11 @@
                 return row + 1
             colname = self.GetColLabelValue(col, False)
             value = self.data[row].get(colname, "")
+               
             if colname == "Type" and isinstance(value, TupleType):
                 if value[0] == "array":
                     return "ARRAY [%s] OF %s" % (",".join(map(lambda x : "..".join(x), value[2])), value[1])
-            return str(value)
+            return value
 
     def SetValue(self, row, col, value):
         if col < len(self.colnames):