-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathUserDirInfo.m
89 lines (82 loc) · 3.78 KB
/
UserDirInfo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function userinfo=UserDirInfo
%find user, directories and slash type
userinfo=struct('directory',[],'slash',[],'user',[],'dbldir',[],...
'syncdir',[],'mapdr',[],'servrep',[],'mapddataf',[]);
% find host name
[~,compHostName]=system('hostname');
if regexp(compHostName(end),'\W') %the system command added a carriage return ending
compHostName=compHostName(1:end-1);
end
if strfind(computer('arch'),'win')
userinfo.slash = '\';
else
userinfo.slash = '/';
end
if strcmp(compHostName,'setup_souris')
userinfo.directory = 'E:\Data\raw';
userinfo.user='Vincent';
userinfo.probemap='C:\Code\EphysDataProc\DataExport\probemaps';
userinfo.dbldir='';
userinfo.mapddataf='';
userinfo.syncdir='C:\Box Sync\Home Folder vp35\Sync\Wang Lab\Data\Ephys\export';
userinfo.MPIDir='C:\Program Files\Microsoft MPI\Bin\';
userinfo.WinDirs='C:\Windows\system32;C:\Windows';
userinfo.ypipe='C:\Code\yes.txt';
elseif strcmp(compHostName,'Neuro-Wang-01')
userinfo.directory = 'D:\Data\Vincent\ephys\raw';
userinfo.probemap='D:\Code\EphysDataProc\DataExport\probemaps';
userinfo.dbldir='';
userinfo.mapddataf='';
userinfo.MPIDir='C:\Program Files\Microsoft MPI\Bin\';
userinfo.WinDirs='C:\Windows\system32;C:\Windows';
if strcmp(getenv('username'),'Vincent')
userinfo.user='Vincent';
userinfo.syncdir='D:\Data\Vincent\Sync\Box Sync\Home Folder vp35\Sync\Wang Lab\Data\Ephys\export';
elseif strcmp(getenv('username'),'Michael')
userinfo.user='Michael';
userinfo.syncdir='';
end
userinfo.ypipe='D:\Code\yes.txt';
elseif strcmp(compHostName,'DangerZone')
if strcmp(getenv('username'),'DangerZone')
userinfo.directory = 'E:\data\Recordings\';
userinfo.user='Vincent';
userinfo.dbldir = 'E:\JDBC';
userinfo.mapddataf='vincedata';
userinfo.syncdir='E:\BoxSync\Box Sync\Home Folder vp35\Sync\CbTimingPredict\data';
end
end
% find environment directories
[~,envInfo] = system('conda info -e');
userinfo.envRootDir=cell2mat(regexp(envInfo,'(?<=spykc ).+?(?=\n)','match'));
userinfo.envScriptDir=[userinfo.envRootDir userinfo.slash 'Scripts'];
userinfo.envLibDir=[userinfo.envRootDir userinfo.slash 'Library' userinfo.slash 'bin'];
%find if one or more remote drives are mapped
[~,connlist]=system('net use');
if logical(regexp(connlist,'OK'))
%in case multiple mapped drives, add some code here
carrets=regexpi(connlist,'\r\n|\n|\r');
if isempty(regexp(connlist,':','start'))
disp('connect remote drive to place files on server')
elseif length(regexp(connlist,':','start'))==1
userinfo.servrep=connlist(regexp(connlist,':','start')-1:carrets(find(carrets>regexp(connlist,':','start'),1))-1);
userinfo.servrep=regexprep(userinfo.servrep,'[^\w\\|.|:|-'']','');
if strfind(userinfo.servrep,'MicrosoftWindowsNetwork')
userinfo.servrep=strrep(userinfo.servrep,'MicrosoftWindowsNetwork','');
end
userinfo.mapdr=userinfo.servrep(1:2);userinfo.servrep=userinfo.servrep(3:end);userinfo.servrep=regexprep(userinfo.servrep,'\\','/');
elseif length(regexp(connlist,':','start'))>=2
servs=regexp(connlist,':','start')-1;
for servl=1:length(servs)
if logical(strfind(regexprep(connlist(servs(servl):carrets(find(carrets>servs(servl),1))-1),'[^\w\\|.|:|-'']',''),...
'ccn-sommerserv.win.duke.edu'))
userinfo.servrep=regexprep(connlist(servs(servl):carrets(find(carrets>servs(servl),1))-1),'[^\w\\|.|:|-'']','');
userinfo.mapdr=userinfo.servrep(1:2);userinfo.servrep=userinfo.servrep(3:end);userinfo.servrep=regexprep(userinfo.servrep,'\\','/');
break;
end
end
end
else
[userinfo.servrep,userinfo.mapdr]=deal([]);
end
end