move argument handling from mainwindow.py to bin/secop-gui

allows calling the GUI client independently from command line arguments

Change-Id: If51b899c456ad610cf8a64f9b0f7c8a218cf5c5b
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/22503
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
zolliker 2020-02-21 16:11:59 +01:00
parent 8cf4c2d8eb
commit 89c98fa716
2 changed files with 6 additions and 10 deletions

View File

@ -58,7 +58,10 @@ def main(argv=None):
app = QApplication(argv) app = QApplication(argv)
win = MainWindow() hosts = [host for host in argv[1:] if not host.startswith('-')]
if not hosts:
hosts = ['localhost:10767']
win = MainWindow(hosts)
win.show() win.show()
return app.exec_() return app.exec_()

View File

@ -22,8 +22,6 @@
# ***************************************************************************** # *****************************************************************************
import sys
import secop.client import secop.client
from secop.gui.modulectrl import ModuleCtrl from secop.gui.modulectrl import ModuleCtrl
from secop.gui.nodectrl import NodeCtrl from secop.gui.nodectrl import NodeCtrl
@ -111,7 +109,7 @@ class QSECNode(QObject):
class MainWindow(QMainWindow): class MainWindow(QMainWindow):
def __init__(self, parent=None): def __init__(self, hosts, parent=None):
super(MainWindow, self).__init__(parent) super(MainWindow, self).__init__(parent)
loadUi(self, 'mainwindow.ui') loadUi(self, 'mainwindow.ui')
@ -130,12 +128,7 @@ class MainWindow(QMainWindow):
self._currentWidget = self.splitter.widget(1).layout().takeAt(0) self._currentWidget = self.splitter.widget(1).layout().takeAt(0)
# add localhost (if available) and SEC nodes given as arguments # add localhost (if available) and SEC nodes given as arguments
args = sys.argv[1:] for host in hosts:
if '-d' in args:
args.remove('-d')
if not args:
args = ['localhost']
for host in args:
try: try:
self._addNode(host) self._addNode(host)
except Exception as e: except Exception as e: