Skip to content

Commit

Permalink
Refs #8562 - Do a check for valid flood files before reducing.
Browse files Browse the repository at this point in the history
This is based on Gesner's patch, which only checks on the GUI side of
things.  It would be better to do this in the Python layer as well, but
this will have to wait until a later date.  I'm sitting on a large amount
of code to do with User File parsing that will deal with file validation a
lot better, and this will someday make it in as part of #9367, but we have
so many other things to do that it's just not a priority at the moment.
  • Loading branch information
PeterParker committed Jun 2, 2014
1 parent 65343c8 commit f17964e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Code/Mantid/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp
Expand Up @@ -2043,6 +2043,12 @@ void SANSRunWindow::readNumberOfEntries(const QString & RunStep, MantidWidgets::
*/
QString SANSRunWindow::readUserFileGUIChanges(const States type)
{
const bool invalidRearFlood = m_uiForm.enableRearFlood_ck->isChecked() && !m_uiForm.floodRearFile->isValid();
const bool invalidFrontFlood = m_uiForm.enableFrontFlood_ck->isChecked() && !m_uiForm.floodFrontFile->isValid();

if( invalidRearFlood || invalidFrontFlood )
throw std::runtime_error("Invalid flood file(s). Check the path shown in the \"Reduction Settings\" tab.");

//Construct a run script based upon the current values within the various widgets
QString exec_reduce;
if ( m_uiForm.detbank_sel->currentIndex() < 2 )
Expand Down Expand Up @@ -2100,6 +2106,7 @@ QString SANSRunWindow::readUserFileGUIChanges(const States type)
exec_reduce += ", False";
}
exec_reduce += ")\n";

QString floodRearFile =
m_uiForm.enableRearFlood_ck->isChecked() ? m_uiForm.floodRearFile->getFirstFilename().trimmed() : "";
QString floodFrontFile =
Expand Down Expand Up @@ -2261,7 +2268,17 @@ void SANSRunWindow::handleReduceButtonClick(const QString & typeStr)
return;
}

QString py_code = readUserFileGUIChanges(type);
QString py_code;

try
{
py_code = readUserFileGUIChanges(type);
}
catch(const std::runtime_error & e)
{
showInformationBox(e.what());
return;
}
if( py_code.isEmpty() )
{
showInformationBox("Error: An error occurred while constructing the reduction code, please check installation.");
Expand Down

0 comments on commit f17964e

Please sign in to comment.