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'?>
<PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml">
<variables>
<variable name="Power_ON" type="BOOL"/>
<variable name="Power_OFF" type="BOOL"/>
<variable name="DrawTest" type="BOOL"/>
<variable name="DrawLogo" type="BOOL"/>
<variable name="DrawEscher" type="BOOL"/>
<variable name="Detect_Circle" type="BOOL"/>
<variable name="XaxisPos" type="INT"/>
<variable name="YaxisPos" type="INT"/>
<variable name="ZaxisPos" type="INT"/>
<variable name="TaxisPos" type="INT"/>
<variable name="XaxisMinus" type="BOOL"/>
<variable name="YaxisMinus" type="BOOL"/>
<variable name="ZaxisMinus" type="BOOL"/>
<variable name="TaxisMinus" type="BOOL"/>
<variable name="XaxisPlus" type="BOOL"/>
<variable name="YaxisPlus" type="BOOL"/>
<variable name="ZaxisPlus" type="BOOL"/>
<variable name="TaxisPlus" type="BOOL"/>
<variable name="DrawTestBtn" type="BOOL"/>
<variable name="DrawTestBtn2" type="BOOL"/>
</variables>
<globals>
<xhtml:p><![CDATA[
import ctypes
import wx, sys
AxisList = ["X","Y","Z","T"]
PwrButtons = ['Power_ON',
'Power_OFF']
ActionButtons = ['Detect_Circle',
'DrawTest',
'DrawLogo',
'DrawEscher']
class ThreeDee(wx.StaticText):
def __init__(self, *args, **kwargs):
self.initialized = False
kwargs["style"] = wx.ALIGN_CENTRE_HORIZONTAL
super(ThreeDee, self).__init__(*args, **kwargs)
self.SetFont(wx.Font(24, wx.SWISS, wx.NORMAL, wx.BOLD))
self.positions = [0.]*4
self.Message = None
self.NegLimits = None
self.Disk = None
def UpdatePositions(self, positions):
# get globals from PLC
self.positions = positions
self.SetLabel(
((self.Message +'\n\n') if self.Message else '' )+
" ".join(["%s %+.2f"%(axis,self.positions[i])
for i,axis in enumerate(AxisList)]))
def MakeButtonFunc(window, sizer, btname):
def ButtonDown(event):
setattr(PLCGlobals,btname,1)
event.Skip()
def ButtonUp(event):
setattr(PLCGlobals,btname,0)
event.Skip()
obj = wx.BitmapButton(window, -1, wx.Bitmap('%s.png'%btname))
sizer.Add(obj, 2, wx.EXPAND, 0)
obj.Bind(wx.EVT_LEFT_DOWN, ButtonDown)
obj.Bind(wx.EVT_LEFT_UP, ButtonUp)
return obj
def UpdPos(self):
positions = [getattr(PLCGlobals,axname+"axisPos") for axname in AxisList]
self.window_1.UpdatePositions(positions)
Class_wxglade_hmi.UpdPos = UpdPos
#def UpdatePositions(self, event):
#
# positions = [getattr(PLCGlobals,axname+"axisPos") for axname in AxisList]
#
# self.window_1.UpdatePositions(positions)
#
# event.Skip()
#Class_wxglade_hmi.UpdatePositions = UpdatePositions
def CleanSizer(sizer):
sizer_len = sizer.GetItemCount()
if sizer_len > 0:
for i in reversed(range(sizer_len)):
sizer.Remove(i)
initorig = Class_wxglade_hmi.__init__
def Init(self,*args,**kargs):
initorig(self,*args,**kargs)
sizer = self.GetSizer().GetItem(1).GetSizer().GetItem(0).GetSizer()
CleanSizer(sizer)
self.main_buttons = map(
lambda btname: MakeButtonFunc(self, sizer, btname), PwrButtons)
sizer = self.GetSizer().GetItem(1).GetSizer().GetItem(1).GetSizer()
CleanSizer(sizer)
self.main_buttons = map(
lambda btname: MakeButtonFunc(self, sizer, btname), ActionButtons)
self.axis_buttons = map(
lambda axis:( MakeButtonFunc(self, sizer, axis+"axisMinus"),
MakeButtonFunc(self, sizer, axis+"axisPlus")),
AxisList)
# self.timer = wx.Timer(self, -1)
# self.Bind(wx.EVT_TIMER, self.UpdatePositions, self.timer)
# self.ShowFullScreen(True,wx.FULLSCREEN_ALL)
# wx.CallAfter(self.timer.Start,200)
Class_wxglade_hmi.__init__ = Init
def SetPLCTestBtnGlobalVar(self, evt):
setattr(PLCGlobals, "DrawTestBtn", evt.GetEventObject().GetValue())
def SetPLCTestBtn2GlobalVar(self, evt):
setattr(PLCGlobals, "DrawTestBtn2", evt.GetEventObject().GetValue())
]]></xhtml:p>
</globals>
<init>
<xhtml:p><![CDATA[
]]></xhtml:p>
</init>
<cleanup>
<xhtml:p><![CDATA[
]]></xhtml:p>
</cleanup>
<start>
<xhtml:p><![CDATA[
]]></xhtml:p>
</start>
<stop>
<xhtml:p><![CDATA[
]]></xhtml:p>
</stop>
</PyFile>