# HG changeset patch # User Edouard Tisserant # Date 1517493078 -3600 # Node ID ccea0fa6ea91fea472570a06936d0db03ac62bd6 # Parent e7b6478b4ebcf077d2d905a93df103620ec0d584 Another set of meaningless changes to satisfy PEP8 and PyLint. diff -r e7b6478b4ebc -r ccea0fa6ea91 Beremiz_service.py --- a/Beremiz_service.py Wed Jan 31 15:25:30 2018 +0100 +++ b/Beremiz_service.py Thu Feb 01 14:51:18 2018 +0100 @@ -173,6 +173,8 @@ # __builtin__.__dict__['_'] = wx.GetTranslation +# Life is hard... have a candy. +# pylint: disable=wrong-import-position,wrong-import-order if enablewx: try: import wx @@ -549,7 +551,7 @@ def LogException(*exp): - LogExceptionAndMessage("", exp) + LogMessageAndException("", exp) sys.excepthook = LogException diff -r e7b6478b4ebc -r ccea0fa6ea91 canfestival/canfestival.py --- 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 @@ import sys import shutil import wx -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 gen_cfile import eds_utils -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 @@ raise Exception(res) file = open(os.path.join(buildpath, "MasterGenerated.od"), "w") - dump(master, file) + # linter disabled here, undefined variable happens + # here because gnosis isn't impored while linting + dump(master, file) # pylint: disable=undefined-variable file.close() return [(Gen_OD_path, local_canfestival_config.getCFLAGS(CanFestivalPath))], "", False diff -r e7b6478b4ebc -r ccea0fa6ea91 canfestival/config_utils.py --- a/canfestival/config_utils.py Wed Jan 31 15:25:30 2018 +0100 +++ b/canfestival/config_utils.py Thu Feb 01 14:51:18 2018 +0100 @@ -697,7 +697,7 @@ return pointers -if __name__ == "__main__": +if __name__ == "__main__": # pylint: disable=all def usage(): print(""" Usage of config_utils.py test : diff -r e7b6478b4ebc -r ccea0fa6ea91 connectors/PYRO/__init__.py --- a/connectors/PYRO/__init__.py Wed Jan 31 15:25:30 2018 +0100 +++ b/connectors/PYRO/__init__.py Thu Feb 01 14:51:18 2018 +0100 @@ -76,7 +76,7 @@ def _settimeout(self, timeout): self.timeout = timeout - from M2Crypto.SSL import Connection + from M2Crypto.SSL import Connection # pylint: disable=import-error Connection.timeout = None Connection.gettimeout = _gettimeout Connection.settimeout = _settimeout diff -r e7b6478b4ebc -r ccea0fa6ea91 controls/DebugVariablePanel/DebugVariableGraphicViewer.py --- a/controls/DebugVariablePanel/DebugVariableGraphicViewer.py Wed Jan 31 15:25:30 2018 +0100 +++ b/controls/DebugVariablePanel/DebugVariableGraphicViewer.py Thu Feb 01 14:51:18 2018 +0100 @@ -26,7 +26,7 @@ from __future__ import absolute_import from types import TupleType from time import time as gettime -from distutils.version import LooseVersion +from cycler import cycler import numpy import wx @@ -42,10 +42,6 @@ from controls.DebugVariablePanel.GraphButton import GraphButton -if LooseVersion(matplotlib.__version__) >= LooseVersion("1.5.0"): - from cycler import cycler - - # Graph variable display type GRAPH_PARALLEL, GRAPH_ORTHOGONAL = range(2) @@ -983,10 +979,7 @@ return AddText def SetAxesColor(self, color): - if LooseVersion(matplotlib.__version__) >= LooseVersion("1.5.0"): - self.Axes.set_prop_cycle(cycler('color', color)) - else: - self.Axes.set_color_cycle(color) + self.Axes.set_prop_cycle(cycler('color', color)) def ResetGraphics(self): """ diff -r e7b6478b4ebc -r ccea0fa6ea91 i18n/mki18n.py --- a/i18n/mki18n.py Wed Jan 31 15:25:30 2018 +0100 +++ b/i18n/mki18n.py Thu Feb 01 14:51:18 2018 +0100 @@ -439,7 +439,8 @@ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # if __name__ == "__main__": - import getopt # command line parsing + # command line parsing + import getopt # pylint: disable=wrong-import-order,wrong-import-position argc = len(sys.argv) if argc == 1: printUsage('Missing argument: specify at least one of -m or -p (or both).') diff -r e7b6478b4ebc -r ccea0fa6ea91 modbus/__init__.py --- a/modbus/__init__.py Wed Jan 31 15:25:30 2018 +0100 +++ b/modbus/__init__.py Thu Feb 01 14:51:18 2018 +0100 @@ -21,6 +21,3 @@ # # This code is made available on the understanding that it will not be # used in safety-critical situations without a full and competent review. - - -from modbus import * diff -r e7b6478b4ebc -r ccea0fa6ea91 modbus/mb_utils.py --- 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, "host": host, "port": port, - "slaveid": slaveid, - } + "slaveid": slaveid} return node_init_template % node_dict @@ -128,8 +127,7 @@ "baud": baud, "parity": modbus_serial_parity_dict[parity], "stopbits": stopbits, - "slaveid": slaveid - } + "slaveid": slaveid} return node_init_template % node_dict @@ -149,8 +147,7 @@ "baud": baud, "parity": modbus_serial_parity_dict[parity], "stopbits": stopbits, - "coms_period": coms_period - } + "coms_period": coms_period} return node_init_template % node_dict @@ -168,8 +165,7 @@ node_dict = {"locnodestr": location, "host": host, "port": port, - "coms_period": coms_period - } + "coms_period": coms_period} return node_init_template % node_dict diff -r e7b6478b4ebc -r ccea0fa6ea91 modbus/modbus.py --- 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 import os -import sys -from mb_utils import * - -import wx +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: +class _RequestPlug(object): XSD = """ @@ -110,7 +109,7 @@ # 1 or 16 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: +class _MemoryAreaPlug(object): XSD = """ @@ -215,7 +214,7 @@ # 1 or 16 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 = """ @@ -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 = """ @@ -446,7 +445,7 @@ # -class _ModbusRTUslavePlug: +class _ModbusRTUslavePlug(object): XSD = """ @@ -516,7 +515,7 @@ # # # -class RootClass: +class RootClass(object): XSD = """ @@ -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) # print "#############" - 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(): # print repr(iecvar) 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(): # print repr(iecvar) 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: loc_vars.append( "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: loc_vars.append( "u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].plcv_buffer[%d];" % (client_requestid, relative_addr)) diff -r e7b6478b4ebc -r ccea0fa6ea91 runtime/NevowServer.py --- 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 os -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 = '''