Skip to content

Commit

Permalink
allow to set username programatically
Browse files Browse the repository at this point in the history
The username can no be set programmatically by calling arCreateInitUser.
  • Loading branch information
niklasneubrand committed Oct 17, 2024
1 parent ac42bc4 commit beaa579
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
46 changes: 17 additions & 29 deletions arFramework3/Subfunctions/arCheck.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% docontinue = arCheck
% arCheck checks the system's setup, sets Matlab paths via addpath and
% configure sundials
% configure sundials
%
% docontinue true if the function is finished, false otherwise

Expand All @@ -9,7 +9,7 @@

symbtool = ver('symbolic');
if(~isempty(symbtool) && verLessThan('symbolic', '5.5'))
error('MUPAD symbolic toolbox version >= 5.5 required');
error('MUPAD symbolic toolbox version >= 5.5 required');
end

ar_path = fileparts(which('arInit.m'));
Expand All @@ -23,7 +23,7 @@
warning('It seems that you specified the path to d2d using local paths, e.g. by addpath(''arFramework3''). The path is now switch to a gloabl one.')
path_id = ~cellfun(@isempty,regexp(matpath,[arFolderName{end} '$']));
if(~all(path_id)==0)
rmpath(matpath{path_id})
rmpath(matpath{path_id})
end
addpath(ar_path)
end
Expand Down Expand Up @@ -84,16 +84,16 @@
addpath([ar_path '/ProjectTemplate'])
end
if(exist('arFitLhsBwCluster','file') == 0)
addpath([ar_path '/BwGrid']);
addpath([ar_path '/BwGrid']);
end
if(exist('arNEB','file') == 0)
addpath([ar_path '/NEB']);
addpath([ar_path '/NEB']);
end
if(exist('arExportPEtab','file') == 0)
addpath([ar_path '/ImportExport']);
addpath([ar_path '/ImportExport']);
end
if(exist('model_template_HillFunctions.def','file') == 0)
addpath([ar_path '/ProjectTemplate']);
addpath([ar_path '/ProjectTemplate']);
end


Expand Down Expand Up @@ -221,7 +221,7 @@
end

savepath

%% CVODES

% uncompress and expand CVODES
Expand Down Expand Up @@ -259,44 +259,32 @@

%% check Windows libraries for pthread-win32
if(ispc)
% if(exist(['.\pthreadGC2_',mexext,'.dll'],'file')==0)
% if(exist(['.\pthreadGC2_',mexext,'.dll'],'file')==0)
try
copyfile([ar_path '\ThirdParty\pthreads-w32_2.9.1\dll\' mexext '\pthreadGC2.dll'], 'pthreadGC2.dll');
catch ERR % occurs (and can be ignored), if dll has been copied previously, is still loaded and therefore replacement is blocked by Windows OS
disp(ERR.message)
end
% end
% if(exist(['.\pthreadVC2_',mexext,'.dll'],'file')==0)
% end
% if(exist(['.\pthreadVC2_',mexext,'.dll'],'file')==0)
try
copyfile([ar_path '\ThirdParty\pthreads-w32_2.9.1\dll\' mexext '\pthreadVC2.dll'], 'pthreadVC2.dll');
catch ERR % occurs (and can be ignored), if dll has been copied previously, is still loaded and therefore replacement is blocked by Windows OS
disp(ERR.message)
end
% end
% end
end

%% user name

% check if arInitUser.m exists and create the file if necessary
if exist('arInitUser.m','file')==0
fprintf(1,'\n%s\n\n','Welcome to Data 2 Dynamics Software');
user = '';
while isempty(user)
user = input('Please enter your full name (e.g. John Doe)\n-> ','s');
end
fid = fopen([ar_path '/arInitUser.m'],'w');
if(fid==-1)
error('could not write file %s!', [ar_path '/arInitUser.m']),
fprintf(1,'\n%s\n\n','Welcome to Data 2 Dynamics Software');
user = '';
while isempty(user)
user = input('Please enter your full name (e.g. John Doe)\n-> ','s');
end
fprintf(fid,'%s\n','% initialize user settings');
fprintf(fid,'\n%s\n','function arInitUser');
fprintf(fid,'\n%s\n','global ar');
fprintf(fid,'\n%s%s%s','ar.config.username = ''',user,''';');
fprintf(fid,'\n%s%s%s','ar.config.comment_string = ''//'';');
fclose(fid);
fprintf(1,'\n%s\n','Initialization successful');
fprintf(1,'Please note that you can set additional default options in arInitUser.m\n' );
rehash path
arCreateInitUser(user);
end

docontinue = true;
20 changes: 20 additions & 0 deletions arFramework3/Subfunctions/arCreateInitUser.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function arCreateInitUser(userName)

ar_path = fileparts(which('arInit.m'));

fid = fopen([ar_path '/arInitUser.m'], 'w');
if(fid==-1)
error('could not write file %s!', [ar_path '/arInitUser.m']),
end
fprintf(fid,'%s\n','% initialize user settings');
fprintf(fid,'\n%s\n','function arInitUser');
fprintf(fid,'\n%s\n','global ar');
fprintf(fid,'\n%s%s%s','ar.config.username = ''',userName,''';');
fprintf(fid,'\n%s%s%s','ar.config.comment_string = ''//'';');
fclose(fid);
fprintf(1,'\n%s\n','Initialization successful');
fprintf(1,'Please note that you can set additional default options in arInitUser.m\n' );

rehash path
end

0 comments on commit beaa579

Please sign in to comment.