Skip to content

Commit

Permalink
Refs #8633. Updated to use the new API and fail gracefully
Browse files Browse the repository at this point in the history
There is now a 'directory exists' check on the directory given to the textbox.

Added the procedures script, as the save was reliant on it.

Updated the save and procedures scripts to use the new api
  • Loading branch information
keithnbrown committed Jan 8, 2014
1 parent c61adbc commit 2ec83fe
Show file tree
Hide file tree
Showing 2 changed files with 1,349 additions and 17 deletions.
30 changes: 13 additions & 17 deletions Code/Mantid/scripts/Interface/ui/reflectometer/refl_save.py
Expand Up @@ -3,6 +3,7 @@
from mantid.api import WorkspaceGroup
import xml.etree.ElementTree as xml
from isis_reflectometry.quick import *
from isis_reflectometry.procedures import *
from isis_reflectometry.combineMulti import *
from isis_reflgui.settings import *

Expand Down Expand Up @@ -228,7 +229,7 @@ def workspaceSelected(self):
logs = mtd[str(self.listWidget.currentItem().text())].getRun().getLogData()
for i in range(0,len(logs)):
self.listWidget2.addItem(logs[i].name)

def on_comboBox_Activated(self):
print ""

Expand All @@ -249,14 +250,10 @@ def populateList(self):
base_path = os.path.join(self.__mountpoint, 'NDX'+ self.__instrument, 'Instrument','logs','journal')
print base_path
main_journal_path = os.path.join(base_path, 'journal_main.xml')
#tree1=xml.parse(r'\\isis\inst$\NDX'+currentInstrument+'\Instrument\logs\journal\journal_main.xml')
print main_journal_path
tree1=xml.parse(main_journal_path)
root1=tree1.getroot()
currentJournal=root1[len(root1)-1].attrib.get('name')
cycle_journal_path = os.path.join(base_path, currentJournal)
print cycle_journal_path
#tree=xml.parse(r'\\isis\inst$\NDX'+currentInstrument+'\Instrument\logs\journal\\'+currentJournal)
tree=xml.parse(cycle_journal_path)
root=tree.getroot()

Expand All @@ -272,25 +269,25 @@ def populateList(self):
self.lineEdit.setText(SavePath)
except LookupError:
print "Not found!"

#--------- If "Save" button pressed, selcted workspaces are saved -------------
def buttonClickHandler1(self):
names = mtd.getObjectNames()
dataToSave=[]
prefix = str(self.lineEdit2.text())
if (self.lineEdit.text()[len(self.lineEdit.text())-1] != '/'):
path = self.lineEdit.text()+'/'
else:
path = self.lineEdit.text()

if not (self.lineEdit.text() and os.path.exists(self.lineEdit.text())):
logger.notice("Directory specified doesn't exist or was invalid for your operating system")
QtGui.QMessageBox.critical(self.lineEdit, 'Could not save',"Directory specified doesn't exist or was invalid for your operating system")
return
print self.listWidget.selectedItems()
for idx in self.listWidget.selectedItems():
runlist=parseRunList(str(self.spectraEdit.text()))
print runlist
fname=str(path+prefix+idx.text())
fname=os.path.join(self.lineEdit.text(),prefix + idx.text())
if (self.comboBox.currentIndex() == 0):
fname+='.dat'
print "FILENAME: ", fname
a1=mtd.getMatrixWorkspace(str(idx.text()))
a1=mtd[str(idx.text())]
titl='#'+a1.getTitle()+'\n'
x1=a1.readX(0)
X1=n.zeros((len(x1)-1))
Expand All @@ -304,7 +301,7 @@ def buttonClickHandler1(self):
sep=' '
elif (self.radio3.isChecked()):
sep='\t'
print fname
f=open(fname,'w')
if self.titleCheckBox.isChecked():
f.write(titl)
Expand Down Expand Up @@ -333,7 +330,6 @@ def buttonClickHandler1(self):
elif (self.comboBox.currentIndex() == 3):
print "ILL MFT format"
self.saveMFT(idx,fname)

# for idx in self.listWidget.selectedItems():
# fname=str(path+prefix+idx.text()+'.dat')
# print "FILENAME: ", fname
Expand All @@ -345,7 +341,7 @@ def buttonClickHandler1(self):
def saveANSTO(self,idx,fname):
fname+='.txt'
print "FILENAME: ", fname
a1=mtd.getMatrixWorkspace(str(idx.text()))
a1=mtd[str(idx.text())]
titl='#'+a1.getTitle()+'\n'
x1=a1.readX(0)
X1=n.zeros((len(x1)-1))
Expand All @@ -366,7 +362,7 @@ def saveANSTO(self,idx,fname):
def saveMFT(self,idx,fname):
fname+='.mft'
print "FILENAME: ", fname
a1=mtd.getMatrixWorkspace(str(idx.text()))
a1=mtd[str(idx.text())]
titl=a1.getTitle()+'\n'
x1=a1.readX(0)
X1=n.zeros((len(x1)-1))
Expand Down

0 comments on commit 2ec83fe

Please sign in to comment.