runtime/__init__.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 13 Mar 2019 14:11:13 +0300
changeset 2540 fca79ca84272
parent 2327 569d7fbc0bd4
child 2583 e172ab28d04e
permissions -rw-r--r--
Replace md5 module with hashlib

fix following pylint error:

************* Module connectors.ConnectorBase
connectors/ConnectorBase.py:7: [W1648(bad-python3-import), ] Module moved in Python 3
************* Module runtime.PLCObject
runtime/PLCObject.py:33: [W1648(bad-python3-import), ] Module moved in Python 3
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import
from __future__ import print_function
import traceback
import sys

from runtime.Worker import worker
MainWorker = worker()

_PLCObjectSingleton = None


def GetPLCObjectSingleton():
    assert _PLCObjectSingleton is not None
    return _PLCObjectSingleton


def LogMessageAndException(msg, exp=None):
    if exp is None:
        exp = sys.exc_info()
    if _PLCObjectSingleton is not None:
        _PLCObjectSingleton.LogMessage(0, msg + '\n'.join(traceback.format_exception(*exp)))
    print(msg)
    traceback.print_exception(*exp)


def CreatePLCObjectSingleton(*args, **kwargs):
    global _PLCObjectSingleton
    from runtime.PLCObject import PLCObject  # noqa # pylint: disable=wrong-import-position
    _PLCObjectSingleton = PLCObject(*args, **kwargs)