beremiz

Fix various pylint and pep8 errors

2019-03-13, Andrey Skvortsov
eb4a4cc41914
Fix various pylint and pep8 errors

Check basic code-style problems for PEP-8
pep8 version: 2.4.0
./connectors/PYRO/__init__.py:57:43: E261 at least two spaces before inline comment
./connectors/SchemeEditor.py:29:21: E128 continuation line under-indented for visual indent
./controls/IDBrowser.py:101:23: E127 continuation line over-indented for visual indent
./controls/IDBrowser.py:102:23: E127 continuation line over-indented for visual indent

Check for problems using pylint ...
No config file found, using default configuration
pylint 1.9.4,
astroid 1.6.5
Python 2.7.16rc1 (default, Feb 18 2019, 11:05:09)
[GCC 8.2.0]
Use multiple threads for pylint
Using config file /home/developer/WorkData/PLC/beremiz/beremiz/.pylint
************* Module connectors.PYRO_dialog
connectors/PYRO_dialog.py:9: [W0611(unused-import), ] Unused import wx
************* Module connectors
connectors/__init__.py:32: [W1652(deprecated-types-field), ] Accessing a deprecated fields on the types module
connectors/__init__.py:32: [C0411(wrong-import-order), ] standard import "from types import ClassType" should be placed before "from connectors.ConnectorBase import ConnectorBase"
************* Module connectors.PYRO.PSK_Adapter
connectors/PYRO/PSK_Adapter.py:7: [C0411(wrong-import-order), ] standard import "import ssl" should be placed before "import sslpsk"
************* Module connectors.SchemeEditor
connectors/SchemeEditor.py:29: [C0330(bad-continuation), ] Wrong continued indentation (add 1 space).
wx.ALIGN_CENTER_VERTICAL),
^|
connectors/SchemeEditor.py:42: [W0631(undefined-loop-variable), SchemeEditor.__init__] Using possibly undefined loop variable 'tag'
************* Module runtime.WampClient
runtime/WampClient.py:138: [W1612(unicode-builtin), WampSession.onJoin] unicode built-in referenced
runtime/WampClient.py:154: [W1612(unicode-builtin), WampSession.publishWithOwnID] unicode built-in referenced
runtime/WampClient.py:346: [W1612(unicode-builtin), PublishEvent] unicode built-in referenced
runtime/WampClient.py:351: [W1612(unicode-builtin), PublishEventWithOwnID] unicode built-in referenced
runtime/WampClient.py:31: [W0611(unused-import), ] Unused str imported from builtins as text
************* Module runtime.PLCObject
runtime/PLCObject.py:35: [W1648(bad-python3-import), ] Module moved in Python 3
runtime/PLCObject.py:35: [C0411(wrong-import-order), ] standard import "import md5" should be placed before "from six.moves import xrange"
runtime/PLCObject.py:36: [C0411(wrong-import-order), ] standard import "from tempfile import mkstemp" should be placed before "from six.moves import xrange"
runtime/PLCObject.py:37: [C0411(wrong-import-order), ] standard import "import shutil" should be placed before "from six.moves import xrange"
runtime/PLCObject.py:38: [C0411(wrong-import-order), ] standard import "from functools import wraps, partial" should be placed before "from six.moves import xrange"
************* Module runtime.Worker
runtime/Worker.py:12: [W1648(bad-python3-import), ] Module moved in Python 3
************* Module runtime.spawn_subprocess
runtime/spawn_subprocess.py:125: [C0325(superfluous-parens), ] Unnecessary parens after 'print' keyword
runtime/spawn_subprocess.py:130: [C0325(superfluous-parens), ] Unnecessary parens after 'print' keyword
runtime/spawn_subprocess.py:125: [E1601(print-statement), ] print statement used
runtime/spawn_subprocess.py:130: [E1601(print-statement), ] print statement used
************* Module controls.IDBrowser
controls/IDBrowser.py:101: [C0330(bad-continuation), ] Wrong continued indentation (remove 5 spaces).
if self.isManager
| ^
controls/IDBrowser.py:102: [C0330(bad-continuation), ] Wrong continued indentation (remove 5 spaces).
else dv.DATAVIEW_CELL_INERT),
| ^
************* Module Beremiz_service
Beremiz_service.py:34: [W0611(unused-import), ] Unused import __builtin__
<?xml version='1.0' encoding='utf-8'?>
<project xmlns:ns1="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.plcopen.org/xml/tc6_0201">
<fileHeader companyName="Beremiz" productName="Beremiz" productVersion="1" creationDateTime="2018-07-27T13:19:12"/>
<contentHeader name="Modbus" modificationDateTime="2018-07-27T15:43:56">
<coordinateInfo>
<fbd>
<scaling x="0" y="0"/>
</fbd>
<ld>
<scaling x="0" y="0"/>
</ld>
<sfc>
<scaling x="0" y="0"/>
</sfc>
</coordinateInfo>
</contentHeader>
<types>
<dataTypes/>
<pous>
<pou name="program0" pouType="program">
<interface>
<localVars>
<variable name="Counter">
<type>
<INT/>
</type>
</variable>
<variable name="CounterReadBack">
<type>
<INT/>
</type>
</variable>
</localVars>
<localVars>
<variable name="MasterWriteToReg0" address="%QW0.0.0.0">
<type>
<INT/>
</type>
</variable>
<variable name="MasterReadFromReg1" address="%IW0.0.1.0">
<type>
<INT/>
</type>
</variable>
<variable name="SlaveHoldReg0" address="%IW0.1.0.0">
<type>
<WORD/>
</type>
</variable>
<variable name="SlaveInputReg0" address="%QW0.1.1.0">
<type>
<WORD/>
</type>
</variable>
</localVars>
<localVars>
<variable name="CTU0">
<type>
<derived name="CTU"/>
</type>
</variable>
<variable name="Generator0">
<type>
<derived name="Generator"/>
</type>
</variable>
</localVars>
</interface>
<body>
<FBD>
<comment localId="4" height="109" width="350">
<position x="102" y="438"/>
<content>
<xhtml:p><![CDATA[Modbus TCP Master writes counter value to one holding register on Modbus TCP Slave and reads it back from other input register.]]></xhtml:p>
</content>
</comment>
<comment localId="3" height="407" width="680">
<position x="21" y="15"/>
<content>
<xhtml:p><![CDATA[This examples shows how to work with Modbus extension. It uses Modbus TCP, but the same functions are available for Modbus RTU as well. Buth protocols are supported.
Modbus extensions requires native Modbus RTU/TCP library to be installed nearby Beremiz.
Following directory structure is expected:
<Parent directory>
"beremiz"
"Modbus"
If Modbus library is installed elsewhere, then place corresponding paths
in CFLAGS/LDFLAGS in project settings.
For GNU/Linux to install Modbus library in parent directory run following commands:
$ hg clone https://bitbucket.org/mjsousa/modbus Modbus
$ cd Modbus
$ make
After that Modbus extension is ready to be used in Beremiz projects.]]></xhtml:p>
</content>
</comment>
<block localId="5" typeName="CTU" instanceName="CTU0" executionOrderId="0" height="80" width="52">
<position x="346" y="605"/>
<inputVariables>
<variable formalParameter="CU" edge="rising">
<connectionPointIn>
<relPosition x="0" y="30"/>
<connection refLocalId="6" formalParameter="OUT">
<position x="346" y="635"/>
<position x="303" y="635"/>
</connection>
</connectionPointIn>
</variable>
<variable formalParameter="R">
<connectionPointIn>
<relPosition x="0" y="50"/>
</connectionPointIn>
</variable>
<variable formalParameter="PV">
<connectionPointIn>
<relPosition x="0" y="70"/>
<connection refLocalId="7">
<position x="346" y="675"/>
<position x="324" y="675"/>
<position x="324" y="703"/>
<position x="302" y="703"/>
</connection>
</connectionPointIn>
</variable>
</inputVariables>
<inOutVariables/>
<outputVariables>
<variable formalParameter="Q">
<connectionPointOut>
<relPosition x="52" y="30"/>
</connectionPointOut>
</variable>
<variable formalParameter="CV">
<connectionPointOut>
<relPosition x="52" y="50"/>
</connectionPointOut>
</variable>
</outputVariables>
</block>
<block localId="6" typeName="Generator" instanceName="Generator0" executionOrderId="0" height="60" width="79">
<position x="224" y="605"/>
<inputVariables>
<variable formalParameter="PON">
<connectionPointIn>
<relPosition x="0" y="30"/>
<connection refLocalId="1">
<position x="224" y="635"/>
<position x="154" y="635"/>
</connection>
</connectionPointIn>
</variable>
<variable formalParameter="POFF">
<connectionPointIn>
<relPosition x="0" y="50"/>
<connection refLocalId="1">
<position x="224" y="655"/>
<position x="189" y="655"/>
<position x="189" y="635"/>
<position x="154" y="635"/>
</connection>
</connectionPointIn>
</variable>
</inputVariables>
<inOutVariables/>
<outputVariables>
<variable formalParameter="OUT">
<connectionPointOut>
<relPosition x="79" y="30"/>
</connectionPointOut>
</variable>
</outputVariables>
</block>
<inVariable localId="1" executionOrderId="0" height="30" width="138" negated="false">
<position x="16" y="620"/>
<connectionPointOut>
<relPosition x="138" y="15"/>
</connectionPointOut>
<expression>T#1s</expression>
</inVariable>
<inVariable localId="7" executionOrderId="0" height="30" width="138" negated="false">
<position x="164" y="688"/>
<connectionPointOut>
<relPosition x="138" y="15"/>
</connectionPointOut>
<expression>32767</expression>
</inVariable>
<inOutVariable localId="2" executionOrderId="0" height="30" width="138" negatedOut="false" negatedIn="false">
<position x="544" y="640"/>
<connectionPointIn>
<relPosition x="0" y="15"/>
<connection refLocalId="5" formalParameter="CV">
<position x="544" y="655"/>
<position x="398" y="655"/>
</connection>
</connectionPointIn>
<connectionPointOut>
<relPosition x="138" y="15"/>
</connectionPointOut>
<expression>Counter</expression>
</inOutVariable>
<outVariable localId="8" executionOrderId="0" height="30" width="138" negated="false">
<position x="762" y="640"/>
<connectionPointIn>
<relPosition x="0" y="15"/>
<connection refLocalId="2">
<position x="762" y="655"/>
<position x="682" y="655"/>
</connection>
</connectionPointIn>
<expression>MasterWriteToReg0</expression>
</outVariable>
<inVariable localId="9" executionOrderId="0" height="30" width="152" negated="false">
<position x="81" y="747"/>
<connectionPointOut>
<relPosition x="152" y="15"/>
</connectionPointOut>
<expression>MasterReadFromReg1</expression>
</inVariable>
<outVariable localId="10" executionOrderId="0" height="30" width="137" negated="false">
<position x="547" y="747"/>
<connectionPointIn>
<relPosition x="0" y="15"/>
<connection refLocalId="9">
<position x="547" y="762"/>
<position x="233" y="762"/>
</connection>
</connectionPointIn>
<expression>CounterReadBack</expression>
</outVariable>
<comment localId="11" height="109" width="350">
<position x="85" y="825"/>
<content>
<xhtml:p><![CDATA[Modbus TCP Slave just copies received register value from holding register to input register.]]></xhtml:p>
</content>
</comment>
<inVariable localId="12" executionOrderId="0" height="30" width="152" negated="false">
<position x="82" y="970"/>
<connectionPointOut>
<relPosition x="152" y="15"/>
</connectionPointOut>
<expression>SlaveHoldReg0</expression>
</inVariable>
<outVariable localId="13" executionOrderId="0" height="30" width="123" negated="false">
<position x="548" y="970"/>
<connectionPointIn>
<relPosition x="0" y="15"/>
<connection refLocalId="12">
<position x="548" y="985"/>
<position x="234" y="985"/>
</connection>
</connectionPointIn>
<expression>SlaveInputReg0</expression>
</outVariable>
</FBD>
</body>
</pou>
<pou name="Generator" pouType="functionBlock">
<interface>
<outputVars>
<variable name="OUT">
<type>
<BOOL/>
</type>
</variable>
</outputVars>
<inputVars>
<variable name="PON">
<type>
<TIME/>
</type>
</variable>
<variable name="POFF">
<type>
<TIME/>
</type>
</variable>
</inputVars>
<localVars>
<variable name="T1">
<type>
<derived name="TON"/>
</type>
</variable>
<variable name="T2">
<type>
<derived name="TOF"/>
</type>
</variable>
</localVars>
</interface>
<body>
<ST>
<xhtml:p><![CDATA[T1( IN := NOT T2.Q, PT := POFF);
T2( IN := T1.Q, PT := PON);
OUT := T2.Q;]]></xhtml:p>
</ST>
</body>
</pou>
</pous>
</types>
<instances>
<configurations>
<configuration name="config">
<resource name="resource1">
<task name="task0" priority="0" interval="T#20ms">
<pouInstance name="instance0" typeName="program0"/>
</task>
</resource>
</configuration>
</configurations>
</instances>
</project>