source: an2_check_updates.m @ 45

Last change on this file since 45 was 45, checked in by tjniskan, 11 years ago
  • Changed a small thing in license notices

M an2_export_gui.m
M an2_cellsprintf.m
M an2_getfilefilter.m
M an2_calc_wait.m
M an2_smiswrite.m
M misclib/spectrsum.m
M misclib/shiftind.m
M misclib/nifti4dto3d.m
M misclib/nifti3dto4d.m
M misclib/dcm_info.m
M misclib/addicon.m
M misclib/makelcmraw.m
M an2_check_file_exist.m
M an2_iseven.m
M an2_cellwrite.m
M an2_wbar.m
M an2_rot3d.m
M an2_readfdf.m
M an2_revision.m
M an2_viewprocpar.m
M an2_checkcthdr.m
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
M an2_smisread.m
M an2_resviewer.m
M an2_maptool.m
M aedes.m
M an2_helpabout.m
M an2_res2table.m
M an2_copy_roi.m
M plugins/save_roi_as_mask.m
M plugins/write_difference_images.m
M plugins/plot_profile.m
M plugins/calculate_t2_map.m
M plugins/calculate_t1r_map.m
M plugins/view_kspace.m
M plugins/copy_data_to_workspace.m
M plugins/take_snapshot.m
M an2_inputdlg.m
M an2_roi_copy_gui.m
M an2_readctdata.m
M an2_readfid.m
M an2_readfidprefs.m
M an2_readtab.m
M an2_check_updates.m
M an2_killfigs.m
M an2_roi_stats.m
M an2_saveres.m
M an2_rotateflip.m
M an2_juigetfiles.m
M an2_gui_defaults.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: 3.2 KB
Line 
1function [isUpdateAvailable,HeadRev,WorkingCopyRev]=an2_check_updates()
2% AN2_CHECK_UPDATES - Check if Aedes updates are available
3%
4% Synopsis:
5%       [isUpdateAvailable,HeadRev,WorkingCopyRev] = an2_check_updates()
6%
7% Description:
8%       Checks if there are updates available for Aedes. The
9%       "isUpdateAvailable" output argument is true if the head revision number
10%   in SVN repository is larger than working copy revision. If the
11%   "HeadRev" output argument is -1, there is a problem with the network.
12%   If "HeadRev" is empty, there is a problem running SVN commands.
13%
14% Examples:
15%       
16%
17% See also:
18%       AEDES, AN2_UPDATE
19
20% This function is a part of Aedes - A graphical tool for analyzing
21% medical images
22%
23% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
24%
25% Department of Physics, Department of Neurobiology
26% University of Kuopio, FINLAND
27%
28% This program may be used under the terms of the GNU General Public
29% License version 2.0 as published by the Free Software Foundation
30% and appearing in the file LICENSE.TXT included in the packaging of
31% this program.
32%
33% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
34% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
35
36
37
38isUpdateAvailable = false;
39HeadRev = [];
40
41% Get current revision and repository URL
42[rev,repo,workingcopy] = an2_revision;
43if isempty(repo)
44  WorkingCopyRev = rev;
45  return
46end
47WorkingCopyRev = rev;
48
49% Get head repository revision
50HeadRev=l_GetHeadRevision(repo);
51if isempty(HeadRev)
52  % Something wrong with running SVN commands. Perhaps SVN is not
53  % installed?
54elseif HeadRev<0
55  % Something wrong with detecting network. Perhaps not inside University
56  % network or not connected to the network at all...
57else
58  if rev<HeadRev
59        isUpdateAvailable = true;
60  end
61end
62 
63 
64  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65  % Get Head Repository Revision
66  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67  function [HeadRev,msg]=l_GetHeadRevision(repo_url)
68 
69  HeadRev = [];
70  msg = '';
71 
72  % Try to determine if the computer is connected to the network and is
73  % inside University network... If this checking fails and the user has no
74  % network, the svn will wait for timeout...
75  % Check if we are inside university firewalls
76  if isunix
77        % Unix/Linux
78        [s,w]=unix('ifconfig');
79        if ~isempty(w)
80          ind = strfind(w,'inet addr:');
81          if ~isempty(ind)
82                try
83                  if ~strcmpi(w(ind(1)+10:ind(1)+16),'193.167')
84                        HeadRev = -1;
85                        return
86                  end
87                catch
88                  HeadRev = -1;
89                  return
90                end
91          else
92                HeadRev = -1;
93                return
94          end
95        else
96          HeadRev = -1;
97          return
98        end
99  elseif ispc
100        % Windows
101        [s,w]=dos('ipconfig');
102        if isempty(findstr(w,'uku.fi'))
103          HeadRev = -1;
104          return
105        end
106  else
107        % Mac OS X
108  end
109 
110 
111  % Try to determine the head revision in svn
112  if isunix
113        % Unix/Linux
114        [s,w] = unix(['svn info ',repo_url]);
115        if s~=0
116          return
117        end
118  elseif ispc
119        % Windows
120        [s,w] = dos(['svn info ',repo_url]);
121        if s~=0
122          return
123        end
124  else
125        % Mac OS X
126  end
127 
128  % Scan the lines from the output
129  C=textscan(w,'%s','delimiter','\n');
130  if ~isempty(C)
131        C=C{:};
132  else
133        return
134  end
135 
136  % Get revision line
137  rev_ind = find(strncmpi(C,'Revision:',4));
138  if ~isempty(rev_ind)
139        rev_str = C{rev_ind};
140  else
141        return
142  end
143  HeadRev=str2num(rev_str(11:end));
144 
145 
Note: See TracBrowser for help on using the repository browser.

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