beremiz

Conform to pep8 and pylint :

2019-04-07, Edouard Tisserant
8fb5c6eddc72
Conform to pep8 and pylint :

pep8 version: 2.3.1
./ConfigTreeNode.py:130:49: E231 missing whitespace after ','
./editors/Viewer.py:643:24: E128 continuation line under-indented for visual indent
./editors/Viewer.py:670:12: E221 multiple spaces before operator
./editors/Viewer.py:671:13: E221 multiple spaces before operator
./editors/Viewer.py:2138:52: E203 whitespace before ':'
./editors/Viewer.py:2139:66: W291 trailing whitespace
./controls/VariablePanel.py:154:25: E231 missing whitespace after ','
./controls/LocationCellEditor.py:88:1: W293 blank line contains whitespace
./controls/LocationCellEditor.py:191:25: E221 multiple spaces before operator
./controls/LocationCellEditor.py:200:17: E128 continuation line under-indented for visual indent

pylint 1.8.3,
************* Module controls.LocationCellEditor
controls/LocationCellEditor.py:200: [C0330(bad-continuation), ] Wrong continued indentation (add 9 spaces).
_("Selected location is identical to previous one"))
^ |
************* Module controls.VariablePanel
controls/VariablePanel.py:154: [E1601(print-statement), VariableTable.SetValue] print statement used
************* Module editors.Viewer
editors/Viewer.py:643: [C0330(bad-continuation), ] Wrong continued indentation (add 1 space).
self.GetAddMenuCallBack(self.AddNewComment))
^|
editors/Viewer.py:598: [W0612(unused-variable), Viewer.AddDivergenceMenuItems] Unused variable 'add_branch'
editors/Viewer.py:1655: [E0602(undefined-variable), Viewer.PopupConnectionMenu] Undefined variable 'variable_type'
editors/Viewer.py:1649: [W0612(unused-variable), Viewer.PopupConnectionMenu] Unused variable 'connection_type'
************* Module connectors.PYRO.PSK_Adapter
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of Beremiz runtime.
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
# Copyright (C) 2017: Andrey Skvortsov
# Copyright (C) 2018: Edouard TISSERANT
# See COPYING file for copyrights details.
from __future__ import absolute_import
from __future__ import print_function
import sys
import Pyro
import Pyro.core as pyro
import runtime
from runtime.ServicePublisher import ServicePublisher
class PyroServer(object):
def __init__(self, servicename, ip_addr, port):
self.continueloop = True
self.daemon = None
self.servicename = servicename
self.ip_addr = ip_addr
self.port = port
self.servicepublisher = None
def _to_be_published(self):
return self.servicename is not None and \
self.ip_addr not in ["", "localhost", "127.0.0.1"]
def PrintServerInfo(self):
print(_("Pyro port :"), self.port)
if self._to_be_published():
print(_("Publishing service on local network"))
sys.stdout.flush()
def PyroLoop(self, when_ready):
if self._to_be_published():
self.Publish()
while self.continueloop:
Pyro.config.PYRO_MULTITHREADED = 0
pyro.initServer()
self.daemon = pyro.Daemon(host=self.ip_addr, port=self.port)
# pyro never frees memory after connection close if no timeout set
# taking too small timeout value may cause
# unwanted diconnection when IDE is kept busy for long periods
self.daemon.setTimeout(60)
pyro_obj = Pyro.core.ObjBase()
pyro_obj.delegateTo(runtime.GetPLCObjectSingleton())
self.daemon.connect(pyro_obj, "PLCObject")
when_ready()
self.daemon.requestLoop()
self.daemon.sock.close()
self.Unpublish()
def Restart(self):
self.daemon.shutdown(True)
def Quit(self):
self.continueloop = False
self.daemon.shutdown(True)
def Publish(self):
self.servicepublisher = ServicePublisher("PYRO")
self.servicepublisher.RegisterService(self.servicename,
self.ip_addr, self.port)
def Unpublish(self):
if self.servicepublisher is not None:
self.servicepublisher.UnRegisterService()
self.servicepublisher = None