runtime/__init__.py
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sun, 07 Apr 2019 21:08:07 +0200
changeset 2579 8fb5c6eddc72
parent 2327 569d7fbc0bd4
child 2583 e172ab28d04e
permissions -rw-r--r--
Conform to pep8 and pylint :

pep8 version: 2.3.1
./ConfigTreeNode.py:130:49: E231 missing whitespace after ','
./editors/Viewer.py:643:24: E128 continuation line under-indented for visual indent
./editors/Viewer.py:670:12: E221 multiple spaces before operator
./editors/Viewer.py:671:13: E221 multiple spaces before operator
./editors/Viewer.py:2138:52: E203 whitespace before ':'
./editors/Viewer.py:2139:66: W291 trailing whitespace
./controls/VariablePanel.py:154:25: E231 missing whitespace after ','
./controls/LocationCellEditor.py:88:1: W293 blank line contains whitespace
./controls/LocationCellEditor.py:191:25: E221 multiple spaces before operator
./controls/LocationCellEditor.py:200:17: E128 continuation line under-indented for visual indent

pylint 1.8.3,
************* Module controls.LocationCellEditor
controls/LocationCellEditor.py:200: [C0330(bad-continuation), ] Wrong continued indentation (add 9 spaces).
_("Selected location is identical to previous one"))
^ |
************* Module controls.VariablePanel
controls/VariablePanel.py:154: [E1601(print-statement), VariableTable.SetValue] print statement used
************* Module editors.Viewer
editors/Viewer.py:643: [C0330(bad-continuation), ] Wrong continued indentation (add 1 space).
self.GetAddMenuCallBack(self.AddNewComment))
^|
editors/Viewer.py:598: [W0612(unused-variable), Viewer.AddDivergenceMenuItems] Unused variable 'add_branch'
editors/Viewer.py:1655: [E0602(undefined-variable), Viewer.PopupConnectionMenu] Undefined variable 'variable_type'
editors/Viewer.py:1649: [W0612(unused-variable), Viewer.PopupConnectionMenu] Unused variable 'connection_type'
************* Module connectors.PYRO.PSK_Adapter
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 344
diff changeset
     1
#!/usr/bin/env python
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 344
diff changeset
     2
# -*- coding: utf-8 -*-
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 344
diff changeset
     3
2270
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
     4
from __future__ import absolute_import
2309
d8fb90a2e11f Please pylint and pep8
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2307
diff changeset
     5
from __future__ import print_function
2270
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
     6
import traceback
2309
d8fb90a2e11f Please pylint and pep8
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2307
diff changeset
     7
import sys
1667
cefc9219bb48 runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
     8
2270
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
     9
from runtime.Worker import worker
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    10
MainWorker = worker()
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 344
diff changeset
    11
2270
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    12
_PLCObjectSingleton = None
49
45dc6a944ab6 On the long wat towards generated code comilation...
etisserant
parents:
diff changeset
    13
2309
d8fb90a2e11f Please pylint and pep8
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2307
diff changeset
    14
2270
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    15
def GetPLCObjectSingleton():
2309
d8fb90a2e11f Please pylint and pep8
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2307
diff changeset
    16
    assert _PLCObjectSingleton is not None
2270
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    17
    return _PLCObjectSingleton
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    18
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    19
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    20
def LogMessageAndException(msg, exp=None):
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    21
    if exp is None:
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    22
        exp = sys.exc_info()
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    23
    if _PLCObjectSingleton is not None:
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    24
        _PLCObjectSingleton.LogMessage(0, msg + '\n'.join(traceback.format_exception(*exp)))
2307
c44692b53736 Show more exceptions on stdout, particularly those that are raised by AutoLoad (first item in Main Thread worker)
Edouard Tisserant
parents: 2270
diff changeset
    25
    print(msg)
c44692b53736 Show more exceptions on stdout, particularly those that are raised by AutoLoad (first item in Main Thread worker)
Edouard Tisserant
parents: 2270
diff changeset
    26
    traceback.print_exception(*exp)
2270
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    27
2309
d8fb90a2e11f Please pylint and pep8
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2307
diff changeset
    28
d8fb90a2e11f Please pylint and pep8
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2307
diff changeset
    29
def CreatePLCObjectSingleton(*args, **kwargs):
2270
d9175daf6522 Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents: 1984
diff changeset
    30
    global _PLCObjectSingleton
2327
569d7fbc0bd4 Prevent PLCObject to be imported from IDE as a side effect of importing runtime package
Edouard Tisserant
parents: 2309
diff changeset
    31
    from runtime.PLCObject import PLCObject  # noqa # pylint: disable=wrong-import-position
2309
d8fb90a2e11f Please pylint and pep8
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2307
diff changeset
    32
    _PLCObjectSingleton = PLCObject(*args, **kwargs)