Skip to content

Commit

Permalink
Refs #8560. Functionality fixed, waiting for blocking tickets
Browse files Browse the repository at this point in the history
The script now returns the data in the format we want, and does a check to make sure the user has entered only an integer to save checking for an eID that won't exist

The ui has had a minor tewk in that the central widget has had it's name changed and a sensible name given to the layout it hosts. The ListWidget has also been expanded slightly. Compared to the old functionality,(as of 2.6 when this wokred last) the list box will no logner resize when given data, scrollbars will be used instead.

This ticket is now wating for #8531, #8532 and #8549 to be pushed to master so i can merge them in and make sure that the functionality doesn't break.
  • Loading branch information
keithnbrown committed Dec 6, 2013
1 parent 9677b0e commit 28d3491
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 85 deletions.
8 changes: 6 additions & 2 deletions Code/Mantid/scripts/Interface/ui/reflectometer/refl_gui.py
Expand Up @@ -107,21 +107,25 @@ def populateList(self, selected_cycle=None):
self.listMain.clear()
# Fill with ADS workspaces
self.populateListADSWorkspaces()
self.comboCycle.setVisible(False)
try:
selectedInstrument = config['default.instrument'].strip().upper()
if not self.__instrumentRuns:
self.__instrumentRuns = LatestISISRuns(instrument=selectedInstrument)
elif not self.__instrumentRuns.getInstrument() == selectedInstrument:
self.__instrumentRuns = LatestISISRuns(selectedInstrument)
self.populateListCycle(selected_cycle)
runs = self.__instrumentRuns.getJournalRuns(self.textRB.text())
for run in runs:
self.listMain.addItem(run)
#self.populateListCycle(selected_cycle)
except Exception as ex:
self.comboCycle.setVisible(False)
logger.notice("Could not list archive runs")
logger.notice(str(ex))

