Fix env checks

This commit is contained in:
2024-07-31 21:59:20 -04:00
parent a672b66e1a
commit df86497aed

View File

@@ -40,19 +40,19 @@ function varargout = EASYconsole(varargin)
fprintf('This script name: %s\n', easyFileName); fprintf('This script name: %s\n', easyFileName);
% Set scansDir (project scans directory) intelligently % Set scansDir (project scans directory) intelligently
if exist('PROJECT_SCANS_DIR', 'var') && ~isempty(getenv('PROJECT_SCANS_DIR')) if ~isempty(getenv('PROJECT_SCANS_DIR'))
scansDir=fullfile(getenv('PROJECT_SCANS_DIR')); scansDir=fullfile(getenv('PROJECT_SCANS_DIR'));
if exist(scansDir, 'dir') if exist(scansDir, 'dir')
fprintf('Using scans directory: %s from environment variable PROJECT_SCANS_DIR\n', scansDir); fprintf('Using scans directory: %s from environment variable PROJECT_SCANS_DIR\n', scansDir);
disp('This usually indicates that we are in module mode'); disp('This usually indicates that we are in module mode');
if ~exist('PROJECT', 'var') || isempty(getenv('PROJECT')) if isempty(getenv('PROJECT'))
dirInfo=fileparts(scansDir); dirInfo=fileparts(scansDir);
project=dirInfo.name; project=dirInfo.name;
end end
else else
disp('WARNING: PROJECT_SCANS_DIR does not exist'); disp('WARNING: PROJECT_SCANS_DIR does not exist');
end end
elseif exist('PROJECT', 'var') && ~isempty(getenv('PROJECT')) % for standalone mode elseif ~isempty(getenv('PROJECT')) % for standalone mode
% scansDir=fullfile(parentDir, '..', '..', 'scans', getenv('PROJECT') 'out', 'easy', getenv('PROJECT')); % scansDir=fullfile(parentDir, '..', '..', 'scans', getenv('PROJECT') 'out', 'easy', getenv('PROJECT'));
scansDir=fullfile(parentDir, '..', '..', 'scans', getenv('PROJECT')); scansDir=fullfile(parentDir, '..', '..', 'scans', getenv('PROJECT'));
project=getenv('PROJECT'); project=getenv('PROJECT');
@@ -97,14 +97,14 @@ function varargout = EASYconsole(varargin)
end end
% User sanity check and warning % User sanity check and warning
if exist('PROJECT_USER', 'var') && ~isempty(getenv('PROJECT_USER')) if ~isempty(getenv('PROJECT_USER'))
if ~equal(getenv('PROJECT_USER'), userName) if ~equal(getenv('PROJECT_USER'), userName)
disp("WARNING: PROJECT_USER does not match the current namespace"); disp("WARNING: PROJECT_USER does not match the current namespace");
end end
end end
% Allow module to override hardcoded default EASY directory % Allow module to override hardcoded default EASY directory
if exist('EASY_DIR','var') && ~isempty(getenv('EASY_DIR')) if ~isempty(getenv('EASY_DIR'))
EASY_DIR=fullfile(getenv('EASY_DIR')); EASY_DIR=fullfile(getenv('EASY_DIR'));
if ~strcmp(easyDir, EASY_DIR) % sanity check if ~strcmp(easyDir, EASY_DIR) % sanity check
disp("WARNING: EASY_DIR does not match this script's hardcoded EASY location"); disp("WARNING: EASY_DIR does not match this script's hardcoded EASY location");
@@ -116,7 +116,7 @@ function varargout = EASYconsole(varargin)
fprintf('Using EASY script directory: %s from hardcoded default\n', easyDir); fprintf('Using EASY script directory: %s from hardcoded default\n', easyDir);
end end
if (exist('EASY_RESULTS_DIR', 'var') && ~isempty(getenv('EASY_RESULTS_DIR'))) if ~isempty(getenv('EASY_RESULTS_DIR')))
easyResultsDir=fullfile(getenv('EASY_RESULTS_DIR')); easyResultsDir=fullfile(getenv('EASY_RESULTS_DIR'));
fprintf('Using output directory: %s from environment variable EASY_RESULTS_DIR\n', easyResultsDir); fprintf('Using output directory: %s from environment variable EASY_RESULTS_DIR\n', easyResultsDir);
else else
@@ -129,7 +129,7 @@ function varargout = EASYconsole(varargin)
end end
end end
if exist('MASTER_PLATE_FILE', 'var') && ~isempty(getenv('MASTER_PLATE_FILE')) if ~isempty(getenv('MASTER_PLATE_FILE'))
masterPlateFile=fullfile(getenv('MASTER_PLATE_FILE')); masterPlateFile=fullfile(getenv('MASTER_PLATE_FILE'));
fprintf('Using drug media file: %s from environment variable MASTER_PLATE_FILE\n', masterPlateFile); fprintf('Using drug media file: %s from environment variable MASTER_PLATE_FILE\n', masterPlateFile);
else else
@@ -143,7 +143,7 @@ function varargout = EASYconsole(varargin)
end end
end end
if exist('DRUG_MEDIA_FILE', 'var') && ~isempty(getenv('DRUG_MEDIA_FILE')) if ~isempty(getenv('DRUG_MEDIA_FILE'))
drugMediaFile=fullfile(getenv('DRUG_MEDIA_FILE')); drugMediaFile=fullfile(getenv('DRUG_MEDIA_FILE'));
fprintf('Using drug media file: %s from environment variable DRUG_MEDIA_FILE\n', drugMediaFile); fprintf('Using drug media file: %s from environment variable DRUG_MEDIA_FILE\n', drugMediaFile);
else else