Commit 9c53bcb8 authored by Makayla Shepherd's avatar Makayla Shepherd
Browse files

When an invalid file is entered thmproc will display an error message instead...

When an invalid file is entered thmproc will display an error message instead of crashing. Fixes #1025.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6271 41f8697f-d340-4b68-9986-7bafba869bb8
parent c94ea994
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -14,6 +14,43 @@ void IsisMain() {
    throw IException(IException::User, msg, _FILEINFO_);
  }

  if(ui.WasEntered("PCK")) {
    FileName pckPreference = ui.GetFileName("PCK");
    if(!pckPreference.fileExists()){
      QString msg = "Please provide a valid PCK preference file.";
      throw IException(IException::User, msg, _FILEINFO_);
    }
  }
  
  if(ui.WasEntered("CK")) {
    FileName ckPreference = ui.GetFileName("CK");
    if(!ckPreference.fileExists()){
      QString msg = "Please provide a valid CK preference file.";
      throw IException(IException::User, msg, _FILEINFO_);
    }
  }
  
  if(ui.WasEntered("SPK")) {
    FileName spkPreference = ui.GetFileName("SPK");
    if(!spkPreference.fileExists()){
      QString msg = "Please provide a valid SPK preference file.";
      throw IException(IException::User, msg, _FILEINFO_);
    }
  }
  if(ui.WasEntered("MAP")) {
    FileName mapPreference = ui.GetFileName("MAP");
    if(!mapPreference.fileExists()){
      QString msg = "Please provide a valid MAP preference file.";
      throw IException(IException::User, msg, _FILEINFO_);
    }
  }
  if(ui.WasEntered("MODEL")) {
    FileName modelPreference = ui.GetFileName("MODEL");
    if(!modelPreference.fileExists()){
      QString msg = "Please provide a valid MODEL preference file.";
      throw IException(IException::User, msg, _FILEINFO_);
    }
  }
  if(ui.GetBoolean("INGESTION")) {
    Pvl labels(ui.GetFileName("FROM"));

@@ -40,6 +77,8 @@ void ProcessVis(bool isRdr) {

  p.SetInputFile("FROM", "BANDS");
  p.SetOutputFile("TO");
  // Set continue to false so that we know if something fails
  p.SetContinue(false);
  p.KeepTemporaryFiles(!ui.GetBoolean("REMOVE"));

  p.AddToPipeline("thm2isis");
@@ -113,6 +152,8 @@ void ProcessIr() {
  p.SetOutputFile("TO");

  p.KeepTemporaryFiles(!ui.GetBoolean("REMOVE"));
  // Set continue to false so that we know if something fails
  p.SetContinue(false);

  p.AddToPipeline("thm2isis");
  p.Application("thm2isis").SetInputParameter("FROM", false);
+4 −0
Original line number Diff line number Diff line
@@ -84,6 +84,10 @@
    <change name="Jeffrey Covington" date="2015-01-27">
      Removed unreachable code.
    </change>
    <change name="Makayla Shepherd and Andrew Stebenne" date="2015-07-14">
      Updated to fix a crash that occurs when invalid files are passed in as parameters. 
      Fixes #1025.
    </change>
  </history>

  <category>
+41 −0
Original line number Diff line number Diff line
@@ -11,4 +11,45 @@ commands:
	TO=$(OUTPUT)/V01001002EDR \
	INGESTION=no \
	MAPPING=no 2>> $(OUTPUT)/error.txt > /dev/null;
	$(RM) $(OUTPUT)/input_* ;
	echo -e "Error Test: Nonexistent PCK file" >> $(OUTPUT)/error.txt;
	$(CP) $(INPUT)/V01001002EDR.QUB $(OUTPUT)/input_V01001002EDR.QUB; \
	$(APPNAME) FROM=$(OUTPUT)/input_V01001002EDR.QUB \
	TO=$(OUTPUT)/V01001002EDR \
	INGESTION=yes \
	MAPPING=no \
	PCK=dummy.pck 2>> $(OUTPUT)/error.txt > /dev/null;
	$(RM) $(OUTPUT)/input_*
	echo -e "Error Test: Nonexistent CK file" >> $(OUTPUT)/error.txt;
	$(CP) $(INPUT)/V01001002EDR.QUB $(OUTPUT)/input_V01001002EDR.QUB; \
        $(APPNAME) FROM=$(OUTPUT)/input_V01001002EDR.QUB \
        TO=$(OUTPUT)/V01001002EDR \
        INGESTION=yes \
        MAPPING=no \
        CK=dummy.ck 2>> $(OUTPUT)/error.txt > /dev/null;
	$(RM) $(OUTPUT)/input_*
	echo -e "Error Test: Nonexistent SPK file" >> $(OUTPUT)/error.txt;
	$(CP) $(INPUT)/V01001002EDR.QUB $(OUTPUT)/input_V01001002EDR.QUB; \
        $(APPNAME) FROM=$(OUTPUT)/input_V01001002EDR.QUB \
        TO=$(OUTPUT)/V01001002EDR \
        INGESTION=yes \
        MAPPING=no \
        SPK=dummy.spk 2>> $(OUTPUT)/error.txt > /dev/null;
	$(RM) $(OUTPUT)/input_*
	echo -e "Error Test: Nonexistent MAP file" >> $(OUTPUT)/error.txt;
	$(CP) $(INPUT)/V01001002EDR.QUB $(OUTPUT)/input_V01001002EDR.QUB; \
        $(APPNAME) FROM=$(OUTPUT)/input_V01001002EDR.QUB \
        TO=$(OUTPUT)/V01001002EDR \
        INGESTION=yes \
        MAPPING=yes \
        MAP=dummy.ck 2>> $(OUTPUT)/error.txt > /dev/null;
	$(RM) $(OUTPUT)/input_*
	echo -e "Error Test: Nonexistent MODEL file" >> $(OUTPUT)/error.txt;
	$(CP) $(INPUT)/V01001002EDR.QUB $(OUTPUT)/input_V01001002EDR.QUB; \
        $(APPNAME) FROM=$(OUTPUT)/input_V01001002EDR.QUB \
        TO=$(OUTPUT)/V01001002EDR \
        INGESTION=yes \
        MAPPING=no \
        SHAPE=USER \
        MODEL=dummy.ck 2>> $(OUTPUT)/error.txt > /dev/null;
	$(RM) $(OUTPUT)/input_*