# HG changeset patch # User Edouard Tisserant # Date 1539880621 -7200 # Node ID 523559fe635257acbb239b70a77f7b8438c02c34 # Parent d8fb90a2e11fd354084e9f1928cfd26c4ca54347# Parent e927c101ce6d60e4f08c06b9fbfc89e3d0fa6e96 merge diff -r e927c101ce6d -r 523559fe6352 BeremizIDE.py --- a/BeremizIDE.py Thu Oct 18 13:17:48 2018 +0200 +++ b/BeremizIDE.py Thu Oct 18 18:37:01 2018 +0200 @@ -25,6 +25,7 @@ from __future__ import absolute_import +from __future__ import print_function import os import sys import tempfile diff -r e927c101ce6d -r 523559fe6352 Beremiz_service.py --- a/Beremiz_service.py Thu Oct 18 13:17:48 2018 +0200 +++ b/Beremiz_service.py Thu Oct 18 18:37:01 2018 +0200 @@ -388,6 +388,7 @@ res = (None, sys.exc_info()) return res + if enabletwisted: import warnings with warnings.catch_warnings(): @@ -440,6 +441,7 @@ # Exception hooks + def LogException(*exp): LogMessageAndException("", exp) diff -r e927c101ce6d -r 523559fe6352 bacnet/bacnet.py --- a/bacnet/bacnet.py Thu Oct 18 13:17:48 2018 +0200 +++ b/bacnet/bacnet.py Thu Oct 18 18:37:01 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 e927c101ce6d -r 523559fe6352 runtime/PLCObject.py --- a/runtime/PLCObject.py Thu Oct 18 13:17:48 2018 +0200 +++ b/runtime/PLCObject.py Thu Oct 18 18:37:01 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 e927c101ce6d -r 523559fe6352 runtime/PyroServer.py --- a/runtime/PyroServer.py Thu Oct 18 13:17:48 2018 +0200 +++ b/runtime/PyroServer.py Thu Oct 18 18:37:01 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 @@ -47,8 +50,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") @@ -73,6 +76,3 @@ self.servicepublisher.UnRegisterService() self.servicepublisher = None self.daemon.shutdown(True) - - - diff -r e927c101ce6d -r 523559fe6352 runtime/WampClient.py --- a/runtime/WampClient.py Thu Oct 18 13:17:48 2018 +0200 +++ b/runtime/WampClient.py Thu Oct 18 18:37:01 2018 +0200 @@ -148,6 +148,7 @@ 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 e927c101ce6d -r 523559fe6352 runtime/Worker.py --- a/runtime/Worker.py Thu Oct 18 13:17:48 2018 +0200 +++ b/runtime/Worker.py Thu Oct 18 18:37:01 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 e927c101ce6d -r 523559fe6352 runtime/__init__.py --- a/runtime/__init__.py Thu Oct 18 13:17:48 2018 +0200 +++ b/runtime/__init__.py Thu Oct 18 18:37:01 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)