--- a/canfestival/canfestival.py Wed Jan 31 15:25:30 2018 +0100
+++ b/canfestival/canfestival.py Thu Feb 01 14:51:18 2018 +0100
@@ -28,8 +28,8 @@
-from gnosis.xml.pickle import *
-from gnosis.xml.pickle.util import setParanoia
+from gnosis.xml.pickle import * # pylint: disable=import-error +from gnosis.xml.pickle.util import setParanoia # pylint: disable=import-error import util.paths as paths
from util.TranslationCatalogs import AddCatalog
@@ -50,7 +50,7 @@
from nodemanager import NodeManager
-import canfestival_config as local_canfestival_config
+import canfestival_config as local_canfestival_config # pylint: disable=import-error from commondialogs import CreateNodeDialog
from subindextable import IECTypeConversion, SizeConversion
@@ -463,7 +463,9 @@
file = open(os.path.join(buildpath, "MasterGenerated.od"), "w")
+ # linter disabled here, undefined variable happens + # here because gnosis isn't impored while linting + dump(master, file) # pylint: disable=undefined-variable return [(Gen_OD_path, local_canfestival_config.getCFLAGS(CanFestivalPath))], "", False
--- a/modbus/mb_utils.py Wed Jan 31 15:25:30 2018 +0100
+++ b/modbus/mb_utils.py Thu Feb 01 14:51:18 2018 +0100
@@ -70,8 +70,7 @@
node_dict = {"locnodestr": location,
return node_init_template % node_dict
@@ -128,8 +127,7 @@
"parity": modbus_serial_parity_dict[parity],
return node_init_template % node_dict
@@ -149,8 +147,7 @@
"parity": modbus_serial_parity_dict[parity],
- "coms_period": coms_period
+ "coms_period": coms_period} return node_init_template % node_dict
@@ -168,8 +165,7 @@
node_dict = {"locnodestr": location,
- "coms_period": coms_period
+ "coms_period": coms_period} return node_init_template % node_dict
--- a/modbus/modbus.py Wed Jan 31 15:25:30 2018 +0100
+++ b/modbus/modbus.py Thu Feb 01 14:51:18 2018 +0100
@@ -23,13 +23,12 @@
# used in safety-critical situations without a full and competent review.
+from __future__ import absolute_import
+from modbus.mb_utils import *
from ConfigTreeNode import ConfigTreeNode
-from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
+from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_MEMORY base_folder = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
base_folder = os.path.join(base_folder, "..")
@@ -45,7 +44,7 @@
+class _RequestPlug(object): XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ModbusRequest">
@@ -110,7 +109,7 @@
datasize = modbus_function_dict[function][4]
# 'Q' for coils and holding registers, 'I' for input discretes and input registers
- datazone = modbus_function_dict[function][5]
+ # datazone = modbus_function_dict[function][5] # 'X' for bits, 'W' for words
datatacc = modbus_function_dict[function][6]
# 'Coil', 'Holding Register', 'Input Discrete' or 'Input Register'
@@ -166,7 +165,7 @@
+class _MemoryAreaPlug(object): XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="MemoryArea">
@@ -215,7 +214,7 @@
datasize = modbus_memtype_dict[function][4]
# 'Q' for coils and holding registers, 'I' for input discretes and input registers
- datazone = modbus_memtype_dict[function][5]
+ # datazone = modbus_memtype_dict[function][5] # 'X' for bits, 'W' for words
datatacc = modbus_memtype_dict[function][6]
# 'Coil', 'Holding Register', 'Input Discrete' or 'Input Register'
@@ -260,7 +259,7 @@
-class _ModbusTCPclientPlug:
+class _ModbusTCPclientPlug(object): XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ModbusTCPclient">
@@ -314,7 +313,7 @@
-class _ModbusTCPserverPlug:
+class _ModbusTCPserverPlug(object): # NOTE: the Port number is a 'string' and not an 'integer'!
# This is because the underlying modbus library accepts strings
# (e.g.: well known port names!)
@@ -376,7 +375,7 @@
-class _ModbusRTUclientPlug:
+class _ModbusRTUclientPlug(object): XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ModbusRTUclient">
@@ -446,7 +445,7 @@
-class _ModbusRTUslavePlug:
+class _ModbusRTUslavePlug(object): XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ModbusRTUslave">
@@ -516,7 +515,7 @@
+class RootClass(object): XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ModbusRoot">
@@ -533,8 +532,10 @@
- CTNChildrenTypes = [("ModbusTCPclient", _ModbusTCPclientPlug, "Modbus TCP Client"), ("ModbusTCPserver", _ModbusTCPserverPlug, "Modbus TCP Server"), ("ModbusRTUclient", _ModbusRTUclientPlug, "Modbus RTU Client"), ("ModbusRTUslave", _ModbusRTUslavePlug, "Modbus RTU Slave")
+ CTNChildrenTypes = [("ModbusTCPclient", _ModbusTCPclientPlug, "Modbus TCP Client"), + ("ModbusTCPserver", _ModbusTCPserverPlug, "Modbus TCP Server"), + ("ModbusRTUclient", _ModbusRTUclientPlug, "Modbus RTU Client"), + ("ModbusRTUslave", _ModbusRTUslavePlug, "Modbus RTU Slave")] # Return the number of (modbus library) nodes this specific instance of the modbus plugin will need
# return type: (tcp nodes, rtu nodes, ascii nodes)
@@ -567,8 +568,7 @@
# print type(self.CTNType)
- loc_dict = {"locstr": "_".join(map(str, self.GetCurrentLocation())),
+ loc_dict = {"locstr": "_".join(map(str, self.GetCurrentLocation()))} # Determine the number of (modbus library) nodes ALL instances of the modbus plugin will need
# total_node_count: (tcp nodes, rtu nodes, ascii nodes)
@@ -663,10 +663,10 @@
for iecvar in subchild.GetLocations():
absloute_address = iecvar["LOC"][3]
- start_address = int(GetCTVal(child, 2))
+ start_address = int(GetCTVal(subchild, 2)) relative_addr = absloute_address - start_address
# test if relative address in request specified range
- if relative_addr in xrange(int(GetCTVal(child, 1))):
+ if relative_addr in xrange(int(GetCTVal(subchild, 1))): if str(iecvar["NAME"]) not in loc_vars_list:
loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &server_nodes[%d].mem_area.%s[%d];" % (
server_id, memarea, absloute_address))
@@ -693,10 +693,10 @@
for iecvar in subchild.GetLocations():
absloute_address = iecvar["LOC"][3]
- start_address = int(GetCTVal(child, 2))
+ start_address = int(GetCTVal(subchild, 2)) relative_addr = absloute_address - start_address
# test if relative address in request specified range
- if relative_addr in xrange(int(GetCTVal(child, 1))):
+ if relative_addr in xrange(int(GetCTVal(subchild, 1))): if str(iecvar["NAME"]) not in loc_vars_list:
loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &server_nodes[%d].mem_area.%s[%d];" % (
server_id, memarea, absloute_address))
@@ -717,9 +717,9 @@
client_request_list.append(new_req)
for iecvar in subchild.GetLocations():
# absloute address - start address
- relative_addr = iecvar["LOC"][3] - int(GetCTVal(child, 3))
+ relative_addr = iecvar["LOC"][3] - int(GetCTVal(subchild, 3)) # test if relative address in request specified range
- if relative_addr in xrange(int(GetCTVal(child, 2))):
+ if relative_addr in xrange(int(GetCTVal(subchild, 2))): if str(iecvar["NAME"]) not in loc_vars_list:
"u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].plcv_buffer[%d];" % (client_requestid, relative_addr))
@@ -742,9 +742,9 @@
client_request_list.append(new_req)
for iecvar in subchild.GetLocations():
# absloute address - start address
- relative_addr = iecvar["LOC"][3] - int(GetCTVal(child, 3))
+ relative_addr = iecvar["LOC"][3] - int(GetCTVal(subchild, 3)) # test if relative address in request specified range
- if relative_addr in xrange(int(GetCTVal(child, 2))):
+ if relative_addr in xrange(int(GetCTVal(subchild, 2))): if str(iecvar["NAME"]) not in loc_vars_list:
"u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].plcv_buffer[%d];" % (client_requestid, relative_addr))
--- a/runtime/NevowServer.py Wed Jan 31 15:25:30 2018 +0100
+++ b/runtime/NevowServer.py Thu Feb 01 14:51:18 2018 +0100
@@ -26,10 +26,10 @@
from __future__ import absolute_import
from __future__ import print_function
-import util.paths as paths
from nevow import appserver, inevow, tags, loaders, athena
from nevow.page import renderer
from twisted.internet import reactor
+import util.paths as paths xhtml_header = '''<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
--- a/util/ProcessLogger.py Wed Jan 31 15:25:30 2018 +0100
+++ b/util/ProcessLogger.py Thu Feb 01 14:51:18 2018 +0100
@@ -29,9 +29,7 @@
from threading import Timer, Lock, Thread, Semaphore
- from signal import SIGTERM, SIGKILL
class outputThread(Thread):
@@ -126,11 +124,11 @@
"stderr": subprocess.PIPE
- if no_gui and wx.Platform == '__WXMSW__':
+ if no_gui and os.name in ("nt", "ce"): self.startupinfo = subprocess.STARTUPINFO()
self.startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
popenargs["startupinfo"] = self.startupinfo
- elif wx.Platform == '__WXGTK__':
+ elif os.name == 'posix': popenargs["shell"] = False
@@ -200,16 +198,16 @@
- if wx.Platform == '__WXMSW__':
+ if os.name in ("nt", "ce"): handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, False, self.Proc.pid)
ctypes.windll.kernel32.TerminateProcess(handle, -1)
ctypes.windll.kernel32.CloseHandle(handle)
os.kill(self.Proc.pid, sig)