Skip to content

Commit

Permalink
Avoid loading Qt things if $DISPLAY is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Nic Bricknell committed Nov 29, 2016
1 parent a189b8d commit d1d112c
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions malcolm/imalcolm.py
Expand Up @@ -5,6 +5,7 @@ def make_process():
import threading
import argparse
import logging
from os import environ

parser = argparse.ArgumentParser(
description="Interactive shell for malcolm")
Expand All @@ -30,20 +31,28 @@ def make_process():

from malcolm.core import SyncFactory, Process
from malcolm.yamlutil import make_include_creator
from PyQt4.Qt import QApplication

# Start qt
def start_qt():
global app
app = QApplication(sys.argv)
app.setQuitOnLastWindowClosed(False)
from malcolm.gui.guiopener import GuiOpener
global opener
opener = GuiOpener()
app.exec_()

qt_thread = threading.Thread(target=start_qt)
qt_thread.start()
try:
environ['DISPLAY']
# If this environment variable doesn't exist then there is probably no
# X server for us to talk to.
except KeyError:
pass
else:
from PyQt4.Qt import QApplication

# Start qt
def start_qt():
global app
app = QApplication(sys.argv)
app.setQuitOnLastWindowClosed(False)
from malcolm.gui.guiopener import GuiOpener
global opener
opener = GuiOpener()
app.exec_()

qt_thread = threading.Thread(target=start_qt)
qt_thread.start()

sf = SyncFactory("Sync")

Expand Down

0 comments on commit d1d112c

Please sign in to comment.