source: an2_update.m @ 37

Last change on this file since 37 was 37, checked in by tjniskan, 11 years ago
  • Renamed analyze2.m to aedes.m
  • Changed all references to "Analyze2" -> "Aedes" (hopefully I didn't

break anything...)

  • Added some nifti-tools to misclib
  • Fixed bug in an2_readfid.m that occurred when reading EPI-data

(thanks Teemu)

M an2_export_gui.m
D analyze2.m
M an2_getfilefilter.m
M an2_calc_wait.m
A misclib/nifti4dto3d.m
A misclib/nifti3dto4d.m
A misclib/filter_fmri_data.m
M misclib/dcm_info.m
M an2_cellwrite.m
M an2_revision.m
M startup.m
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
D about_analyze2.png
M an2_resviewer.m
M an2_maptool.m
A aedes.m
M an2_helpabout.m
M plugins/save_roi_as_mask.m
M plugins/calculate_t2_map.m
M an2_inputdlg.m
M an2_readctdata.m
M an2_readfid.m
M an2_readfidprefs.m
M an2_readtab.m
M an2_check_updates.m
A about_aedes.png
M an2_saveres.m
M an2_editstack.m
M an2_errordump.m
M an2_update.m
M an2_write_nifti.m

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

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