Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExitCodes refactoring so that their number fit in the range 0-255 #297

Merged
merged 5 commits into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions DTIPrep/DTIPrepRegister.pl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
my ($protXMLrefs) = &DTI::readDTIPrepXMLprot($DTIPrepProtocol);
if (!$protXMLrefs) {
print LOG "\n\tERROR: DTIPrep XML protocol could not be read.\n";
exit $NeuroDB::ExitCodes::UNREADABLE_DTIPREP_PROTOCOL;
exit $NeuroDB::ExitCodes::UNREADABLE_FILE;
}

# 1.b Create a hash containing names of all outputs created by DTIPrep/mincdiffusion pipeline
Expand All @@ -151,7 +151,7 @@
if ((!$mincdiffVersion) && ($DTIrefs->{$dti_file}->{'Postproc'}->{'Tool'} eq "mincdiffusion")) {
print LOG "\n$Usage\nERROR:\n\tYou must specify which version of "
. "mincdiffusion tools was used to post-process the DTI.\n";
exit $NeuroDB::ExitCodes::NO_MINCDIFFUSION_VERSION;
exit $NeuroDB::ExitCodes::MISSING_TOOL_VERSION;
}


Expand All @@ -168,13 +168,13 @@
# If $QCed_minc is not defined, means that getFiles returned undef for all output files => ERROR.
if (!$QCReport) {
print LOG "\nERROR:\n\tSome process files are missing in $DTIPrep_subdir.\n";
exit $NeuroDB::ExitCodes::MISSING_PREPROCESSED_FILES;
exit $NeuroDB::ExitCodes::MISSING_FILES;
}
# If $QCed2_step is set, QCed2_minc should be defined in %mri_files hash!
if (($QCed2_step) && (!$mri_files->{'Preproc'}{'QCed2'}{'minc'})) {
print LOG "\nERROR:\n\tSecondary QCed DTIPrep nrrd & minc outputs are "
. "missing in $DTIPrep_subdir.\n";
exit $NeuroDB::ExitCodes::MISSING_POSTPROCESSED_FILES;
exit $NeuroDB::ExitCodes::MISSING_FILES;
}
# => If we could pass step 2, then all the files to be registered were found in the filesystem!

