Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit df27104

Browse files
committed
reapply AttributeFilters, use them on get_next_archiver
1 parent 1f12f9e commit df27104

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

PyTangoArchiving/hdbpp/config.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,24 @@ def get_next_archiver(self,errors=False,use_freq=False, attrexp=''):
268268
errors/use_freq are used to compute the archiver load
269269
attrexp can be used to get archivers already archiving attributes
270270
"""
271+
props = dict((a,fn.tango.get_device_property(a,'AttributeFilters'))
272+
for a in self.get_archivers())
273+
if any(props.values()):
274+
archs = [a for a,v in props.items() if not v]
275+
else:
276+
archs = [a for a in props if fn.clmatch('*[0-9]$',a)]
271277

272278
loads = dict((a,self.get_archiver_load(a,use_freq=use_freq))
273-
for a in self.get_archivers() if fn.clmatch('*[0-9]$',a))
279+
for a in archs)
274280
if errors:
275281
# Errors count twice as load
276282
for a,v in loads.items():
277283
errs = self.get_archiver_errors(a)
278284
loads[a] += 10*len(errs)
279-
280-
if attrexp:
285+
286+
if not len(loads):
287+
self.warning('No free archivers found!')
288+
elif attrexp:
281289
attrs = [a for a in self.get_attributes(True)
282290
if fn.clmatch(attrexp,a)]
283291
archs = [self.get_attribute_archiver(a) for a in attrs]

PyTangoArchiving/hdbpp/multi.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,19 @@ def check_attribute_in_all_dbs(attr_regexp,reader = None,
221221
#for a in attrs:
222222
#for m,f in filters.items():
223223
#pass
224+
225+
def get_archivers_filters(archivers=''):
226+
"""
227+
Returns the value of AttributeFilters property for each archiver in the list
228+
229+
:param archivers: sequence or regular expression for matching archivers
230+
:return: dictionary {archiver:regexp}
231+
"""
232+
archs = archs if fn.isSequence(archivers) else fn.find_devices(archivers)
233+
filters = fn.SortedDict(sorted((k,v['AttributeFilters']) for k,v in
234+
fn.tango.get_matching_device_properties(
235+
archiver,'AttributeFilters').items()))
236+
return filters
224237

225238

226239
def get_archivers_for_attributes(attrs=[],archs='archiving/es/*'):

0 commit comments

Comments
 (0)