# HG changeset patch # User Edouard Tisserant # Date 1515681680 -3600 # Node ID e8cf68d69447840e7c90865fbbccd3cacf53f858 # Parent 9d1547578f559cde56e0211d129a633f8b678bcf Enforced check_source.sh pep8 and pylint rules. diff -r 9d1547578f55 -r e8cf68d69447 Beremiz_service.py --- a/Beremiz_service.py Thu Jan 11 15:39:58 2018 +0100 +++ b/Beremiz_service.py Thu Jan 11 15:41:20 2018 +0100 @@ -418,8 +418,8 @@ while self.continueloop: pyro.initServer() self.daemon = pyro.Daemon(host=self.ip_addr, port=self.port) - # pyro never frees memory after connection close if no timeout set - self.daemon.setTimeout(1); + # pyro never frees memory after connection close if no timeout set + self.daemon.setTimeout(1) self.Start() self.daemon.requestLoop() self.daemon.sock.close() @@ -467,7 +467,6 @@ sys.stdout.flush() - def _stop(self): if self.plcobj is not None: self.plcobj.StopPLC() @@ -578,7 +577,7 @@ if wampconf is None: _wampconf = os.path.join(WorkingDir, "wampconf.json") - if os.path.exists(_wampconf) : + if os.path.exists(_wampconf): wampconf = _wampconf if wampconf is not None: @@ -605,9 +604,9 @@ if wampconf is not None: try: - _wampconf = WC.LoadWampClientConf(wampconf) # if project WAMP config is added - if _wampconf : - if _wampconf["url"]: #TODO : test more ? + _wampconf = WC.LoadWampClientConf(wampconf) + if _wampconf: + if _wampconf["url"]: # TODO : test more ? WC.RegisterWampClient(wampconf, wampsecret) pyruntimevars["wampsession"] = WC.GetSession WC.SetServer(pyroserver) diff -r 9d1547578f55 -r e8cf68d69447 py_ext/PythonFileCTNMixin.py --- a/py_ext/PythonFileCTNMixin.py Thu Jan 11 15:39:58 2018 +0100 +++ b/py_ext/PythonFileCTNMixin.py Thu Jan 11 15:41:20 2018 +0100 @@ -119,7 +119,7 @@ "configname": configname.upper(), "uppername": variable.getname().upper(), "IECtype": variable.gettype(), - "initial" : repr(variable.getinitial()), + "initial": repr(variable.getinitial()), "pyextname": pyextname }, self.CodeFile.variables.variable) diff -r 9d1547578f55 -r e8cf68d69447 runtime/WampClient.py --- a/runtime/WampClient.py Thu Jan 11 15:39:58 2018 +0100 +++ b/runtime/WampClient.py Thu Jan 11 15:41:20 2018 +0100 @@ -24,15 +24,12 @@ from __future__ import absolute_import from __future__ import print_function -import json import time -import os import json from autobahn.twisted import wamp from autobahn.twisted.websocket import WampWebSocketClientFactory, connectWS from autobahn.wamp import types, auth from autobahn.wamp.serializer import MsgPackSerializer -from autobahn.wamp.exception import ApplicationError from twisted.internet.defer import inlineCallbacks from twisted.internet.protocol import ReconnectingClientFactory @@ -55,12 +52,12 @@ ] # Those two lists are meant to be filled by customized runtime -# or User python code. +# or User python code. -""" crossbar Events to register to """ +""" crossbar Events to register to """ SubscribedEvents = [] -""" things to do on join (callables) """ +""" things to do on join (callables) """ DoOnJoin = [] @@ -75,7 +72,7 @@ class WampSession(wamp.ApplicationSession): def onConnect(self): - if self.config.extra.has_key("secret"): + if "secret" in self.config.extra: user = self.config.extra["ID"].encode('utf8') self.join(u"Automation", [u"wampcra"], user) else: @@ -93,10 +90,10 @@ def onJoin(self, details): global _WampSession _WampSession = self - ID = self.config.extra["ID"] # this is unicode + ID = self.config.extra["ID"] print('WAMP session joined by :', ID) for name in ExposedCalls: - regoption = types.RegisterOptions(u'exact',u'last',None, None) + regoption = types.RegisterOptions(u'exact', u'last', None, None) yield self.register(GetCallee(name), u'.'.join((ID, name)), regoption) for name in SubscribedEvents: @@ -113,11 +110,11 @@ class ReconnectingWampWebSocketClientFactory(WampWebSocketClientFactory, ReconnectingClientFactory): def clientConnectionFailed(self, connector, reason): - print _("WAMP Client connection failed (%s) .. retrying .." %time.ctime()) + print(_("WAMP Client connection failed (%s) .. retrying .." % time.ctime())) ReconnectingClientFactory.clientConnectionFailed(self, connector, reason) def clientConnectionLost(self, connector, reason): - print _("WAMP Client connection lost (%s) .. retrying .." %time.ctime()) + print(_("WAMP Client connection lost (%s) .. retrying .." % time.ctime())) ReconnectingClientFactory.clientConnectionFailed(self, connector, reason) @@ -131,6 +128,7 @@ except Exception: return None + def LoadWampSecret(secretfname): try: WSClientWampSecret = open(secretfname, 'rb').read() @@ -158,7 +156,7 @@ # create a WAMP application session factory component_config = types.ComponentConfig( realm=WSClientConf["realm"], - extra=WSClientConf) # pass a dict containing unicode values + extra=WSClientConf) session_factory = wamp.ApplicationSessionFactory( config=component_config) session_factory.session = WampSession