source: an2_update.m @ 78

Last change on this file since 78 was 78, checked in by tjniskan, 10 years ago
  • Moved fMRI related plugins to their own subdirectories
  • Created a subdirectory for map calculation plugins and added a few

basic plugins for those. At the moment these plugins do not support
masking etc. and I didn't test them at all so be cautious...

  • Made a minor memory optimation to an2_readfid.m
  • Fixed a few issues in files related updating via SVN
  • Disabled some annoying warnings that Matlab R2008a and higher

generate from uitree and uitreenode functions inan2_juigetfiles.m

  • Coded something minor to an2_maptool.m. This is still stub and does

not work at all. Please don't try to use it.

  • Fixed a bug that caused Aedes to fail without generating an error

when reading VNMR FID-files that don't have PROCPAR in the same folder.

  • Fixed a javaFrame -warning (with R2008a and higher) in aedes.m

M an2_revision.m
M an2_data_read.m
M an2_maptool.m
M aedes.m
D plugins/calculate_t2_map.m
D plugins/calculate_t1r_map.m
D plugins/basic_fmri_analysis.m
D plugins/resting_state_fc.m
A plugins/fmri_plugins
A plugins/fmri_plugins/basic_fmri_analysis.m
A plugins/fmri_plugins/resting_state_fc.m
A plugins/map_plugins
A plugins/map_plugins/t2.m
A plugins/map_plugins/t1_3_parameter_fit.m
A plugins/map_plugins/t1_saturation_recovery.m
A plugins/map_plugins/t1_rho.m
A plugins/map_plugins/t2_rho.m
A plugins/map_plugins/t1_inversion_recovery.m
M an2_readfid.m
M an2_check_updates.m
M an2_juigetfiles.m
M an2_update.m

  • Property svn:executable set to *
