author | Edouard Tisserant |
Tue, 11 Sep 2018 16:08:21 +0200 | |
changeset 2272 | 28b0a783975e |
parent 2270 | d9175daf6522 |
child 2307 | c44692b53736 |
permissions | -rw-r--r-- |
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 |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
5 |
import traceback |
1667
cefc9219bb48
runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1511
diff
changeset
|
6 |
|
2270
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
7 |
from runtime.Worker import worker |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
8 |
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
|
9 |
|
2270
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
10 |
from runtime.PLCObject import PLCObject |
1667
cefc9219bb48
runtime is licensed under LGPLv2.1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1511
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 |
|
2270
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
14 |
def GetPLCObjectSingleton(): |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
15 |
global _PLCObjectSingleton |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
16 |
assert(_PLCObjectSingleton is not None) |
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 |
global _PLCObjectSingleton |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
22 |
if exp is None: |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
23 |
exp = sys.exc_info() |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
24 |
if _PLCObjectSingleton is not None: |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
25 |
_PLCObjectSingleton.LogMessage(0, msg + '\n'.join(traceback.format_exception(*exp))) |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
26 |
else: |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
27 |
print(msg) |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
28 |
traceback.print_exception(*exp) |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
29 |
|
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
30 |
def CreatePLCObjectSingleton(*args): |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
31 |
global _PLCObjectSingleton |
d9175daf6522
Refactoring. Separated PLC Object, PYRO Server and MainWorker :
Edouard Tisserant
parents:
1984
diff
changeset
|
32 |
_PLCObjectSingleton = PLCObject(*args) |