# HG changeset patch # User Andrey Skvortsov # Date 1552466823 -10800 # Node ID eb4a4cc41914fe89e63087b900971653eae50ecf # Parent 2747d6e72eb8a5fe59286f4918ff96a7910e7d90 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__ diff -r 2747d6e72eb8 -r eb4a4cc41914 Beremiz_service.py --- a/Beremiz_service.py Wed Mar 13 10:19:30 2019 +0300 +++ b/Beremiz_service.py Wed Mar 13 11:47:03 2019 +0300 @@ -31,7 +31,6 @@ import getopt import threading from threading import Thread, Semaphore, Lock, currentThread -import __builtin__ from builtins import str as text from past.builtins import execfile from six.moves import builtins diff -r 2747d6e72eb8 -r eb4a4cc41914 connectors/PYRO/PSK_Adapter.py --- a/connectors/PYRO/PSK_Adapter.py Wed Mar 13 10:19:30 2019 +0300 +++ b/connectors/PYRO/PSK_Adapter.py Wed Mar 13 11:47:03 2019 +0300 @@ -3,8 +3,8 @@ import socket import re +import ssl import sslpsk -import ssl import Pyro from Pyro.core import PyroURI from Pyro.protocol import _connect_socket, TCPConnection, PYROAdapter diff -r 2747d6e72eb8 -r eb4a4cc41914 connectors/PYRO/__init__.py --- a/connectors/PYRO/__init__.py Wed Mar 13 10:19:30 2019 +0300 +++ b/connectors/PYRO/__init__.py Wed Mar 13 11:47:03 2019 +0300 @@ -54,7 +54,7 @@ scheme, location = uri.split("://") if scheme == "PYROS": - import connectors.PYRO.PSK_Adapter # pylint: disable=wrong-import-order,unused-import,wrong-import-position + import connectors.PYRO.PSK_Adapter # pylint: disable=wrong-import-order,unused-import,wrong-import-position schemename = "PYROLOCPSK" url, ID = location.split('#') # TODO fix exception when # not found # load PSK from project diff -r 2747d6e72eb8 -r eb4a4cc41914 connectors/PYRO_dialog.py --- a/connectors/PYRO_dialog.py Wed Mar 13 10:19:30 2019 +0300 +++ b/connectors/PYRO_dialog.py Wed Mar 13 11:47:03 2019 +0300 @@ -6,7 +6,6 @@ from __future__ import absolute_import from itertools import repeat, islice, chain -import wx from connectors.SchemeEditor import SchemeEditor diff -r 2747d6e72eb8 -r eb4a4cc41914 connectors/SchemeEditor.py --- a/connectors/SchemeEditor.py Wed Mar 13 10:19:30 2019 +0300 +++ b/connectors/SchemeEditor.py Wed Mar 13 11:47:03 2019 +0300 @@ -26,7 +26,7 @@ self.txtctrls[tag] = txtctrl for win, flag in [ (wx.StaticText(self, label=label), - wx.ALIGN_CENTER_VERTICAL), + wx.ALIGN_CENTER_VERTICAL), (txtctrl, wx.GROW)]: self.fieldsizer.AddWindow(win, flag=flag) @@ -39,7 +39,7 @@ self, parent.ctr, # use a callafter, as editor can be deleted by calling SetURI partial(wx.CallAfter, parent.SetURI), - self.txtctrls[tag].SetValue) + self.txtctrls["ID"].SetValue) self.mainsizer.AddWindow(self.idselector) self.SetSizer(self.mainsizer) else: diff -r 2747d6e72eb8 -r eb4a4cc41914 connectors/__init__.py --- a/connectors/__init__.py Wed Mar 13 10:19:30 2019 +0300 +++ b/connectors/__init__.py Wed Mar 13 11:47:03 2019 +0300 @@ -29,7 +29,6 @@ from __future__ import absolute_import from os import listdir, path from connectors.ConnectorBase import ConnectorBase -from types import ClassType connectors_packages = ["PYRO", "WAMP"] @@ -118,8 +117,8 @@ return None # new class inheriting from generic and specific connector base classes - return ClassType(_scheme + "_connector", - (ConnectorBase, connector_specific_class), {})() + return type(_scheme + "_connector", + (ConnectorBase, connector_specific_class), {})() def EditorClassFromScheme(scheme): diff -r 2747d6e72eb8 -r eb4a4cc41914 controls/IDBrowser.py --- a/controls/IDBrowser.py Wed Mar 13 10:19:30 2019 +0300 +++ b/controls/IDBrowser.py Wed Mar 13 11:47:03 2019 +0300 @@ -98,8 +98,8 @@ args(_("Last URI"), COL_URI, width=300 if big else 80), args(_("Description"), COL_DESC, width=300 if big else 200, mode=dv.DATAVIEW_CELL_EDITABLE - if self.isManager - else dv.DATAVIEW_CELL_INERT), + if self.isManager + else dv.DATAVIEW_CELL_INERT), args(_("Last connection"), COL_LAST, width=120), ] diff -r 2747d6e72eb8 -r eb4a4cc41914 runtime/PLCObject.py --- a/runtime/PLCObject.py Wed Mar 13 10:19:30 2019 +0300 +++ b/runtime/PLCObject.py Wed Mar 13 11:47:03 2019 +0300 @@ -28,14 +28,14 @@ import os import sys import traceback +import shutil from time import time -import _ctypes # pylint: disable=wrong-import-order +import md5 +from tempfile import mkstemp +from functools import wraps, partial from six.moves import xrange from past.builtins import execfile -import md5 -from tempfile import mkstemp -import shutil -from functools import wraps, partial +import _ctypes from runtime.typemapping import TypeTranslator from runtime.loglevels import LogLevelsDefault, LogLevelsCount diff -r 2747d6e72eb8 -r eb4a4cc41914 runtime/WampClient.py --- a/runtime/WampClient.py Wed Mar 13 10:19:30 2019 +0300 +++ b/runtime/WampClient.py Wed Mar 13 11:47:03 2019 +0300 @@ -135,7 +135,7 @@ self.register(GetCallee(name), u'.'.join((ID, name)), registerOptions) for name in SubscribedEvents: - self.subscribe(GetCallee(name), unicode(name)) + self.subscribe(GetCallee(name), text(name)) for func in DoOnJoin: func(self) @@ -151,7 +151,7 @@ def publishWithOwnID(self, eventID, value): ID = self.config.extra["ID"] - self.publish(unicode(ID+'.'+eventID), value) + self.publish(text(ID+'.'+eventID), value) class ReconnectingWampWebSocketClientFactory(WampWebSocketClientFactory, ReconnectingClientFactory): @@ -343,12 +343,12 @@ def PublishEvent(eventID, value): if getWampStatus() == "Attached": - _WampSession.publish(unicode(eventID), value) + _WampSession.publish(text(eventID), value) def PublishEventWithOwnID(eventID, value): if getWampStatus() == "Attached": - _WampSession.publishWithOwnID(unicode(eventID), value) + _WampSession.publishWithOwnID(text(eventID), value) # WEB CONFIGURATION INTERFACE diff -r 2747d6e72eb8 -r eb4a4cc41914 runtime/Worker.py --- a/runtime/Worker.py Wed Mar 13 10:19:30 2019 +0300 +++ b/runtime/Worker.py Wed Mar 13 11:47:03 2019 +0300 @@ -9,9 +9,9 @@ from __future__ import absolute_import import sys -import thread from threading import Lock, Condition import six +from six.moves import _thread class job(object): @@ -65,7 +65,7 @@ """ meant to be called by worker thread (blocking) """ - self._threadID = thread.get_ident() + self._threadID = _thread.get_ident() self.mutex.acquire() if args or kwargs: _job = job(*args, **kwargs) @@ -93,7 +93,7 @@ _job = job(*args, **kwargs) - if self._threadID == thread.get_ident(): + if self._threadID == _thread.get_ident(): # if caller is worker thread execute immediately _job.do() else: diff -r 2747d6e72eb8 -r eb4a4cc41914 runtime/spawn_subprocess.py --- a/runtime/spawn_subprocess.py Wed Mar 13 10:19:30 2019 +0300 +++ b/runtime/spawn_subprocess.py Wed Mar 13 11:47:03 2019 +0300 @@ -3,6 +3,7 @@ # subset of subprocess built-in module using posix_spawn rather than fork. +from __future__ import print_function from __future__ import absolute_import import os import signal