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

Commit ee6b363

Browse files
committed
separate subscribed attributes on get_attributes methods
1 parent ed3f03a commit ee6b363

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

PyTangoArchiving/hdbpp/config.py

+19-6
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def get_manager(self, db_name='', prop=''):
185185
return dp
186186

187187
@Cached(expire=60.)
188-
def get_archivers(self, from_db = True):
188+
def get_subscribers(self, from_db = True):
189189
"""
190190
If not got from_db, the manager may limit the list available
191191
"""
@@ -198,6 +198,10 @@ def get_archivers(self, from_db = True):
198198
raise Exception('%s Manager not running'%self.manager)
199199

200200
return [d for d in p if d.strip()]
201+
202+
def get_archivers(self, *args, **kwargs):
203+
""" alias to get_subscribers """
204+
return self.get_subscribers(*args,**kwargs)
201205

202206
@Cached(expire=5.)
203207
def get_archiver_attributes(self, archiver, from_db=False, full=False):
@@ -257,7 +261,10 @@ def get_archiver_errors(self,archiver):
257261
return dict((a,e) for a,e in zip(al,er) if e)
258262

259263
def get_archiver_load(self,archiver,use_freq=True):
260-
264+
"""
265+
if use_freq=True, returns attribute record frequency
266+
if false, returns attribute list size
267+
"""
261268
if use_freq:
262269
return fn.tango.read_attribute(archiver+'/attributerecordfreq')
263270
else:
@@ -350,24 +357,30 @@ def get_attributes_by_table(self,table='',as_id=False):
350357
" where att_conf_data_type_id = %s" % (w,i))) for t,i in types)
351358

352359
@Cached(depth=10,expire=60.)
353-
def get_archived_attributes(self,search=''):
360+
def get_subscribed_attributes(self,search=''):
354361
"""
355-
It gets attributes currently assigned to archiver and updates
362+
It gets attributes currently assigned to subscribers and updates
356363
internal attribute/archiver index.
357364
358365
DONT USE Manager.AttributeSearch, it is limited to 1024 attrs!
359366
"""
360367
#print('get_archived_attributes(%s)'%str(search))
361368
attrs = []
362369
[self.get_archiver_attributes(d,from_db=True)
363-
for d in self.get_archivers()]
370+
for d in self.get_subscribers()]
364371
for d,dattrs in self.dedicated.items():
365372
for a in dattrs:
366373
self.attributes[a].archiver = d
367374
if not search or fn.clsearch(search,a):
368375
attrs.append(a)
369376
return attrs
370377

378+
def get_archived_attributes(self, *args, **kwargs):
379+
"""
380+
alias to get_subscribed_attributes, to be overloaded in subclasses
381+
"""
382+
return self.get_subscribed_attributes(*args, **kwargs)
383+
371384
def get_attribute_ID(self,attr):
372385
# returns only 1 ID
373386
return self.get_attributes_IDs(attr,as_dict=0)[0][1]
@@ -605,7 +618,7 @@ def add_attribute(self,attribute,archiver=None,period=0,
605618
"""
606619
set _event arguments to -1 to ignore them and not modify the database
607620
608-
621+
code_event will be set to True if no other event is setup
609622
"""
610623
attribute = parse_tango_model(attribute,fqdn=True).fullname
611624
archiver = archiver or self.get_next_archiver(

PyTangoArchiving/hdbpp/periodic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def get_archived_attributes(self,search='',periodic=True):
104104
DONT USE Manager.AttributeSearch, it is limited to 1024 attrs!
105105
"""
106106
#print('get_archived_attributes(%s)'%str(search))
107-
attrs = HDBppDB.get_archived_attributes(self, search)
107+
attrs = HDBppDB.get_subscribed_attributes(self, search)
108108
if periodic:
109109
attrs.extend(self.get_periodic_attributes())
110110
return sorted(set(fn.tango.get_full_name(a,fqdn=True).lower()
@@ -201,4 +201,4 @@ def clear_periodic_caches(self):
201201
self.get_periodic_archiver_attributes.cache.clear()
202202
self.get_periodic_archivers_attributes.cache.clear()
203203
self.get_periodic_attribute_archiver.cache.clear()
204-
self.get_periodic_attribute_period.cache.clear()
204+
self.get_periodic_attribute_period.cache.clear()

0 commit comments

Comments
 (0)