gui.py 19.6 KB
Newer Older
1
2
3
4
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
    TASTE ASN.1 Value Editor
Maxime Perrotin's avatar
Maxime Perrotin committed
5

6
7
    Tool main entry point (when used standalone)

Maxime Perrotin's avatar
Maxime Perrotin committed
8
    Copyright (c) 2012-2018 European Space Agency
9
10
11
12
13
14
15

    Designed and implemented by Maxime Perrotin

    Contact: maxime.perrotin@esa.int

    License is LGPLv3 - Check the LICENSE file
"""
Maxime Perrotin's avatar
Maxime Perrotin committed
16
17
18
19
20

__url__ = "http://taste.tuxfamily.org"


import os
21
import traceback
Maxime Perrotin's avatar
Maxime Perrotin committed
22
23
24
25
26
import signal
import sys
import platform
import re
import logging
27
import argparse
Maxime Perrotin's avatar
Maxime Perrotin committed
28
import time
29
from functools import partial
Maxime Perrotin's avatar
Maxime Perrotin committed
30
from ctypes import CDLL, create_string_buffer
Maxime Perrotin's avatar
Maxime Perrotin committed
31

Maxime Perrotin's avatar
Maxime Perrotin committed
32
logging.basicConfig()
Maxime Perrotin's avatar
Maxime Perrotin committed
33
34
35
36
37
38
39
40
41
42
43
log = logging.getLogger(__name__)
terminal_formatter = logging.Formatter(
        fmt="%(levelname)s - %(name)s: %(message)s")
handler_console = logging.StreamHandler()
handler_console.setLevel(logging.DEBUG)
handler_console.setFormatter(terminal_formatter)
log.addHandler(handler_console)


from ColorFormatter import ColorFormatter

Maxime Perrotin's avatar
Maxime Perrotin committed
44
from asn1_value_editor import asn1Editor, asn1Viewer, __version__
Maxime Perrotin's avatar
Maxime Perrotin committed
45
from plotmanager import PlotManager
46
import vn
Maxime Perrotin's avatar
Maxime Perrotin committed
47

48
49
import UserWidgets

Maxime Perrotin's avatar
Maxime Perrotin committed
50
51
52
53
54
try:
    import speedometer
except ImportError:
    log.error('You must install speedometer first')

55
56
57
58
59
60
61
62
63
# Make sure the gui can import modules in the current directory
sys.path.insert(0, '.')

try:
    import datamodel
except ImportError:
    datamodel = None

try:
Maxime Perrotin's avatar
Maxime Perrotin committed
64
    from PythonController import(OpenMsgQueueForReading,
65
66
67
68
69
                GetMsgQueueBufferSize, DV, RetrieveMessageFromQueue)
    python_controller = True
except ImportError:
    python_controller = False

Maxime Perrotin's avatar
Maxime Perrotin committed
70
71
72
import resources

from mscHandler import mscHandler
73
from sdlHandler import sdlHandler
Maxime Perrotin's avatar
Maxime Perrotin committed
74

75
from PySide.QtCore import QThread, QFile, Qt, Signal, QObject
Maxime Perrotin's avatar
Maxime Perrotin committed
76
from PySide.QtGui import(QApplication, QStatusBar, QLabel, QWidget,
77
        QListWidget, QPushButton, QDockWidget, QTabWidget, QMenu, QAction)
Maxime Perrotin's avatar
Maxime Perrotin committed
78
79
80
81

from PySide.QtUiTools import QUiLoader

g_tmPool = {}
Maxime Perrotin's avatar
Maxime Perrotin committed
82
False
Maxime Perrotin's avatar
Maxime Perrotin committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

class MsgQ_Poller(QThread):
    '''
        Thread for polling the GUI queue in order to receive
        the messages from the main binary
    '''
    tm = Signal()

    def __init__(self, log, parent=None):
        self.log = log
        QThread.__init__(self, parent)
        self.Qname = "{uid}_{fvname}_PI_queue".format(uid=str(os.geteuid()),
                                                    fvname=datamodel.FVname)
        self.log.info('msQ name= ' + self.Qname)

    def run(self):
        self.log.debug('Starting msgQ polling thread')
        self._bDie = False
        while True:
            if self._bDie:
                return
            self._msgQueue = OpenMsgQueueForReading(self.Qname)
            if (self._msgQueue != -1):
                break
            self.log.warning(
                    "Communication channel over {Qname} not established yet. "
                    "Retrying...".format(Qname=self.Qname))
            time.sleep(1)
        bufferSize = GetMsgQueueBufferSize(self._msgQueue)
Maxime Perrotin's avatar
Maxime Perrotin committed
112
        pDataFromMQ = create_string_buffer(bufferSize).raw
Maxime Perrotin's avatar
Maxime Perrotin committed
113
114
115
116
117
118
119
        while not self._bDie:
            messageReceivedType = RetrieveMessageFromQueue(
                                       self._msgQueue, bufferSize, pDataFromMQ)
            if messageReceivedType == -1:
                time.sleep(0.005)
                continue
            self.log.debug('MsgQ poller: received message')
120
121
122
            while (g_tmPool[messageReceivedType].pendingTM):
                # Wait until possible previous message has been consumed
                time.sleep(0.005)
123
124
125
            # Copy the message into the ASN.1 type instance of the editor
            g_tmPool[messageReceivedType].asn1Instance.SetData(pDataFromMQ)
            g_tmPool[messageReceivedType].pendingTM = True
Maxime Perrotin's avatar
Maxime Perrotin committed
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
            # use a signal to inform the TM editor of the received TM
            self.tm.emit()


class MyLogger:
    ''' Hook for catching the calls to "print" from imported modules '''
    def __init__(self, log):
        self.log = log
        self.string = ""

    def write(self, string):
        if string.endswith('\n'):
            self.log.info(self.string)
            self.string = ""
        else:
            self.string += string


def gui():
    ''' Application entry point '''
    # Exit app on Ctrl-C
    signal.signal(signal.SIGINT, signal.SIG_DFL)
148
    if 'opengeode-simulator' in sys.argv[0]:
Maxime Perrotin's avatar
Maxime Perrotin committed
149
        logo = ':/opengeode.png'
150
        msclist_enable = False
151
        sys.argv.append('-l')
Maxime Perrotin's avatar
Maxime Perrotin committed
152
153
    else:
        logo = ':/tasteLogo_white.png'
154
        msclist_enable = True
Maxime Perrotin's avatar
Maxime Perrotin committed
155

156
    #usage = 'usage: gui.py [--udp=IP_Address:in_Port:out_Port]'
Maxime Perrotin's avatar
Maxime Perrotin committed
157
    version = 'Version ' + __version__
Maxime Perrotin's avatar
Maxime Perrotin committed
158
159
160
161

    # Set up the logging facilities
    log = logging.getLogger("gui")
    console = logging.StreamHandler(sys.__stdout__)
Maxime Perrotin's avatar
Maxime Perrotin committed
162
    console.setFormatter(ColorFormatter())
Maxime Perrotin's avatar
Maxime Perrotin committed
163
164
165
166
167
    log.addHandler(console)
    log.info('Starting GUI')
    myPrint = MyLogger(log)

    # Parse the command line
168
169
    parser = argparse.ArgumentParser(version=version)
    parser.add_argument('-g', '--verbose', action='store_true', default=False,
Maxime Perrotin's avatar
Maxime Perrotin committed
170
                      help='Display debug information')
171
    parser.add_argument('--udp', dest='udp', metavar='RemoteIP:inPort:outPort',
Maxime Perrotin's avatar
Maxime Perrotin committed
172
                      help='Use UDP sockets instead of message queues')
173
174
175
176
    parser.add_argument('-l', '--shared_lib', action='store_true',
                      default=False, help='Simulate SDL system, '
                      'using a shared library')
    parser.add_argument('-r', '--reset', action='store_true', default=False,
Maxime Perrotin's avatar
Maxime Perrotin committed
177
                      help='Do not try to restore windows layout')
178
179
180
    parser.add_argument('-p', '--properties', dest='properties',
                      help='Specify a file containing stop conditions')
    parser.add_argument('-i', '--ivpath', dest='ivpath',
Maxime Perrotin's avatar
Maxime Perrotin committed
181
182
                      default='./InterfaceView.aadl',
                      help='Path and filename of the system interface view')
183
    options = parser.parse_args()
Maxime Perrotin's avatar
Maxime Perrotin committed
184
185
186
187
188
    if options.verbose:
        log.setLevel(logging.DEBUG)
    else:
        log.setLevel(logging.INFO)

Maxime Perrotin's avatar
Maxime Perrotin committed
189
190
    sys.stdout = myPrint

Maxime Perrotin's avatar
Maxime Perrotin committed
191
192
193
194
195
196
197
198
199
    log.debug('{version} using Python {pyVersion}'.format(
                        version=version, pyVersion=platform.python_version()))
    log.debug('Using interface view (for MSC processing): ' + options.ivpath)
    if options.udp is not None and not re.match("\d+.\d+.\d+.\d+:\d+:\d+",
                                                options.udp):
        log.error('Wrong UDP format. Run with --help for the proper syntax')
        log.error('You entered ' + options.udp)
        sys.exit(-1)

200
    if not datamodel:
201
202
203
        log.error('Could not import project data')
        return -1

Maxime Perrotin's avatar
Maxime Perrotin committed
204
205
    msgQ = True
    udp = None
206
    dll = None
Maxime Perrotin's avatar
Maxime Perrotin committed
207
    hasTM = False
208
    if not options.udp and not options.shared_lib:
209
        # Default: use message queue
210
211
        log.info('Using message queues to communicate')
        if not python_controller:
Maxime Perrotin's avatar
Maxime Perrotin committed
212
            log.error('Python module "PythonController": import error')
Maxime Perrotin's avatar
Maxime Perrotin committed
213
            return -1
214
    elif options.udp:
Maxime Perrotin's avatar
Maxime Perrotin committed
215
216
217
218
219
220
221
222
223
224
225
226
        msgQ = False
        udpConfig = options.udp.split(':')
        log.debug('UDP with IP={cfg[0]} inPort={cfg[1]} outPort={cfg[2]}'
                   .format(cfg=udpConfig))
        try:
            from udpcontroller import tasteUDP
            udp = tasteUDP(log=log, ip_out=udpConfig[0],
                           inport=int(udpConfig[1]), outport=int(udpConfig[2]))
            log.info('Using UDP to communicate')
        except ImportError:
            log.error('Python module "udpcontroller" is missing')
            return -1
Maxime Perrotin's avatar
Maxime Perrotin committed
227
    elif options.shared_lib:
228
        # Load and run the startup transition of the shared library (Ada only?)
Maxime Perrotin's avatar
Maxime Perrotin committed
229
        msgQ = False
230
        try:
231
232
            dll = CDLL('./lib{}.so'.format(datamodel.FVname.lower()))
            dll_init = getattr(dll, 'lib{}init'.format(datamodel.FVname.lower()))
233
            dll_init()
Maxime Perrotin's avatar
Maxime Perrotin committed
234
235
        except OSError as err:
            log.error('Issue with shared library lib{}.so:'
236
                      .format(datamodel.FVname))
Maxime Perrotin's avatar
Maxime Perrotin committed
237
            log.error(str(err))
238
            return -1
Maxime Perrotin's avatar
Maxime Perrotin committed
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269

    # Define a Qt application (mandatory)
    app = QApplication(sys.argv)

    # All available styles are listed with: QStyleFactory.keys()
    app.setStyle("cleanlooks")

    # Load the GUI description file (.ui file editable with Qt Designer)
    # Pyside and PyQt have a different way of doing...
    from TasteMainWindow import TasteMainWindow
    loader = QUiLoader()
    loader.registerCustomWidget(asn1Editor)
    loader.registerCustomWidget(asn1Viewer)
    loader.registerCustomWidget(TasteMainWindow)
    uiFile = QFile("guilayout.ui")
    uiFile.open(QFile.ReadOnly)
    myWidget = loader.load(uiFile)
    uiFile.close()

    log.info('GUI generated for function ' + datamodel.FVname)
    myWidget.FVname = datamodel.FVname

    # Create an instance of the Plot/Meter manager
    plotter = PlotManager(parent=myWidget, log=log)

    # find QStatusBar widget
    statusbar = myWidget.findChildren(QStatusBar)[0]
    statusbar.showMessage('Welcome to TASTE')

    # find TASTE logo and get width of the picture
    tasteLogo = myWidget.findChild(QLabel, 'tasteLogo')
Maxime Perrotin's avatar
Maxime Perrotin committed
270
    tasteLogo.setPixmap(logo)
Maxime Perrotin's avatar
Maxime Perrotin committed
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
    logoWidth = tasteLogo.pixmap().width()

    # find Central widget and set maximum size to width of the logo
    centralWidget = myWidget.findChild(QWidget, 'centralWidget')
    centralWidget.setMaximumWidth(logoWidth)

    # To Put ASSERT background image
    #assertPix=QPalette()
    #assertPix.setBrush(myWidget.backgroundRole(),
    #                   QBrush(QImage("assert_bkg.jpg")))
    #myWidget.setPalette(assertPix)

    # find list to place MSC scenarii and corresponding buttons
    mscList = myWidget.findChild(QListWidget, 'msc')
    runMSC = myWidget.findChild(QPushButton, 'runMSC')
    loadMSC = myWidget.findChild(QPushButton, 'loadMSC')
    editMSC = myWidget.findChild(QPushButton, 'editMSC')
288
289
290
291
292
    # In SDL simulation mode, MSC record/replay is not supported yet
    mscList.setEnabled(msclist_enable)
    runMSC.setEnabled(msclist_enable)
    loadMSC.setEnabled(msclist_enable)
    editMSC.setEnabled(msclist_enable)
Maxime Perrotin's avatar
Maxime Perrotin committed
293
294
295
296
297
298
299

    # Create an instance of the class handling MSC/Python scripts
    msgs = []
    for msg in datamodel.tc:
        msgs.append({'name': msg, 'type': datamodel.tc[msg]['nodeTypename']})
    for msg in datamodel.tm:
        msgs.append({'name': msg, 'type': datamodel.tm[msg]['nodeTypename']})
300
301
302
303
304
305
306
307
308
309
310

    # set the names of the MSC instances, depending on the context
    if dll:
        instance1 = datamodel.FVname
        instance2 = 'Operator'
    else:
        instance1 = 'TASTE_System'
        instance2 = datamodel.FVname

    msc = mscHandler(myWidget, mscList, instance2, msgs, udpController=udp,
                     instance_name=instance1)
Maxime Perrotin's avatar
Maxime Perrotin committed
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
    msc.log = log
    msc.ivpath = options.ivpath
    runMSC.pressed.connect(msc.run)
    loadMSC.pressed.connect(msc.load)
    editMSC.pressed.connect(msc.edit)
    myWidget.mscStop.connect(msc.stopMscRecording)

    # Create toolbar with a button to start/stop MSC recording and streamind
    toolbar = myWidget.addToolBar('toolbar')
    toolbar.setObjectName('toolbar')
    mscButton = toolbar.addAction('MSC')
    mscButton.triggered.connect(msc.startStop)
    myWidget.mscTrigger.connect(msc.startStop)

    # find dockable widgets (containing TM and TC editors)
    docks = myWidget.findChildren(QDockWidget)
    firstTC = None
    firstTM = None
    # Arrange them in a nice way: group the TM and TC in tabs
    myWidget.setTabPosition(Qt.RightDockWidgetArea, QTabWidget.North)
    for dock in docks:
        if dock.objectName().startswith('tm'):
            if firstTM is None:
                firstTM = dock
            else:
                myWidget.tabifyDockWidget(firstTM, dock)
        else:
            if firstTC is None:
                firstTC = dock
            else:
                myWidget.tabifyDockWidget(firstTC, dock)
        dock.setMinimumWidth(700 - logoWidth)

    # find TC/TM Editors
    myEdits = myWidget.findChildren(asn1Editor)

    #Pattern to create/add a new dock window - easy!
    #newDock=QDockWidget('Hello', parent=myWidget)
    #newDock.setFloating(True)
    #myWidget.addDockWidget(Qt.RightDockWidgetArea, newDock)

352
353
354
    # Create a dock to handle the display of SDL diagrams
    try:
        sdl = sdlHandler(myWidget)
355
356
357
358
        try:
            sdl.dll = dll
        except ValueError as err:
            raise IOError(str(err))
359
        sdl.msc.connect(msc.addToMsc)
360
361
362
363
        sdl.msc_undo.connect(msc.undo)
        sdl.msc_redo.connect(msc.redo)
        sdl.msc_macro_start.connect(msc.start_undo_macro)
        sdl.msc_macro_stop.connect(msc.stop_undo_macro)
364
        sdl.allowed_messages.connect(myWidget.allowed_editors)
365
    except IOError as err:
366
        log.info('SDL Simulator Error - ' + str(err))
367
        #log.info(traceback.format_exc())
368
369
370
371
        sdl = None
    else:
        sdlButton = toolbar.addAction('SDL')
        sdlButton.triggered.connect(sdl.startStop)
372
373
        if options.properties:
            sdl.load_properties(options.properties)
374
375


Maxime Perrotin's avatar
Maxime Perrotin committed
376
377
378
379
380
381
382
383
384
    # Set the ASN.1 data type of each TC editor
    for editor in myEdits:
        # Enable mouse tracking - to display tips in the status bar
        editor.setMouseTracking(True)
        editor.entered.connect(editor.displaytip)
        # Hide columns showing the ASN.1 Type and constraint
        editor.hideExtraColumns()
        # Import the backend generated by the pyside_B_mapper from aadl2glueC
        encoder_backend = __import__("%s_backend" % editor.objectName())
385

Maxime Perrotin's avatar
Maxime Perrotin committed
386
        # Set the callback in the backend to forward incoming TM to the GUI
387
388
389
390
391
        encoder_backend.editor = editor
        TMHandler = type('TMHandler', (QObject,), {'got_tm': Signal()})
        encoder_backend.tm_callback = TMHandler()
        encoder_backend.tm_callback.got_tm.connect(editor.receivedTM)

392
393
        # Set the callback in the backend to send messages via the dll
        # (handled in the SDL backend, also managing MSC traces)
394
        if dll and sdl:
395
396
397
398
            DLLHandler = type('DLLHandler', (QObject,),
                              {'dll': Signal(unicode, type, type)})
            encoder_backend.send_via_dll = DLLHandler()
            encoder_backend.send_via_dll.dll.connect(sdl.send_tc)
Maxime Perrotin's avatar
Maxime Perrotin committed
399
400
401
            if isinstance(editor, asn1Viewer):
                # Connect TM to MSC
                editor.msc.connect(sdl.add_to_msc)
402
403
404
        else:
            editor.msc.connect(msc.addToMsc)

Maxime Perrotin's avatar
Maxime Perrotin committed
405
406
407
408
409
        encoder_backend.log = log
        encoder_backend.statusbar = statusbar
        editor.statusBarMessage.connect(statusbar.showMessage)
        if msgQ:
            encoder_backend.setMsgQ()
410
        elif udp:
Maxime Perrotin's avatar
Maxime Perrotin committed
411
            encoder_backend.setUDP()
412
        elif dll:
413
            # Provide pointer to the shared lib to the backends
414
            encoder_backend.setSharedLib(dll)
415
        editor.setBackend(encoder_backend)
Maxime Perrotin's avatar
Maxime Perrotin committed
416
417
418
        editor.log = log
        dockWidget = editor.parent()
        myButtons = dockWidget.findChildren(QPushButton)
419
420
421

        # retrieve user widgets for TM and TC
        customTC, customTM = [], []
422
423
424
425
426
427
        for each in UserWidgets.__all__:
            widget = getattr(UserWidgets, each)
            if widget.__base__ == UserWidgets.TC and widget.applicable():
                customTC.append(widget)
            elif widget.__base__ == UserWidgets.TM and widget.applicable():
                customTM.append(widget)
Maxime Perrotin's avatar
Maxime Perrotin committed
428
429
430
431
432
433

        if isinstance(editor, asn1Viewer):  # TM Viewer
            hasTM = True
            editor.setAsn1Model(datamodel.tm[editor.objectName()])
            g_tmPool[encoder_backend.tmId] = editor
            editor.setPlotterBackend(plotter)
Maxime Perrotin's avatar
Maxime Perrotin committed
434
435
436
            # Connect the plot_refresh signal from editors to the plot manager
            # (to make sure only one thread accesses it)
            editor.plot_refresh.connect(plotter.refresh)
Maxime Perrotin's avatar
Maxime Perrotin committed
437
438
439
440
441
442
443
444
445
446
            for button in myButtons:
                if button.objectName() == 'plotButton':
                    myMenu = QMenu()
                    action = QAction("New Plot", myMenu)
                    myMenu.addAction(action)
                    button.setMenu(myMenu)
                    action.triggered.connect(editor.newPlot)
                    plotter.addPlotMenu(myMenu, editor)
                elif button.objectName() == 'meterButton':
                    button.clicked.connect(editor.meter)
447
448
                elif button.objectName() == 'customCombo':
                    if not customTM:
449
                        button.hide()
450
451
452
453
454
455
456
457
458
                        continue
                    myMenu = QMenu()
                    for each in customTM:
                        action = QAction(each.name, myMenu)
                        myMenu.addAction(action)
                        action.triggered.connect(partial(editor.custom,
                                                         each))

                    button.setMenu(myMenu)
459
                    button.menu() # Seems there is a refresh issue without that
Maxime Perrotin's avatar
Maxime Perrotin committed
460
461
462
463
464
465
466
467
                else:
                    button.hide()
        else:  # TC Editor
            editor.setAsn1Model(datamodel.tc[editor.objectName()])
            if not msgQ:
                encoder_backend.udpController = udp
            for button in myButtons:
                if button.objectName() == 'saveButton':
468
469
470
                    # DEPRECATED - Use databases to load/save TC
                    button.hide()
                    #button.clicked.connect(editor.saveTC)
Maxime Perrotin's avatar
Maxime Perrotin committed
471
                elif button.objectName() == 'loadButton':
472
473
474
                    # DEPRECATED - Use databases to load/save TC
                    button.hide()
                    #button.clicked.connect(editor.loadTC)
Maxime Perrotin's avatar
Maxime Perrotin committed
475
476
                elif button.objectName() == 'sendButton':
                    button.clicked.connect(editor.sendTC)
477
                    if dll and sdl:
478
479
480
481
                        sdl.param_tc_editors.append({'name':
                                                         editor.objectName(),
                                                     'editor': editor,
                                                     'send_btn': button})
482
483
484
                elif button.objectName() == 'customCombo':
                    if not customTC:
                        button.hide()
485
                        continue
486
487
488
489
490
491
492
493
494
495
                    myMenu = QMenu()
                    for each in customTC:
                        action = QAction(each.name, myMenu)
                        myMenu.addAction(action)
                        action.triggered.connect(partial(editor.custom,
                                                         each))
                    button.setMenu(myMenu)
                    button.menu() # Seems there is a refresh issue without that
                else:
                    button.hide()
Maxime Perrotin's avatar
Maxime Perrotin committed
496
497
498
499
500
501
502
503
504

    # Create a thread to poll the message queue or open an UDP socket
    if msgQ:
        if hasTM:
            pollingThread = MsgQ_Poller(log=log)
            for editor in myEdits:
                if isinstance(editor, asn1Viewer):
                    pollingThread.tm.connect(editor.receivedTM)
            pollingThread.start()
505
    elif udp:
Maxime Perrotin's avatar
Maxime Perrotin committed
506
507
508
        if hasTM:
            udp.tmPool = g_tmPool
        udp.start(hasTM)
509
    elif dll:
510
        # Nothing to do, the TM callbacks have already been connected (above)
511
        pass
Maxime Perrotin's avatar
Maxime Perrotin committed
512
513
514
515
516
517
518
519
520
521
522
523
524
525

    # Associate the plotter manager to the main app
    myWidget.plotter = plotter

    # Set list of editors to the main app
    myWidget.editors = myEdits

    # If applicable, restore window geometry from a previous session
    if not options.reset:
        log.info('Restoring windows layout (use --reset to discard)')
        myWidget.restoreApplicationState()
    else:
        log.info('Ignoring and deleting previously stored windows layout')

526
527
528
529
530
531
532
533
534
535
    if 'opengeode-simulator' in sys.argv[0] and not sdl:
        ret = 1
    else:
        # Display the main window (including TM/TC editors)
        myWidget.show()
        ret = app.exec_()
        sys.stdout = sys.__stdout__
        if msgQ and hasTM:
            pollingThread._bDie = True
            pollingThread.wait()
Maxime Perrotin's avatar
Maxime Perrotin committed
536
537
538
539
    return ret

if __name__ == '__main__':
    sys.exit(gui())