#Functionality which will hopefully be moved into a new file
def populateListCycle(self, selected_cycle=None):
runs = self.__instrumentRuns.getJournalRuns(cycle=selected_cycle)
runs = self.__instrumentRuns.getJournalRuns(self.textRB.text())
for run in runs:
self.listMain.addItem(run)
# Get possible cycles for this instrument.
Expand Down
47 changes: 24 additions & 23 deletions Code/Mantid/scripts/Interface/ui/reflectometer/refl_window.py
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file 'D:\mantid\windows\Code\Mantid\scripts\Interface\ui\reflectometer/refl_window.ui'
#
# Created: Tue Nov 26 12:08:03 2013
# Created: Fri Dec 06 12:25:52 2013
# by: PyQt4 UI code generator 4.8.3
#
# WARNING! All changes made in this file will be lost!
Expand All @@ -19,14 +19,15 @@ def setupUi(self, windowRefl):
windowRefl.setObjectName(_fromUtf8("windowRefl"))
windowRefl.resize(1000, 400)
windowRefl.setAcceptDrops(True)
self.layoutMainRow = QtGui.QWidget(windowRefl)
self.widgetMainRow = QtGui.QWidget(windowRefl)
self.widgetMainRow.setObjectName(_fromUtf8("widgetMainRow"))
self.layoutMainRow = QtGui.QVBoxLayout(self.widgetMainRow)
self.layoutMainRow.setMargin(9)
self.layoutMainRow.setObjectName(_fromUtf8("layoutMainRow"))
self.verticalLayout_4 = QtGui.QVBoxLayout(self.layoutMainRow)
self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4"))
self.layoutTopRow = QtGui.QHBoxLayout()
self.layoutTopRow.setSpacing(12)
self.layoutTopRow.setObjectName(_fromUtf8("layoutTopRow"))
self.comboInstrument = QtGui.QComboBox(self.layoutMainRow)
self.comboInstrument = QtGui.QComboBox(self.widgetMainRow)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand All @@ -42,30 +43,30 @@ def setupUi(self, windowRefl):
self.comboInstrument.addItem(_fromUtf8(""))
self.comboInstrument.addItem(_fromUtf8(""))
self.layoutTopRow.addWidget(self.comboInstrument)
self.comboCycle = QtGui.QComboBox(self.layoutMainRow)
self.comboCycle = QtGui.QComboBox(self.widgetMainRow)
self.comboCycle.setObjectName(_fromUtf8("comboCycle"))
self.layoutTopRow.addWidget(self.comboCycle)
self.labelRB = QtGui.QLabel(self.layoutMainRow)
self.labelRB = QtGui.QLabel(self.widgetMainRow)
self.labelRB.setObjectName(_fromUtf8("labelRB"))
self.layoutTopRow.addWidget(self.labelRB)
self.textRB = QtGui.QLineEdit(self.layoutMainRow)
self.textRB = QtGui.QLineEdit(self.widgetMainRow)
self.textRB.setMaximumSize(QtCore.QSize(55, 16777215))
self.textRB.setCursorPosition(0)
self.textRB.setObjectName(_fromUtf8("textRB"))
self.layoutTopRow.addWidget(self.textRB)
self.labelRuns = QtGui.QLabel(self.layoutMainRow)
self.labelRuns = QtGui.QLabel(self.widgetMainRow)
self.labelRuns.setObjectName(_fromUtf8("labelRuns"))
self.layoutTopRow.addWidget(self.labelRuns)
self.textRuns = QtGui.QLineEdit(self.layoutMainRow)
self.textRuns = QtGui.QLineEdit(self.widgetMainRow)
self.textRuns.setMaximumSize(QtCore.QSize(100, 16777215))
self.textRuns.setObjectName(_fromUtf8("textRuns"))
self.layoutTopRow.addWidget(self.textRuns)
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.layoutTopRow.addItem(spacerItem)
self.labelPolarCorrect = QtGui.QLabel(self.layoutMainRow)
self.labelPolarCorrect = QtGui.QLabel(self.widgetMainRow)
self.labelPolarCorrect.setObjectName(_fromUtf8("labelPolarCorrect"))
self.layoutTopRow.addWidget(self.labelPolarCorrect)
self.comboPolarCorrect = QtGui.QComboBox(self.layoutMainRow)
self.comboPolarCorrect = QtGui.QComboBox(self.widgetMainRow)
font = QtGui.QFont()
font.setWeight(75)
font.setBold(True)
Expand All @@ -78,30 +79,30 @@ def setupUi(self, windowRefl):
self.layoutTopRow.addWidget(self.comboPolarCorrect)
spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.layoutTopRow.addItem(spacerItem1)
self.checkTickAll = QtGui.QCheckBox(self.layoutMainRow)
self.checkTickAll = QtGui.QCheckBox(self.widgetMainRow)
self.checkTickAll.setLayoutDirection(QtCore.Qt.LeftToRight)
self.checkTickAll.setTristate(False)
self.checkTickAll.setObjectName(_fromUtf8("checkTickAll"))
self.layoutTopRow.addWidget(self.checkTickAll)
spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.layoutTopRow.addItem(spacerItem2)
self.buttonAuto = QtGui.QPushButton(self.layoutMainRow)
self.buttonAuto = QtGui.QPushButton(self.widgetMainRow)
self.buttonAuto.setObjectName(_fromUtf8("buttonAuto"))
self.layoutTopRow.addWidget(self.buttonAuto)
self.verticalLayout_4.addLayout(self.layoutTopRow)
self.layoutMainRow.addLayout(self.layoutTopRow)
self.layoutBottomRow = QtGui.QHBoxLayout()
self.layoutBottomRow.setObjectName(_fromUtf8("layoutBottomRow"))
self.listMain = QtGui.QListWidget(self.layoutMainRow)
self.listMain = QtGui.QListWidget(self.widgetMainRow)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.listMain.sizePolicy().hasHeightForWidth())
self.listMain.setSizePolicy(sizePolicy)
self.listMain.setMaximumSize(QtCore.QSize(150, 16777215))
self.listMain.setMaximumSize(QtCore.QSize(200, 16777215))
self.listMain.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.listMain.setObjectName(_fromUtf8("listMain"))
self.layoutBottomRow.addWidget(self.listMain)
self.buttonTransfer = QtGui.QPushButton(self.layoutMainRow)
self.buttonTransfer = QtGui.QPushButton(self.widgetMainRow)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand All @@ -112,7 +113,7 @@ def setupUi(self, windowRefl):
self.layoutBottomRow.addWidget(self.buttonTransfer)
self.layoutTableColumn = QtGui.QVBoxLayout()
self.layoutTableColumn.setObjectName(_fromUtf8("layoutTableColumn"))
self.tableMain = QtGui.QTableWidget(self.layoutMainRow)
self.tableMain = QtGui.QTableWidget(self.widgetMainRow)
font = QtGui.QFont()
font.setWeight(50)
font.setBold(False)
Expand Down Expand Up @@ -166,21 +167,21 @@ def setupUi(self, windowRefl):
self.layoutTableColumn.addWidget(self.tableMain)
self.layoutTableButton = QtGui.QHBoxLayout()
self.layoutTableButton.setObjectName(_fromUtf8("layoutTableButton"))
self.buttonProcess = QtGui.QPushButton(self.layoutMainRow)
self.buttonProcess = QtGui.QPushButton(self.widgetMainRow)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.buttonProcess.sizePolicy().hasHeightForWidth())
self.buttonProcess.setSizePolicy(sizePolicy)
self.buttonProcess.setObjectName(_fromUtf8("buttonProcess"))
self.layoutTableButton.addWidget(self.buttonProcess)
self.buttonClear = QtGui.QPushButton(self.layoutMainRow)
self.buttonClear = QtGui.QPushButton(self.widgetMainRow)
self.buttonClear.setObjectName(_fromUtf8("buttonClear"))
self.layoutTableButton.addWidget(self.buttonClear)
self.layoutTableColumn.addLayout(self.layoutTableButton)
self.layoutBottomRow.addLayout(self.layoutTableColumn)
self.verticalLayout_4.addLayout(self.layoutBottomRow)
windowRefl.setCentralWidget(self.layoutMainRow)
self.layoutMainRow.addLayout(self.layoutBottomRow)
windowRefl.setCentralWidget(self.widgetMainRow)
self.menuBar = QtGui.QMenuBar(windowRefl)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 1000, 21))
self.menuBar.setObjectName(_fromUtf8("menuBar"))
Expand Down
9 changes: 6 additions & 3 deletions Code/Mantid/scripts/Interface/ui/reflectometer/refl_window.ui
Expand Up @@ -16,8 +16,11 @@
<property name="windowTitle">
<string>ISIS Reflectometry</string>
</property>
<widget class="QWidget" name="layoutMainRow">
<layout class="QVBoxLayout" name="verticalLayout_4">
<widget class="QWidget" name="widgetMainRow">
<layout class="QVBoxLayout" name="layoutMainRow">
<property name="margin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="layoutTopRow">
<property name="spacing">
Expand Down Expand Up @@ -209,7 +212,7 @@
</property>
<property name="maximumSize">
<size>
<width>150</width>
<width>200</width>
<height>16777215</height>
</size>
</property>
Expand Down
95 changes: 38 additions & 57 deletions Code/Mantid/scripts/Reflectometry/isis_reflgui/latest_isis_runs.py
Expand Up @@ -18,25 +18,20 @@ class LatestISISRuns(object):
__cycleMap = None

