Skip to content

Commit

Permalink
Merge pull request #175 from dls-controls/works-without-X
Browse files Browse the repository at this point in the history
Avoid loading Qt things if $DISPLAY is not defined
  • Loading branch information
coretl committed Nov 30, 2016
2 parents 88387df + d1d112c commit cf0cc0a
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions malcolm/imalcolm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def make_process():
import threading
import argparse
import logging
from os import environ

parser = argparse.ArgumentParser(
description="Interactive shell for malcolm")
Expand All @@ -31,20 +32,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 cf0cc0a

Please sign in to comment.