# HG changeset patch # User Edouard Tisserant # Date 1538517932 -7200 # Node ID d8fb90a2e11fd354084e9f1928cfd26c4ca54347 # Parent 4d7cee25a4743382df4de1d71945a691af40a647 Please pylint and pep8 diff -r 4d7cee25a474 -r d8fb90a2e11f BeremizIDE.py --- a/BeremizIDE.py Tue Oct 02 15:57:26 2018 +0200 +++ b/BeremizIDE.py Wed Oct 03 00:05:32 2018 +0200 @@ -25,6 +25,7 @@ from __future__ import absolute_import +from __future__ import print_function import os import sys import tempfile diff -r 4d7cee25a474 -r d8fb90a2e11f Beremiz_service.py --- a/Beremiz_service.py Tue Oct 02 15:57:26 2018 +0200 +++ b/Beremiz_service.py Wed Oct 03 00:05:32 2018 +0200 @@ -386,6 +386,7 @@ res = (None, sys.exc_info()) return res + if enabletwisted: import warnings with warnings.catch_warnings(): @@ -438,6 +439,7 @@ # Exception hooks + def LogException(*exp): LogMessageAndException("", exp) diff -r 4d7cee25a474 -r d8fb90a2e11f bacnet/bacnet.py --- a/bacnet/bacnet.py Tue Oct 02 15:57:26 2018 +0200 +++ b/bacnet/bacnet.py Wed Oct 03 00:05:32 2018 +0200 @@ -416,7 +416,7 @@ self.ObjTables["MSO_Obj"].ChangesToSave = False self.ObjTables["MSI_Obj"].ChangesToSave = False return True - except: + except Exception: return _("Unable to save to file \"%s\"!") % filepath def LoadFromFile(self, filepath): @@ -426,7 +426,7 @@ self.ObjTablesData = pickle.load(fd) fd.close() return True - except: + except Exception: return _("Unable to load file \"%s\"!") % filepath def _ExportBacnetSlave(self): diff -r 4d7cee25a474 -r d8fb90a2e11f runtime/PLCObject.py --- a/runtime/PLCObject.py Tue Oct 02 15:57:26 2018 +0200 +++ b/runtime/PLCObject.py Wed Oct 03 00:05:32 2018 +0200 @@ -23,7 +23,7 @@ from __future__ import absolute_import -from threading import Thread, Lock, Semaphore, Event, Condition +from threading import Thread, Lock, Semaphore, Event import ctypes import os import sys @@ -60,7 +60,6 @@ sys.stdout.flush() - def RunInMain(func): def func_wrapper(*args, **kwargs): return MainWorker.call(func, *args, **kwargs) diff -r 4d7cee25a474 -r d8fb90a2e11f runtime/PyroServer.py --- a/runtime/PyroServer.py Tue Oct 02 15:57:26 2018 +0200 +++ b/runtime/PyroServer.py Wed Oct 03 00:05:32 2018 +0200 @@ -9,6 +9,8 @@ # See COPYING file for copyrights details. +from __future__ import absolute_import +from __future__ import print_function import sys import Pyro @@ -16,6 +18,7 @@ import runtime from runtime.ServicePublisher import ServicePublisher + class Server(object): def __init__(self, servicename, ip_addr, port): self.continueloop = True @@ -49,8 +52,8 @@ # 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 = Pyro.core.ObjBase() pyro_obj.delegateTo(runtime.GetPLCObjectSingleton()) self.daemon.connect(pyro_obj, "PLCObject") @@ -75,6 +78,3 @@ self.servicepublisher.UnRegisterService() self.servicepublisher = None self.daemon.shutdown(True) - - - diff -r 4d7cee25a474 -r d8fb90a2e11f runtime/WampClient.py --- a/runtime/WampClient.py Tue Oct 02 15:57:26 2018 +0200 +++ b/runtime/WampClient.py Wed Oct 03 00:05:32 2018 +0200 @@ -144,10 +144,11 @@ _transportFactory = None print(_('WAMP session left')) - def publishWithOwnID(eventID, value): + def publishWithOwnID(self, eventID, value): ID = self.config.extra["ID"] self.publish(unicode(ID+'.'+eventID), value) + class ReconnectingWampWebSocketClientFactory(WampWebSocketClientFactory, ReconnectingClientFactory): def __init__(self, config, *args, **kwargs): @@ -343,13 +344,16 @@ global _PySrv _PySrv = pysrv + def PublishEvent(eventID, value): if getWampStatus() == "Attached": - _WampSession.publish(eventID, value) + _WampSession.publish(eventID, value) + def PublishEventWithOwnID(eventID, value): if getWampStatus() == "Attached": - _WampSession.publishWithOwnID(eventID, value) + _WampSession.publishWithOwnID(eventID, value) + # WEB CONFIGURATION INTERFACE WAMP_SECRET_URL = "secret" diff -r 4d7cee25a474 -r d8fb90a2e11f runtime/Worker.py --- a/runtime/Worker.py Tue Oct 02 15:57:26 2018 +0200 +++ b/runtime/Worker.py Wed Oct 03 00:05:32 2018 +0200 @@ -12,6 +12,7 @@ import thread from threading import Lock, Condition + class job(object): """ job to be executed by a worker diff -r 4d7cee25a474 -r d8fb90a2e11f runtime/__init__.py --- a/runtime/__init__.py Tue Oct 02 15:57:26 2018 +0200 +++ b/runtime/__init__.py Wed Oct 03 00:05:32 2018 +0200 @@ -2,23 +2,25 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import +from __future__ import print_function import traceback +import sys from runtime.Worker import worker MainWorker = worker() -from runtime.PLCObject import PLCObject +from runtime.PLCObject import PLCObject # noqa # pylint: disable=wrong-import-position + _PLCObjectSingleton = None + def GetPLCObjectSingleton(): - global _PLCObjectSingleton - assert(_PLCObjectSingleton is not None) + assert _PLCObjectSingleton is not None return _PLCObjectSingleton def LogMessageAndException(msg, exp=None): - global _PLCObjectSingleton if exp is None: exp = sys.exc_info() if _PLCObjectSingleton is not None: @@ -26,6 +28,7 @@ print(msg) traceback.print_exception(*exp) -def CreatePLCObjectSingleton(*args): + +def CreatePLCObjectSingleton(*args, **kwargs): global _PLCObjectSingleton - _PLCObjectSingleton = PLCObject(*args) + _PLCObjectSingleton = PLCObject(*args, **kwargs)