diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m index f37952bd40acd2c053b2104e31af08f9c65d650d..346dad077bb1f55b873781650cb25309b99e1a8b 100644 --- a/+PlotID/Publish.m +++ b/+PlotID/Publish.m @@ -29,6 +29,18 @@ if numel(figure) > 1 warning(msg); end +%read config file +try + txt = fileread('config.json'); + config = jsondecode(txt); + configError = false; +catch + msg = ['Error while reading the config file' newline,... + ' publishing on server not possible']; + warning(msg); + configError = true; +end + switch options.Location case 'local' if contains(options.ParentFolder, {'/','\'}) @@ -39,8 +51,6 @@ switch options.Location storPath = fullfile(scriptPath,options.ParentFolder); end case 'server' %from config File - txt = fileread('config.json'); - config = jsondecode(txt); storPath = config.ServerPath; case 'manual' %UI storPath = uigetdir(); @@ -60,13 +70,31 @@ end disp('Publishing started'); -%% Create a Copy of the script and User functions(optional) +%% Create a Copy of the script, config and user functions(optional) +% script PlotID.createFileCopy({[DataPaths.script,'.m']},folderName,storPath,ID, 'script'); -if options.CopyUserFCN - [fList,pList] = matlab.codetools.requiredFilesAndProducts(DataPaths.script); - % plist contains the required MATLAB Toolboxes, maybe usefull in future +% config +[fList,pList] = matlab.codetools.requiredFilesAndProducts(DataPaths.script); +if ~configError %config File must exist + % copy config file + configPath = PlotID.createFileCopy('config.json',folderName,... + storPath,ID, 'data'); + % add Metadata + config.MatlabVersion = version; + % TODO Add Toolboxes + %write config + fid = fopen(char(configPath),'w'); + txt = jsonencode(config,'PrettyPrint',true); + fprintf(fid,txt); + fclose(fid); +end + + +% user functions +if options.CopyUserFCN fList = fList(~ismember(fList,[DataPaths.script,'.m'])); % rmv script from list + fList = fList(~contains(fList,'config.json')); % rmv config.json from list fList = PlotID.removePltIdFiles(fList); % Do not copy files that are part of plot ID if ~isempty(fList) PlotID.createFileCopy(fList,folderName,storPath,ID,'userFcn'); diff --git a/example.m b/example.m index dfb5647fb28923605f61033f8e0b832b221b3333..bda38be82806b1e96ba3b6cb5e194c412ba3d5fd 100644 --- a/example.m +++ b/example.m @@ -52,6 +52,7 @@ h5write(fpath, "/y1", y1) a = 1; % example_fcn is a dummy function to show the functionality a = example_fcn(a); +%p = betacdf(0.5,1,1); % to test Toolboxes %% Plotting % This is still part of a normal script to produce plots.