Changeset 157


Ignore:
Timestamp:
01/20/20 14:58:37 (5 years ago)
Author:
bduin
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • prextra/toolbox_export.m

    r156 r157  
    11%TOOLBOX_EXPORT Prepare toolbox for export, archive and send to website
    22%
    3 % TOOLBOX_EXPORT(TOOLBOX,COPYFLAG,EXPORTDIR,EXCLUDE)
    4 %
    5 % zip and copy TOOLBOX to PRTools server and archive in EXPORTDIR. In case
     3% TOOLBOX_EXPORT(TOOLBOX,COPYFLAG,EXCLUDE,ARCHIVE)
     4%
     5% zip and copy TOOLBOX to PRTools server and archive in ARCHIVE. In case
    66% COPYFLAG is false (default) copying to the server is skipped.
    77%
     
    99% updated. In addition a TOOLBOX_version.txt file is created or updated on
    1010% the server. Sub-directories of TOOLBOX given as a cell array in EXCLUDE
    11 % will not be stored in the zip-file. Other sub-directories will compressed
    12 % as they are. In the main toolbox directory just the m-files are used.
     11% will not be stored in the zip-file. Other sub-directories will be
     12% compressed as they are. In the main toolbox directory just the m-files
     13% are used.
    1314%
    1415% TOOLBOX should be in the search path and has to be given by the name
    1516% only.
    1617%
    17 % The default for EXPORTDIR is 'K:\insy\PRLab\Matlab\prtools_export'
     18% The default for ARCHIVE is the prtools_export dir in the group server:
     19% \\srv051.tudelft.net\staff-groups-ewi\insy\PRLab\Matlab\prtools_export
    1820
    1921% Copyright: R.P.W. Duin
    2022
    21 function toolbox_export(toolbox,copyflag,exportdir,exclude)
    22 
    23 if nargin < 4, exclude = []; end
    24 if nargin < 3 || isempty(exportdir)
    25   exportdir = 'K:\insy\PRLab\Matlab\prtools_export';
    26 end
     23function toolbox_export(toolbox,copyflag,exclude,archive)
     24
     25if nargin < 4 || isempty(archive)
     26  archive = '\\srv051.tudelft.net\staff-groups-ewi\insy\PRLab\Matlab\prtools_export';
     27end
     28if nargin < 3, exclude = []; end
    2729if nargin < 2 || isempty(copyflag); copyflag = false; end
    2830if ischar(exclude), exclude = {exclude}; end
     31
     32if exist(archive,'dir') ~= 7
     33  error(['Archive directory .\insy\PRLab\Matlab\prtools_export not found.' ...
     34    newline 'Define it in the ARCHIVE parameter.'])
     35end
    2936
    3037% check toolbox
    3138s = which([toolbox '/Contents.m']);
    3239if isempty(s)
    33   error(['Toolbox ' toolbox ' is not found or has no Contents.m file']);
     40  error(['Toolbox ' toolbox ' is not found in the path or it has no proper Contents.m file']);
    3441end
    3542
     
    3744zipdir = fullfile(fileparts(which(mfilename)),'tmp');
    3845makedir(zipdir);
     46if exist(fullfile(zipdir,toolbox),'dir') == 7
     47  rmdir(fullfile(zipdir,toolbox),'s');
     48end
    3949
    4050% get names and version
    4151today           = datestr(date,'ddmmmyy');
    42 toolboxpath     = fileparts(which(fullfile(toolbox,'Contents')));
    43 [~,toolboxname] = fileparts(toolboxpath);
    44 toolboxver      = ver(toolboxpath);
     52toolboxdir     = fileparts(which(fullfile(toolbox,'Contents')));
     53[~,toolboxname] = fileparts(toolboxdir);
     54toolboxver      = ver(toolboxdir);
    4555
    4656% get and set possibly new version number in Content file
     
    4959if isempty(pver_new)
    5060  pver_new = toolboxver(end).Version;
    51 end
    52 set_version_in_Contents(toolboxpath,pver_new);
     61else
     62  set_version_in_Contents(toolboxdir,pver_new);
     63end
     64
     65% use a copy of TOOLBOX for cleaning and compression
     66disp('    Copying, cleaning and compression make take some time ...')
     67copyfile(toolboxdir,fullfile(zipdir,toolbox));
     68toolboxdir = fullfile(zipdir,toolbox);
    5369
    5470% zip
    5571zfilename = [toolbox pver_new '_' today '.zip'];
    5672ztoolbox  = fullfile(zipdir,zfilename);
    57 sdir      = dirnames(toolboxpath);
     73sdir      = dirnames(toolboxdir);
     74for j=1:numel(sdir) % remove all hidden dirs (.svn)
     75  rmdir(fullfile(fullfile(toolboxdir,sdir{j}),'.svn'),'s');
     76end
    5877if ~isempty(exclude)
    5978  for j=1:numel(exclude)
    6079    n = strmatch(exclude{j},sdir);
    6180    if isempty(n)
    62       warning(['Subdirectory ' exclude{j} ' does not exist and is skipped'])
     81      warning(['Subdirectory ' exclude{j} ' does not exist. Exclusion is skipped'])
    6382    else
    6483      sdir(n) = [];
     
    6685  end
    6786end
    68 zip(ztoolbox,[{'*.m'} sdir{:}],toolboxpath);
    69 
    70 % create specific archdir for this toolbox
    71 archdir = fullfile(exportdir,toolboxname);
     87zip(ztoolbox,[{'*.m'} sdir{:}],toolboxdir);
     88
     89% use or create specific archdir for this toolbox
     90archdir = fullfile(archive,toolboxname);
    7291makedir(archdir);
    7392
     
    87106  [s,mess] = copyfile(ztoolbox,archdir);
    88107  if s
    89     disp(['    export files have been backed-up in ' archdir])
     108    disp(['    Export files have been archived in' newline '    ' archdir])
    90109  else
    91110    disp(mess);
Note: See TracChangeset for help on using the changeset viewer.