Expand All @@ -191,7 +191,7 @@
"DTIPrep");
if (!$registeredXMLprotocolID) {
print LOG "\nERROR: no XML protocol file was registered in the database\n";
exit $NeuroDB::ExitCodes::FILE_REGISTRATION_FAILURE;
exit $NeuroDB::ExitCodes::INSERT_FAILURE;
} else {
print LOG "\nRegistered XML protocol with ID $registeredXMLprotocolID.\n";
$mri_files->{'Preproc'}{'QCProt'}{'xml'} = $registeredXMLprotocolID;
Expand All @@ -216,7 +216,7 @@
$DTIPrepVersion);
if (!$registeredXMLReportFile) {
print LOG "\nERROR: no XML report file was registered in the database\n";
exit $NeuroDB::ExitCodes::FILE_REGISTRATION_FAILURE;
exit $NeuroDB::ExitCodes::INSERT_FAILURE;
} else {
print LOG "\nRegistered XML report $registeredXMLReportFile.\n";
$mri_files->{'Preproc'}{'QCReport'}{'xml'} = $registeredXMLReportFile;
Expand All @@ -239,7 +239,7 @@
$DTIPrepVersion);
if (!$registeredQCReportFile) {
print LOG "\nERROR: no QC report file was registered in the database\n";
exit $NeuroDB::ExitCodes::FILE_REGISTRATION_FAILURE;
exit $NeuroDB::ExitCodes::INSERT_FAILURE;
} else {
print LOG "\nRegistered QC report $registeredQCReportFile.\n";
$mri_files->{'Preproc'}{'QCReport'}{'txt'} = $registeredQCReportFile;
Expand Down Expand Up @@ -575,7 +575,7 @@ sub register_XMLFile {
if (!$toolName) {
print STDERR "WARNING: This should not happen as long as the pipeline "
. "versioning of DTIPrep is not fixed!";
exit $NeuroDB::ExitCodes::NO_TOOL_NAME_VERSION;
exit $NeuroDB::ExitCodes::MISSING_TOOL_VERSION;
# Will need to program this part once DTIPrep fixed!
#($src_pipeline, $src_tool)=getToolName($XMLFile);
}else {
Expand Down Expand Up @@ -655,7 +655,7 @@ sub register_QCReport {
if (!$toolName) {
print STDERR "WARNING: This should not happen as long as the pipeline "
. "versioning of DTIPrep is not fixed!";
exit $NeuroDB::ExitCodes::NO_TOOL_NAME_VERSION;
exit $NeuroDB::ExitCodes::MISSING_TOOL_VERSION;
# Will need to program this part once DTIPrep fixed!
#($src_pipeline, $src_tool)=getToolName($QCReport);
}else {
Expand Down Expand Up @@ -961,7 +961,7 @@ sub getToolName {
. "which tool was used manually with the option "
. "-DTIPrepVersion or -mincdiffusionVersion as input of the "
. "script DTIPrepRegister.pl.";
exit $NeuroDB::ExitCodes::NO_TOOL_NAME_VERSION;
exit $NeuroDB::ExitCodes::MISSING_TOOL_VERSION;
}else {
#remove leading spaces, trailing spaces and all instances of "
$src_tool =~s/"//g;
Expand Down Expand Up @@ -1332,7 +1332,7 @@ sub register_nrrd {
if (!$toolName) {
print STDERR "WARNING: This should not happen as long as the pipeline "
. "versioning of DTIPrep is not fixed!";
exit $NeuroDB::ExitCodes::NO_TOOL_NAME_VERSION;
exit $NeuroDB::ExitCodes::MISSING_TOOL_VERSION;
# Will need to program this part once DTIPrep fixed!
#($src_pipeline, $src_tool)=getToolName($XMLFile);
}else {
Expand Down
8 changes: 4 additions & 4 deletions DTIPrep/DTIPrep_pipeline.pl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
. "via the path to DTIPrep binary. You need to specify which "
. "version of DTIPrep you will be using with -DTIPrepVersion "
. "option.\n\n";
exit $NeuroDB::ExitCodes::NO_DTIPREP_VERSION;
exit $NeuroDB::ExitCodes::MISSING_TOOL_VERSION;
}

# Establish database connection
Expand Down Expand Up @@ -169,14 +169,14 @@
if (!$mincdiffVersion) {
print STDERR "\n\tERROR: mincdiffusion tool's version could "
. "not be determined.\n\n";
exit $NeuroDB::ExitCodes::NO_MINCDIFFUSION_VERSION;
exit $NeuroDB::ExitCodes::MISSING_TOOL_VERSION;
}
# Exit program if $niak_path is not set
if (!$niak_path) {
print STDERR "\n\tERROR: variable niak_path need to be set in the "
. "config file if you plan to use mincdiffusion tools "
. "to process the DTI files.\n\n";
exit $NeuroDB::ExitCodes::NO_NIAK_PATH;
exit $NeuroDB::ExitCodes::INVALID_PATH;
}
}

Expand Down Expand Up @@ -230,7 +230,7 @@
} else {
print LOG "\n\tERROR: Post processing tools won't be run for this dataset. \n";
print LOG "--------------------------------\n";
exit $NeuroDB::ExitCodes::NO_POST_PROCESSING_TO_RUN;
exit $NeuroDB::ExitCodes::PROGRAM_EXECUTION_FAILURE;
}


Expand Down
4 changes: 2 additions & 2 deletions batch_uploads_imageuploader
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ foreach my $input (@resultsarray)
if (($type ne '.tgz') && ($type ne '.tar.gz') && ($type ne '.zip')) {
print STDERR "The file on line $counter is not of type .tgz, tar.gz, or "
. ".zip and will not be processed\n";
exit $NeuroDB::ExitCodes::UPLOADED_FILE_TYPE_FAILURE;
exit $NeuroDB::ExitCodes::FILE_TYPE_CHECK_FAILURE;
}
if (($phantom eq '') || (($phantom ne 'N') && ($phantom ne 'Y'))) {
print STDERR "Make sure the Phantom entry is filled out "
Expand All @@ -167,7 +167,7 @@ foreach my $input (@resultsarray)
if ($patientname ne '') {
print STDERR "Please leave the patient name blank for phantom "
. "entries\n";
exit $NeuroDB::ExitCodes::PNAME_PHANTOM_MISMATCH;
exit $NeuroDB::ExitCodes::PNAME_FILENAME_MISMATCH;
}
else {
$patientname = 'NULL';
Expand Down
6 changes: 3 additions & 3 deletions dicom-archive/dicomTar.pl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
$targetlocation =~ s/^(.*)\/$/$1/;
} else {
print STDERR "\nERROR: source and target must be existing directories!\n\n";
exit $NeuroDB::ExitCodes::ARG_FILE_DOES_NOT_EXIST;
exit $NeuroDB::ExitCodes::INVALID_PATH;
}

# The tar target
Expand Down Expand Up @@ -220,7 +220,7 @@
print "\nDone adding archive info into database\n" if $verbose;
} else {
print STDERR "\nThe database command failed\n";
exit $NeuroDB::ExitCodes::TARCHIVE_INSERT_FAILURE;
exit $NeuroDB::ExitCodes::INSERT_FAILURE;
}
}

Expand All @@ -232,7 +232,7 @@
my $output = system($script);
if ($output!=0) {
print STDERR "\n\tERROR: the script updateMRI_Upload.pl has failed\n\n";
exit $NeuroDB::ExitCodes::UPDATE_MRI_UPLOAD_FAILURE;
exit $NeuroDB::ExitCodes::UPDATE_FAILURE;
}
}

Expand Down
6 changes: 3 additions & 3 deletions dicom-archive/updateMRI_Upload.pl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
unless (-e $tarchive) {
print STDERR "\nERROR: Could not find archive $tarchive.\n"
. "Please, make sure the path to the archive is valid.\n\n";
exit $NeuroDB::ExitCodes::ARG_FILE_DOES_NOT_EXIST;
exit $NeuroDB::ExitCodes::INVALID_PATH;
}

################################################################
Expand All @@ -111,7 +111,7 @@
unless (-e $source_location) {
print STDERR "\nERROR: Could not find sourcelocation $source_location\n"
. "Please, make sure the sourcelocation is valid.\n\n";
exit $NeuroDB::ExitCodes::ARG_FILE_DOES_NOT_EXIST;
exit $NeuroDB::ExitCodes::INVALID_PATH;
}
################################################################
#####establish database connection if database option is set####
Expand Down Expand Up @@ -154,7 +154,7 @@
my $count = $sth->fetchrow_array;
if($count>0) {
print STDERR "\n\tERROR: the tarchive is already uploaded \n\n";
exit $NeuroDB::ExitCodes::TARCHIVE_ALREADY_UPLOADED;
exit $NeuroDB::ExitCodes::FILE_NOT_UNIQUE;
}


Expand Down
38 changes: 17 additions & 21 deletions docs/scripts_md/ExitCodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,37 @@ input error checking and setting failures). Note that not all of the possible
exit codes are used by each script, giving some room to add some later on if
needed.

Below is a list of the possible exit codes organized per script:
Below is a list of the possible exit codes:

1\. Common exit codes to most insertion scripts (exit codes from 0 to 19, 0 =
exit script with success status)
\##### ---- SECTION 1: EXIT CODES COMMON TO MOST IMAGING INSERTION SCRIPTS

2\. Exit codes from batch\_uploads\_imageuploader (exit codes from 20 to 39)
1\. Success: exit code = 0 upon success.

3\. Exit codes from batch\_uploads\_tarchive (no exit codes available yet, exit
codes will be from 40 to 59)
2\. Common input error checking and setting failures (exit codes from 1 to 19)

4\. Exit codes from dicom-archive/dicomTar.pl (exit codes from 60 to 79)
3\. Common database related failures (exit codes from 20 to 39)

5\. Exit codes from dicom-archive/updateMRI\_upload (exit codes from 80 to 99)
4\. Common configuration failures (exit codes from 40 to 59)

6\. Exit codes from DTIPrep/DTIPrep\_pipeline.pl (exit codes from 100 to 119)
5\. Common file manipulation failures (exit codes from 60 to 79)

7\. Exit codes from DTIPrep/DTIPrepRegister.pl (exit codes from 120 to 139)
6\. Common other generic failures (exit codes from 80 to 149)

8\. Exit codes from uploadNeuroDB/imaging\_upload\_file.pl (exit codes from 140
to 159)
\##### ---- SECTION 2: SCRIPT SPECIFIC EXIT CODES NOT COVERED IN SECTION 1

9\. Exit codes from uploadNeuroDB/NeuroDB/ImagingUpload.pm (exit codes from 160
to 179)
7\. Exit codes from batch\_uploads\_imageuploader (exit codes from 150 to 159)

10\. Exit codes from uploadNeuroDB/NeuroDB/MRIProcessingUtility.pm (exit codes
from 180 to 199)
8\. Exit codes from DTIPrep/DTIPrepRegister.pl (exit codes from 160 to 169)

11\. Exit codes from uploadNeuroDB/minc\_deletion.pl (exit codes from 200 to 219)
9\. Exit codes from uploadNeuroDB/NeuroDB/ImagingUpload.pm (exit codes from
170 to 179)

12\. Exit codes from uploadNeuroDB/minc\_insertion.pl (exit codes from 220 to 239)
11\. Exit codes from uploadNeuroDB/minc\_insertion.pl (exit codes from 180 to 189)

13\. Exit codes from uploadNeuroDB/register\_processed\_data.pl (exit codes from
240 to 259)
12\. Exit codes from uploadNeuroDB/tarchiveLoader (exit codes from 190 to 199)

14\. Exit codes from uploadNeuroDB/tarchiveLoader (exit codes from 260 to 279)
13\. Exit codes from uploadNeuroDB/NeuroDB/bin/minc2jiv.pl (exit codes from 200
to 210)

# LICENSING

Expand Down
Loading