def __init__(self, instrument):

self.__instrument = instrument.upper().strip()

self.__instrument = instrument.upper().strip()
usersettings = Settings() # This will throw a missing config exception if no config file is available.
try:
self.__mountpoint = usersettings.get_named_setting("DataMountPoint")
except KeyError:
print "DataMountPoint is missing from the config.xml file."
raise

self.getPaths()

def getPaths(self):
instr_path = os.path.join(self.__mountpoint, 'NDX'+ self.__instrument, 'Instrument')
self.__checkPath(instr_path)

base_path = os.path.join(instr_path, 'logs', 'journal')
self.__checkPath(base_path)

path = os.path.join(base_path, 'journal_main.xml')
tree = xml.parse(path)
dom = tree.getroot()
Expand All @@ -60,12 +55,8 @@ def getInstrument(self):
def __findCycleId(self, path):
tree = xml.parse(path)
root = tree.getroot()
print root.tag
for run in root:
print run.tag
for elem in run:
print elem.tag
print elem.tag.split('}')
if elem.tag.split('}')[-1] == 'isis_cycle':
return elem.text

Expand All @@ -75,21 +66,16 @@ def __checkPath(self, path):


def __getLocations(self):

instr_path = os.path.join(self.__mountpoint, 'NDX'+ self.__instrument, 'Instrument')
self.__checkPath(instr_path)

