runtime/__init__.py
author Edouard Tisserant
Thu, 21 Mar 2019 13:04:26 +0100
branchsearch_in_CTN
changeset 2525 9812b332f350
parent 2327 569d7fbc0bd4
child 2583 e172ab28d04e
permissions -rw-r--r--
WIP adding searching capabilities in python files. was done :
- change stub search results to trigger highlighting un variable panel
- trying to highlight in CTN code file editors -> problem with EditorPanel not having self.VariableEditor set...
- added highlight capability to CTN's CodeFileEditor's VariablePanel
#!/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)