File size: 8.0 KB
RevLine 
[25]1function done=an2_update(opt)
[37]2% AN2_UPDATE - Aedes update tool
[25]3%
4% Synopsis:
5%       done=an2_update(opt)
6%
7% Description:
8%       
9%
10% Examples:
11%       
12%
13% See also:
[37]14%       AN2_CHECK_UPDATES, AN2_REVISION, AEDES
[25]15
[37]16% This function is a part of Aedes - A graphical tool for analyzing
[36]17% medical images
[25]18%
[36]19% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
20%
[45]21% Department of Physics, Department of Neurobiology
[39]22% University of Kuopio, FINLAND
[36]23%
24% This program may be used under the terms of the GNU General Public
25% License version 2.0 as published by the Free Software Foundation
26% and appearing in the file LICENSE.TXT included in the packaging of
27% this program.
28%
29% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
30% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
[25]31
[36]32
[25]33done = false;
34ShowChangeLog = false;
35
36if nargin==0
37  opt = 'semiprompt';
38end
39
40% Check if updates are available
[78]41[isUpdateAvailable,HeadRev,WorkingCopyRev,error_msg]=an2_check_updates();
[25]42
43if isUpdateAvailable
44  if strcmpi(opt,'noprompt')
[78]45    fprintf(1,'Updating from revision %d to %d\n',...
46      WorkingCopyRev,HeadRev)
[25]47  elseif any(strcmpi(opt,{'prompt','semiprompt'}))
[78]48    % Prompt for updates
49    dialog_str = {'Updates for Aedes are available.',...
50      '',...
51      ['Your current revision: ',num2str(WorkingCopyRev)],...
52      ['The latest revision: ',num2str(HeadRev)],...
53      '',...
54      'Do you want to install updates now?'};
55    resp=questdlg(dialog_str,'Updates available. Install updates now?',...
56      'Yes','No','Yes');
57    if strcmpi(resp,'No')
58      done = [];
59      return
60    end
61    [cwh,txh]=an2_calc_wait('Installing updates...');
[25]62  end
63elseif isempty(HeadRev)
64  % Something wrong with SVN
65  if strcmpi(opt,'prompt')
[78]66    h=warndlg({'Could not check updates. Do you have hetwork access and is SVN properly installed?','',...
67      'The following error was encountered:','',...
68      error_msg},...
69      'Could not check updates','modal');
70    uiwait(h);
71    return
[25]72  elseif any(strcmpi(opt,{'noprompt','semiprompt'}))
[78]73    fprintf(1,'Could not check updates.\n');
74    fprintf(1,'The following error was encountered:\n');
75    fprintf(1,error_msg);
76    return
[25]77  end
78else
[37]79  % No updates available, Aedes is up-to-date. Don't display anything if
[25]80  % semiprompt mode is selected
81  if strcmpi(opt,'prompt')
[78]82    h=helpdlg('No updates available. Aedes is up-to-date.',...
83      'Aedes up-to-date');
84    uiwait(h);
[25]85  elseif strcmpi(opt,'noprompt')
[78]86    fprintf(1,'No updates available. Aedes is up-to-date.\n');
[25]87  end
88  return
89end
90
91
92% Update to the latest revision
93[fp,fn,fe]=fileparts(mfilename('fullpath'));
94if isunix
[29]95  [s,w]=unix(['svn up "',fp,'"']);
[25]96  C=textscan(w,'%s','delimiter','\n');
97  C=C{:};
98elseif ispc
[29]99  [s,w]=dos(['svn up "',fp,'"']);
[25]100  C=textscan(w,'%s','delimiter','\n');
101  C=C{:};
102else
[78]103  % Mac OSX
104  [s,w]=unix(['svn up "',fp,'"']);
105  C=textscan(w,'%s','delimiter','\n');
106  C=C{:};
[25]107end
108if s~=0
109  try
[78]110    delete(cwh)
[25]111  catch
112  end
113  if any(strcmpi(opt,{'prompt','semiprompt'}))
[78]114    h=errordlg({'Update failed because of following error:',...
115      C{:}},...
116      'Update failed','modal');
117    uiwait(h);
118    return
[25]119  elseif strcmpi(opt,'noprompt')
[78]120    fprintf(1,'\n********************* ERROR ***********************\n')
121    fprintf(1,'Update failed because of following error:\n');
122    fprintf(1,'%s\n',C{:});
123    fprintf(1,'***************************************************\n')
124    return
[25]125  end
126end
127
128try
129  set(txh,'String','Installing updates...done')
130  pause(0.5)
131  delete(cwh)
132catch
133end
134
135
136% Check for conflict or merge
137c_ind = [];
138g_ind = [];
139for ii=1:length(C)
140  if strncmpi(C{ii},'C  ',3)
[78]141    % Conflict
142    c_ind(end+1)=ii;
[25]143  elseif strncmpi(C{ii},'G  ',3)
[78]144    % Merge
145    g_ind(end+1)=ii;
[25]146  end
147end
148
149%%%%%%%%%%%%%%%%%%
[29]150%c_ind = [];
151%g_ind = [];
[25]152%%%%%%%%%%%%%%%%%%
153
154%% Everything went ok ------------------------
155if isempty(c_ind) && isempty(g_ind)
156  % Update successful
157  if any(strcmpi(opt,{'prompt','semiprompt'}))
[78]158    resp=questdlg({['Updated successfully to revision ',num2str(HeadRev),'.'],...
159      '',...
160      ['You can use "View Details..." the view the changelog.']},...
161      'Update successful','OK','View Details...','View Details...');
162    if strcmpi(resp,'View Details...')
163      ShowChangeLog = true;
164    else
165      ShowChangeLog = false;
166    end
[25]167  elseif strcmpi(opt,'noprompt')
[78]168    fprintf(1,'Updated successfully to revision %d\n',HeadRev);
169   
170    % Echo the update information to the command window
171    fprintf(1,'%s\n',C{:});
172    fprintf(1,'Update complete.\n');
[25]173  end
174 
175  % Clear functions just in case...
176  clear functions
177 
178  done = true;
179 
180  % Show the Change log and information
181  if ShowChangeLog
[78]182    if isunix
183      [s,w] = unix(sprintf('svn log "%s" -r%d:%d',...
184        fp,HeadRev,WorkingCopyRev+1));
185      if s~=0
186       
187      end
188    elseif ispc
189      [s,w] = dos(sprintf('svn log "%s" -r%d:%d',...
190        fp,HeadRev,WorkingCopyRev+1));
191      if s~=0
192       
193      end
194    else
195     
196    end
197    W = textscan(w,'%s','delimiter','\n');
198    W=W{:};
199    web(['text://',...
200      '<title>Update information and changelog</title>',...
201      sprintf('<h1>Updated Aedes successfully to revision %d</h1>',...
202      HeadRev),...
203      sprintf('<h2>Updated files from revision %d to %d</h2>',...
204      WorkingCopyRev,HeadRev),...
205      sprintf('%s<br>',C{:}),...
206      '<br>',...
207      sprintf('<h2>Changelog from revision %d to %d</h2>',...
208      WorkingCopyRev,HeadRev),...
209      sprintf('%s<br>',W{:})]);
[25]210  end
211 
212  % Merges and/or conflicts detected ----------
213elseif ~isempty(c_ind) || ~isempty(g_ind)
214 
215  % Echo the update information to the command window
216  fprintf(1,'%s\n',C{:});
217  fprintf(1,'Update complete.\n');
218 
219  % List of files with conflicts
220  c_files = C(c_ind);
221 
222  % List of files with merges
223  g_files = C(g_ind);
224 
225  % Update successful but with conflicts and/or merges
226  if isempty(c_ind)
[78]227    % Only merges
228    fprintf(1,'\n********************* WARNING *********************\n')
229    fprintf(1,['Updated to revision %d but with errors.\n',...
230      'The following files contain MERGES:\n'],HeadRev)
231    fprintf(1,'%s\n',g_files{:})
232    fprintf(1,'***************************************************\n')
233    if any(strcmpi(opt,{'prompt','semiprompt'}))
234      h = warndlg({['Updated to revision ',num2str(HeadRev),' but with errors.'],...
235        '',...
236        'The following files contain MERGES:',...
237        '',...
238        g_files{:},...
239        ''},...
240        'Updated with errors','modal');
241      uiwait(h);
242    end
243   
[25]244  elseif isempty(g_ind)
[78]245    % Only conflicts
246    fprintf(1,'\n********************* WARNING *********************\n')
247    fprintf(1,['Updated to revision %d but with errors.\n',...
248      'The following files contain CONFLICTS:\n'],HeadRev)
249    fprintf(1,'%s\n',g_files{:})
250    fprintf(1,'***************************************************\n')
251    if any(strcmpi(opt,{'prompt','semiprompt'}))
252      h = warndlg({['Updated to revision ',num2str(HeadRev),' but with errors.'],...
253        '',...
254        'The following files contain CONFLICTS:',...
255        '',...
256        c_files{:},...
257        ''},...
258        'Updated with errors','modal');
259      uiwait(h);
260    end
261   
[25]262  else
[78]263    % Both conflicts and merges
264    fprintf(1,'\n********************* WARNING *********************\n')
265    fprintf(1,['Updated to revision %d but with errors.\n',...
266      'The following files contain CONFLICTS:\n'],HeadRev)
267    fprintf(1,'%s\n',c_files{:})
268    fprintf(1,'\nThe following files contain MERGES:\n')
269    fprintf(1,'%s\n',g_files{:})
270    fprintf(1,'***************************************************\n')
271    if any(strcmpi(opt,{'prompt','semiprompt'}))
272      h = warndlg({['Updated to revision ',num2str(HeadRev),' but with errors.'],...
273        '',...
274        'The following files contain CONFLICTS:',...
275        '',...
276        c_files{:},...
277        '',...
278        'The following files contain MERGES:',...
279        '',...
280        g_files{:},...
281        ''},...
282        'Updated with errors','modal');
283      uiwait(h);
284    end
[25]285  end
286 
287  % Clear functions just in case...
288  clear functions
289 
290  done = true;
291 
292end
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008