Skip to content

Commit

Permalink
Add option to specify hostname when starting in client mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jooste committed Mar 10, 2022
1 parent 32beb62 commit 9ab1b6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion BlueSky.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def main():
# also advise latest version
missingmodules = {"OpenGL": "pyopengl and pyopengl-accelerate"}

serv_addr = None

### Parse command-line arguments ###
# BlueSky.py modes:
# server-gui: Start gui and simulation server
Expand Down Expand Up @@ -67,6 +69,9 @@ def main():
mode = 'sim'
elif '--client' in sys.argv:
mode = 'client'
pos = sys.argv.index('--client')
if len(sys.argv) > pos + 1:
serv_addr = sys.argv[pos + 1]
elif '--headless' in sys.argv:
mode = 'server-headless'
else:
Expand Down Expand Up @@ -110,7 +115,7 @@ def main():
# Start gui if client or main server/gui combination is started here
if mode in ('client', 'server-gui'):
from bluesky.ui import qtgl
qtgl.start(mode)
qtgl.start(mode, serv_addr)

# Give info on missing module
except ImportError as error:
Expand Down
7 changes: 4 additions & 3 deletions bluesky/ui/qtgl/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def gui_msg_handler(msgtype, context, msg):
exit()


def start(mode):
def start(mode, hostname=None):
# Install message handler for Qt messages
qInstallMessageHandler(gui_msg_handler)

Expand Down Expand Up @@ -60,13 +60,14 @@ def start(mode):
splash.finish(win)
# If this instance of the gui is started in client-only mode, show
# server selection dialog
if mode == 'client':
if mode == 'client' and hostname is None:
dialog = DiscoveryDialog(win)
dialog.show()
bs.net.start_discovery()

else:
client.connect(event_port=bs.settings.event_port,
client.connect(hostname=hostname or 'localhost',
event_port=bs.settings.event_port,
stream_port=bs.settings.stream_port)

# Start the Qt main loop
Expand Down

0 comments on commit 9ab1b6d

Please sign in to comment.