|
@@ -157,9 +157,18 @@ class fileIOWidget(slicer.ScriptedLoadableModule.ScriptedLoadableModuleWidget):
|
|
|
copyToRemoteButton.connect('clicked(bool)',self.onCopyToRemoteButtonClicked)
|
|
|
fileDialogFormLayout.addRow(copyToRemoteButton)
|
|
|
|
|
|
+ removeRemoteButton=qt.QPushButton("Remove remote")
|
|
|
+ removeRemoteButton.toolTip="Remove Remote"
|
|
|
+ removeRemoteButton.connect('clicked(bool)',self.onRemoveRemoteButtonClicked)
|
|
|
+ fileDialogFormLayout.addRow(removeRemoteButton)
|
|
|
+
|
|
|
+ mkdirRemoteButton=qt.QPushButton("Mkdir remote")
|
|
|
+ mkdirRemoteButton.toolTip="Mkdir Remote"
|
|
|
+ mkdirRemoteButton.connect('clicked(bool)',self.onMkdirRemoteButtonClicked)
|
|
|
+ fileDialogFormLayout.addRow(mkdirRemoteButton)
|
|
|
|
|
|
def onListLocalButtonClicked(self):
|
|
|
- self.localPath.setText(qt.QFileDialog.getOpenFileName())
|
|
|
+ self.localPath.setText(qt.QFileDialog.getOpenFileName(None,"Select local"))
|
|
|
|
|
|
def onListRemoteButtonClicked(self):
|
|
|
self.selectRemote.show()
|
|
@@ -188,11 +197,38 @@ class fileIOWidget(slicer.ScriptedLoadableModule.ScriptedLoadableModuleWidget):
|
|
|
self.loadConfigButton.setText(os.path.basename(filename))
|
|
|
self.network.initRemote()
|
|
|
|
|
|
+ def copyLocalToRemote(self,localPath,remotePath):
|
|
|
+ if os.path.isfile(localPath):
|
|
|
+ #end recursion
|
|
|
+ print "Copy {} to {}".format(localPath,remotePath)
|
|
|
+ self.network.copyFileToRemote(localPath,remotePath)
|
|
|
+ return
|
|
|
+
|
|
|
+ dirName=os.path.basename(os.path.normpath(localPath))
|
|
|
+ remotePath+='/'+dirName
|
|
|
+ if not self.network.isDir(remotePath):
|
|
|
+ self.network.mkdir(remotePath+'/')
|
|
|
+ for f in os.listdir(localPath):
|
|
|
+ #enter recursion
|
|
|
+ localfile=os.path.join(localPath,f)
|
|
|
+ self.copyLocalToRemote(localfile,remotePath)
|
|
|
+
|
|
|
def onCopyToRemoteButtonClicked(self):
|
|
|
- if os.path.isfile(self.localPath.text):
|
|
|
- self.network.copyFileToRemote(self.localPath.text,self.remotePath.text)
|
|
|
- else:
|
|
|
- print "Not implemented for directories"
|
|
|
+ self.copyLocalToRemote(self.localPath.text,self.remotePath.text)
|
|
|
+
|
|
|
+ def onRemoveRemoteButtonClicked(self):
|
|
|
+ remotePath=self.remotePath.text
|
|
|
+ if self.network.isDir(remotePath):
|
|
|
+ resp=qt.QMessageBox.question(None,'Delete directory',
|
|
|
+ 'Do you want to delete directory {}'.format(remotePath))
|
|
|
+ if resp == qt.QMessageBox.No:
|
|
|
+ return
|
|
|
+ self.network.rmdir(remotePath)
|
|
|
+
|
|
|
+ def onMkdirRemoteButtonClicked(self):
|
|
|
+ remotePath=self.remotePath.text
|
|
|
+ self.network.mkdir(remotePath)
|
|
|
+
|
|
|
|
|
|
class fileIOLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
|
|
|
def __init__(self,parent):
|