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

Commit

Permalink
add check for periodic and hdbrf attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
sergirubio committed Apr 25, 2019
1 parent 80dab3d commit 631ecdf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 4 additions & 3 deletions PyTangoArchiving/hdbpp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class HDBppDB(ArchivingDB,SingletonMap):

def __init__(self,db_name='',host='',user='',
passwd='', manager='',
other=None, port = '3306'):
other=None, port = '3306',
log_level = 'WARNING'):
"""
Configuration can be loaded from PyTangoArchiving.Schemas,
an HdbConfigurationManager or another DB object.
Expand Down Expand Up @@ -98,7 +99,7 @@ def __init__(self,db_name='',host='',user='',
self.dedicated = {}
self.status = fn.defaultdict(list)
ArchivingDB.__init__(self,db_name,host,user,passwd,)
self.setLogLevel('INFO')
self.setLogLevel(log_level)
try:
self.get_manager()
self.get_attributes()
Expand Down Expand Up @@ -666,7 +667,7 @@ def restart_attribute(self,attr, d=''):

def restart_attributes(self,attributes=None):
if attributes is None:
attributes = self.get_failed_attributes()
attributes = self.get_attributes_not_updated()

devs = dict(fn.kmap(self.get_attribute_archiver,attributes))

Expand Down
5 changes: 5 additions & 0 deletions PyTangoArchiving/hdbpp/periodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def get_next_periodic_archiver(self, attrexp=''):
@fn.Catched
def add_periodic_attribute(self,attribute,period,archiver=None,wait=1.5):

arch = self.get_periodic_attribute_archiver(attribute)
if arch:
print('%s is already archived by %s!' % (attribute,arch))
return False

attribute = parse_tango_model(attribute,fqdn=True).fullname
archiver = archiver or self.get_next_periodic_archiver(
attrexp = fn.tango.get_dev_name(attribute)+'/*')
Expand Down
7 changes: 4 additions & 3 deletions PyTangoArchiving/hdbpp/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def get_attribute_values(self,table,start_date=None,stop_date=None,

#self.info('%s : %s' % (table, self.getTableCols(table)))
int_time = int_time and 'int_time' in self.getTableCols(table)
if self.db_name == 'hdbrf': int_time = False #@TODO HACK
if int_time:
self.info('Using int_time indexing for %s' % table)
if start_date or stop_date:
Expand Down Expand Up @@ -180,11 +181,11 @@ def next_power_of_2(x):
######################################################################
# QUERY
t0 = time.time()
self.warning(query.replace('where','\nwhere').replace(
self.info(query.replace('where','\nwhere').replace(
'group,','\ngroup'))
try:
result = self.Query(query)
self.warning('read [%d] in %f s'%(len(result),time.time()-t0))
self.info('read [%d] in %f s'%(len(result),time.time()-t0))
except MySQLdb.ProgrammingError as e:
result = []
if 'DOUBLE' in str(e) and "as DOUBLE" in query:
Expand Down Expand Up @@ -419,7 +420,7 @@ def check_attributes(self,attrs = '', load = False, t0 = 0):

return result

def get_failed_attributes(self,t=7200):
def get_attributes_not_updated(self,t=7200):
vals = self.load_last_values(self.get_attributes())
nones = [k for k,v in vals.items()
if (not v or v[1] is None)]
Expand Down

0 comments on commit 631ecdf

Please sign in to comment.