base_path = os.path.join(instr_path, 'logs', 'journal')
self.__checkPath(base_path)

journal_path = self.__getLatestJournalPath(base_path)
self.__checkPath(journal_path)

cycle_dir = 'cycle_'+ self.__findCycleId(journal_path)
cycle_path = os.path.join(instr_path, 'data', cycle_dir)
self.__checkPath(cycle_path)

return cycle_path, journal_path
instr_path = os.path.join(self.__mountpoint, 'NDX'+ self.__instrument, 'Instrument')
self.__checkPath(instr_path)
base_path = os.path.join(instr_path, 'logs', 'journal')
self.__checkPath(base_path)
journal_path = self.__getLatestJournalPath(base_path)
self.__checkPath(journal_path)
cycle_dir = 'cycle_'+ self.__findCycleId(journal_path)
cycle_path = os.path.join(instr_path, 'data', cycle_dir)
self.__checkPath(cycle_path)
return cycle_path, journal_path

def __addSettingDirToManagedUserDirs(self, cycle_dir):
current_search_dir= config.getDataSearchDirs()
Expand All @@ -98,37 +84,32 @@ def __addSettingDirToManagedUserDirs(self, cycle_dir):
config.appendDataSearchDir(cycle_dir)

def getJournalRuns(self, eID):
journal_path, cycle_dir_path = self.__cycleMap[self.__most_recent_cycle]

# side effect.
self.__addSettingDirToManagedUserDirs(cycle_dir_path)

runnames = []
tree = xml.parse(journal_path)
root = tree.getroot()
for run in root:
if run.findall('experiment_identifier')[0].text == eID:
#i think this way is more inefficent, i'll check it vs iterating and breaking
#runno = run.findall('run_number')[0].text
#title = run.findall('title')[0].text
runno = None
title = None
for curTag in run
#if curTag.tag.split('}')[-1] == 'run_number':
if curTag.tag == 'run_number':
runno = curTag.text
#elif curTag.tag.split('}')[-1] == 'title':
elif curTag.tag == 'title':
title = curTag.text
if title && runno:
break
# print "RB",run[3].text, runno, run[0].text
journalentry = runno + ": " + title
runnames.append(journalentry)
'''
for elem in run:
print elem.tag
print elem.tag.split('}')
if (elem.tag.split('}')[-1] == 'experiment_identifier') && (elem.text == eID):
'''
if eID:
try:
#this is meant to speed up the check if invalid input is given
#as this will throw if the given eID isn't an integer
intcheck = int(eID)
journal_path, cycle_dir_path = self.runPaths
# side effect.
self.__addSettingDirToManagedUserDirs(cycle_dir_path)
tree = xml.parse(journal_path)
root = tree.getroot()
for run in root:
for thisTag in run:
if thisTag.tag.split('}')[-1] == 'experiment_identifier' and thisTag.text == eID:
runno = None
title = None
for curTag in run:
if curTag.tag.split('}')[-1] == 'run_number':
runno = curTag.text.strip()
elif curTag.tag.split('}')[-1] == 'title':
title = curTag.text.strip()
if title and runno:
break
journalentry = runno + ": " + title
runnames.append(journalentry)
break
except:
print "Could not fetch Journal runs, an error occurred during searching"
return runnames

0 comments on commit 28d3491

Please sign in to comment.