Skip to content

Commit f6a37af

Browse files
Merge pull request #290 from guzman-raphael/package-main
Pull into prompts GHToolbox dependency handling
2 parents 1772969 + 2c263f0 commit f6a37af

File tree

5 files changed

+36
-15
lines changed

5 files changed

+36
-15
lines changed

+dj/setup.m

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,40 @@ function setup(varargin)
2929
try
3030
ghtb.require(requiredToolboxes, 'prompt', prompt);
3131
catch ME
32-
if strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass')
32+
installPromptMsg = {
33+
'Toolbox ''%s'' did not meet the minimum requirements.'
34+
'Would you like to proceed with an upgrade?'
35+
};
36+
if strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass') && (~prompt || strcmpi('yes',...
37+
dj.internal.ask(sprintf(sprintf('%s\n', installPromptMsg{:}), 'GHToolbox'))))
38+
% fetch
39+
tmp_toolbox = [tempname '.mltbx'];
40+
websave(tmp_toolbox, ['https://github.com/' requiredToolboxes{1}.ResolveTarget ...
41+
'/releases/download/' ...
42+
subsref(webread(['https://api.github.com/repos/' ...
43+
requiredToolboxes{1}.ResolveTarget ...
44+
'/releases/latest'], ...
45+
weboptions('Timeout', 60)), ...
46+
substruct('.', 'tag_name')) ...
47+
'/GHToolbox.mltbx'], weboptions('Timeout', 60));
48+
% install
49+
try
50+
matlab.addons.install(tmp_toolbox, 'overwrite');
51+
catch ME
52+
if strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass')
53+
matlab.addons.toolbox.installToolbox(tmp_toolbox);
54+
else
55+
rethrow(ME);
56+
end
57+
end
58+
% remove temp toolbox file
59+
delete(tmp_toolbox);
60+
% retrigger dependency validation
61+
ghtb.require(requiredToolboxes, 'prompt', prompt);
62+
elseif strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass')
3363
GHToolboxMsg = {
34-
'Toolbox ''GHToolbox'' did not meet the minimum minimum requirements.'
35-
'Please install it via instructions in '
36-
'''https://github.com/datajoint/GHToolbox'''.'
64+
'Toolbox ''GHToolbox'' did not meet the minimum requirements.'
65+
'Please proceed to install it.'
3766
};
3867
error('DataJoint:verifyGHToolbox:Failed', ...
3968
sprintf('%s\n', GHToolboxMsg{:}));

+dj/version.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function varargout = version
22
% report DataJoint version
33

4-
v = struct('major',3,'minor',3,'bugfix',2);
4+
v = struct('major',3,'minor',3,'bugfix',3);
55

66
if nargout
77
varargout{1}=v;

DataJoint.mltbx

507 Bytes
Binary file not shown.

LNX-docker-compose.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,7 @@ services:
4141
- |
4242
mkdir ~/Documents
4343
matlab -nodisplay -r "
44-
websave([tempdir 'GHToolbox.mltbx'],\
45-
['https://github.com/datajoint/GHToolbox' \
46-
'/releases/download/' subsref(webread(['https://api.github.com/repos' \
47-
'/datajoint/GHToolbox' \
48-
'/releases/latest']),\
49-
substruct('.', 'tag_name')) \
50-
'/GHToolbox.mltbx']);\
51-
matlab.addons.toolbox.installToolbox([tempdir 'GHToolbox.mltbx']);\
52-
ghtb.install('DataJoint.mltbx');\
44+
matlab.addons.toolbox.installToolbox('DataJoint.mltbx');\
5345
addpath('tests');\
5446
res=run(Main);\
5547
disp(res);\

tests/Prep.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function init(testCase)
3131
clear functions;
3232
addpath([testCase.test_root '/test_schemas']);
3333
dj.set('suppressPrompt', true);
34-
34+
disp(dj.version);
3535
curr_conn = dj.conn(testCase.CONN_INFO_ROOT.host, ...
3636
testCase.CONN_INFO_ROOT.user, testCase.CONN_INFO_ROOT.password,'',true);
3737
% create test users

0 commit comments

Comments
 (0)