|
@@ -3,6 +3,7 @@ import unittest
|
|
|
from __main__ import vtk, qt, ctk, slicer
|
|
|
from slicer.ScriptedLoadableModule import *
|
|
|
import slicerNetwork
|
|
|
+import json
|
|
|
|
|
|
#
|
|
|
# labkeySlicerPythonExtension
|
|
@@ -48,6 +49,7 @@ class labkeySlicerPythonExtensionWidget(ScriptedLoadableModuleWidget):
|
|
|
self.layout.addWidget(connectionCollapsibleButton)
|
|
|
|
|
|
connectionFormLayout = qt.QFormLayout(connectionCollapsibleButton)
|
|
|
+ self.configDir='.'
|
|
|
|
|
|
self.serverURL=qt.QLineEdit("https://merlin.fmf.uni-lj.si")
|
|
|
self.serverURL.textChanged.connect(self.updateServerURL)
|
|
@@ -87,6 +89,11 @@ class labkeySlicerPythonExtensionWidget(ScriptedLoadableModuleWidget):
|
|
|
#self.connectButton.connect('clicked(bool)',self.onConnectButtonClicked)
|
|
|
#connectionFormLayout.addRow("Connection:",self.connectButton)
|
|
|
|
|
|
+ self.loadConfigButton=qt.QPushButton("Load configuration")
|
|
|
+ self.loadConfigButton.toolTip="Load configuration"
|
|
|
+ self.loadConfigButton.connect('clicked(bool)',self.onLoadConfigButtonClicked)
|
|
|
+ connectionFormLayout.addRow("Connection:",self.loadConfigButton)
|
|
|
+
|
|
|
self.initButton=qt.QPushButton("Init")
|
|
|
self.initButton.toolTip="Initialize connection to the server"
|
|
|
self.initButton.connect('clicked(bool)',self.onInitButtonClicked)
|
|
@@ -256,6 +263,37 @@ class labkeySlicerPythonExtensionWidget(ScriptedLoadableModuleWidget):
|
|
|
|
|
|
self.network.connectRemote(str(self.serverURL.text),uname,self.auth_pwd)
|
|
|
|
|
|
+ def onLoadConfigButtonClicked(self):
|
|
|
+ filename=qt.QFileDialog.getOpenFileName(None,'Open configuration file (JSON)',
|
|
|
+ self.configDir, '*.json')
|
|
|
+ with open(filename,'r') as f:
|
|
|
+ dt=json.load(f)
|
|
|
+ if dt.has_key('host'):
|
|
|
+ self.serverURL.setText(dt['host'])
|
|
|
+ if dt.has_key('dataset'):
|
|
|
+ pass
|
|
|
+ #self.datasetName.setText(dt['dataset'])
|
|
|
+ if dt.has_key('project'):
|
|
|
+ pass
|
|
|
+ #self.datasetProject.setText(dt['project'])
|
|
|
+ if dt.has_key('SSL'):
|
|
|
+ if dt['SSL'].has_key('user'):
|
|
|
+ self.userCertButton.setText(dt['SSL']['user'])
|
|
|
+ if dt['SSL'].has_key('key'):
|
|
|
+ self.privateKeyButton.setText(dt['SSL']['key'])
|
|
|
+ if dt['SSL'].has_key('keyPwd'):
|
|
|
+ self.pwd=dt['SSL']['keyPwd']
|
|
|
+ if dt['SSL'].has_key('ca'):
|
|
|
+ self.caCertButton.setText(dt['SSL']['ca'])
|
|
|
+ if dt.has_key('labkey'):
|
|
|
+ if dt['labkey'].has_key('user'):
|
|
|
+ self.network.auth_name=dt['labkey']['user']
|
|
|
+ self.authName.setText(self.network.auth_name)
|
|
|
+ if dt['labkey'].has_key('password'):
|
|
|
+ self.network.auth_pass=dt['labkey']['password']
|
|
|
+ self.authPass.setText(self.network.auth_pass)
|
|
|
+ self.loadConfigButton.setText(os.path.basename(filename))
|
|
|
+
|
|
|
def onInitButtonClicked(self):
|
|
|
self.network.configureSSL(
|
|
|
self.userCertButton.text,
|