diff --git a/matlab/TCV_IMAS/tcv_get_deploymentinfo.m b/matlab/TCV_IMAS/tcv_get_deploymentinfo.m index 576b97c706bbd09eee4b2b8dc38e0edc57511db7..0222db10ca255d269cca337b17ae6812d91254ba 100644 --- a/matlab/TCV_IMAS/tcv_get_deploymentinfo.m +++ b/matlab/TCV_IMAS/tcv_get_deploymentinfo.m @@ -11,45 +11,50 @@ function info = tcv_get_deploymentinfo(filepath) % Initialize output struct info = struct(); - info.repository=fileparts(filepath); - - % Check if file exists - if exist(filepath, 'file') ~= 2 - error('File does not exist: %s', filepath); - end - - % Open file for reading - fid = fopen(filepath, 'r'); - if fid == -1 - error('Could not open file: %s', filepath); - end - - % Read file line by line - while ~feof(fid) - line = fgetl(fid); - if ischar(line) - tokens = regexp(line, '^(\w+):\s(.+)$', 'tokens'); - if ~isempty(tokens) - key = tokens{1}{1}; - value = strtrim(tokens{1}{2}); - - % Store relevant fields in the struct - switch key - case 'DEPLOYMENT_DATE' - info.deployment_date = value; - case 'GIT_TAG' - info.git_tag = value; - case 'GIT_COMMIT' - info.git_commit = value; - case 'GIT_TAG_DATE' - info.git_tag_date = value; - case 'GITLAB_PROJECT_URL' - info.gitlab_project_url = value; + try + filepath=fullfile(fileparts(which(filepath)),'.this-deployment.info'); + info.repository=fileparts(filepath); + + % Check if file exists + if exist(filepath, 'file') ~= 2 + error('File does not exist: %s', filepath); + end + + % Open file for reading + fid = fopen(filepath, 'r'); + if fid == -1 + error('Could not open file: %s', filepath); + end + + % Read file line by line + while ~feof(fid) + line = fgetl(fid); + if ischar(line) + tokens = regexp(line, '^(\w+):\s(.+)$', 'tokens'); + if ~isempty(tokens) + key = tokens{1}{1}; + value = strtrim(tokens{1}{2}); + + % Store relevant fields in the struct + switch key + case 'DEPLOYMENT_DATE' + info.deployment_date = value; + case 'GIT_TAG' + info.git_tag = value; + case 'GIT_COMMIT' + info.git_commit = value; + case 'GIT_TAG_DATE' + info.git_tag_date = value; + case 'GITLAB_PROJECT_URL' + info.gitlab_project_url = value; + end end end end + + % Close the file + fclose(fid); + catch + warning('Failed to read .deployment at filepath: %s',filepath); end - - % Close the file - fclose(fid); end diff --git a/matlab/TCV_IMAS/tcv_get_ids_bolometer.m b/matlab/TCV_IMAS/tcv_get_ids_bolometer.m index 38b695fa0df51099881bc9dd281e6e5e4f21316e..58819c530a60fb5d4eee36fd6bd84fe42c95e40d 100644 --- a/matlab/TCV_IMAS/tcv_get_ids_bolometer.m +++ b/matlab/TCV_IMAS/tcv_get_ids_bolometer.m @@ -30,9 +30,7 @@ ids_bolometer_description = struct(); % Load the bolometer geometry bolo_geom=bolou_load_geometry(); -bolo_geom_gitinfo= ... - tcv_get_deploymentinfo(fullfile(fileparts(which('bolou_load_geometry')), ... - '.this-deployment.info')); +bolo_geom_gitinfo= tcv_get_deploymentinfo('bolou_load_geometry'); params_eff.data_request='\tcv_shot::top.results.bolo_u.intensity'; params_eff.trialindx=1; @@ -146,8 +144,7 @@ if status %% Code legacy for rc_gti_prep ids_bolometer.code.name = 'rc_gti_prep'; - rc_gti_prep_gitinfo= ... - tcv_get_deploymentinfo(fullfile(fileparts(which(ids_bolometer.code.name)),'.this-deployment.info')); + rc_gti_prep_gitinfo= tcv_get_deploymentinfo(ids_bolometer.code.name); ids_bolometer.code.description = ... 'rc_gti_prep, RADCAM gitlab repo, calls GTI to generate emissivity profiles with liuqe.'; ids_bolometer.code.commit=rc_gti_prep_gitinfo.git_commit;