83def update_dict_for_configs_afs(updict, indir):
84
85 basedir = os.path.abspath(indir)
86
87 print ('Looking for configurations in subdirectories of', indir)
88
89 types = ['minutes10', 'minutes30', 'run']
90 searchparams = [('Cosmics', 'cosmics'), ('Collisions', 'collisions'),
91 ('HeavyIons', 'heavyions')]
92
93 filepathdict = {}
94 filelist = []
95
96 for dir1, fn in searchparams:
97 print (dir1)
98 filepathdict[dir1] = {}
99 for t in types:
100 print (' ', t, '...',)
101 fname = os.path.join(basedir, dir1,
102 '%s_%s.current.hcfg' % (fn, t))
103 if os.access(fname, os.R_OK):
104 print ('found,',)
105 if os.path.islink(fname) and os.path.isfile(fname):
106 realname = os.readlink(fname)
107 if not os.path.isabs(realname):
108 realname = os.path.join(os.path.dirname(fname), realname)
109 print ('is symlink to', realname)
110 filepathdict[dir1][t] = realname
111 filelist.append(realname)
112 else:
113 print ('but is not valid symlink')
114 else:
115 print ('not found')
116 if filepathdict[dir1] == {}:
117 del filepathdict[dir1]
118
119 commonpart = os.path.dirname(os.path.commonprefix(filelist)) + os.sep
120
121 filepathdict['basename'] = commonpart
122
123
124 for dir1, fn in searchparams:
125 for t in types:
126 try:
127 filepathdict[dir1][t] = filepathdict[dir1][t].
replace(commonpart,
'')
128 except KeyError:
129 pass
130
131 print ()
132 print ('-------------------------------------')
133 print ('File path dictionary to upload:')
134 print (filepathdict)
135 print ('-------------------------------------')
136 print ()
137
138 val = updict.get('phconfig', {})
139 if isinstance(val, str):
140 val = {}
141 val['filepaths'] = filepathdict
142 updict['phconfig'] = '"%s"' % val
143
144
std::string replace(std::string s, const std::string &s2, const std::string &s3)