[pytango] 465/483: Fixed the timing attributes
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:15:13 UTC 2017
This is an automated email from the git hooks/post-receive script.
sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.
commit b97cafd6f507b28550420f5f605451f8f0cfe387
Author: Sébastien Petitdemange <sebastien.petitdemange at esrf.fr>
Date: Wed Apr 1 19:46:46 2015 +0200
Fixed the timing attributes
filter unique server class name (jive)
small optimization on often call commands
Reload configuration in Init method
---
src/boost/python/databaseds/database.py | 63 +++++++++----------------
src/boost/python/databaseds/db_access/beacon.py | 61 ++++++++++++------------
2 files changed, 50 insertions(+), 74 deletions(-)
diff --git a/src/boost/python/databaseds/database.py b/src/boost/python/databaseds/database.py
index c8ba602..7886250 100644
--- a/src/boost/python/databaseds/database.py
+++ b/src/boost/python/databaseds/database.py
@@ -136,30 +136,24 @@ class DataBase(Device):
# --- attributes ---------------------------------------
- Timing_maximum = attribute(dtype=('float64',), access=READ_ONLY)
+ Timing_maximum = attribute(dtype=('float64',),max_dim_x=128, access=READ_ONLY)
- Timing_average = attribute(dtype=('float64',), access=READ_ONLY)
+ Timing_average = attribute(dtype=('float64',),max_dim_x=128, access=READ_ONLY)
- Timing_index = attribute(dtype=('str',), access=READ_ONLY)
+ Timing_index = attribute(dtype=('str',),max_dim_x=128, access=READ_ONLY)
- Timing_calls = attribute(dtype=('float64',), access=READ_ONLY)
+ Timing_calls = attribute(dtype=('float64',),max_dim_x=128, access=READ_ONLY)
- Timing_info = attribute(dtype=('str',), access=READ_ONLY)
+ Timing_info = attribute(dtype=('str',),max_dim_x=128, access=READ_ONLY)
StoredProcedureRelease = attribute(dtype='str', access=READ_ONLY)
- Timing_minimum = attribute(dtype=('float64',), access=READ_ONLY)
+ Timing_minimum = attribute(dtype=('float64',),max_dim_x=128, access=READ_ONLY)
def init_device(self):
self._log = log = logging.getLogger(self.get_name())
self._log.debug("In init_device()")
self.attr_StoredProcedureRelease_read = ''
- self.attr_Timing_average_read = [0.0]
- self.attr_Timing_minimum_read = [0.0]
- self.attr_Timing_maximum_read = [0.0]
- self.attr_Timing_calls_read = [0.0]
- self.attr_Timing_index_read = ['']
- self.attr_Timing_info_read = ['']
self.init_timing_stats()
m = __import__('%s.%s' % (db_access.__package__,options.db_access),None,None,
'%s.%s' % (db_access.__package__,options.db_access))
@@ -182,45 +176,33 @@ class DataBase(Device):
def read_Timing_maximum(self):
self._log.debug("In read_Timing_maximum()")
- self.attr_Timing_maximum_read[:] = []
- for tmp_name in cmd_list:
- self.attr_Timing_maximum_read.append(self.timing_maps[tmp_name].maximum)
-
- return self.attr_Timing_maximum_read
+ return [x.maximum for x in self.timing_maps.values()]
def read_Timing_average(self):
self._log.debug("In read_Timing_average()")
-
- self.attr_Timing_average_read[:] = []
- for tmp_name in cmd_list:
- self.attr_Timing_average_read.append(self.timing_maps[tmp_name].average)
- return self.attr_Timing_average_read
+
+ return [x.average for x in self.timing_maps.values()]
def read_Timing_index(self):
self._log.debug("In read_Timing_index()")
- for tmp_name in cmd_list:
- self.attr_Timing_index_read.append(self.timing_maps[tmp_name].index)
- return self.attr_Timing_index_read
+ return [x.index for x in self.timing_maps.values()]
def read_Timing_calls(self):
self._log.debug("In read_Timing_calls()")
- self.attr_Timing_calls_read[:] = []
- for tmp_name in cmd_list:
- self.attr_Timing_calls_read.append(self.timing_maps[tmp_name].calls)
- return self.attr_Timing_calls_read
+ return [x.calls for x in self.timing_maps.values()]
def read_Timing_info(self):
self._log.debug("In read_Timing_info()")
- self.attr_Timing_info_read[:] = []
util = PyTango.Util.instance()
- self.attr_Timing_info_read.append("TANGO Database Timing info on host " + util.get_host_name())
- self.attr_Timing_info_read.append(" ")
- self.attr_Timing_info_read.append("command average minimum maximum calls")
- self.attr_Timing_info_read.append(" ")
- for tmp_name in cmd_list:
+ attr_Timing_info_read = []
+ attr_Timing_info_read.append("TANGO Database Timing info on host " + util.get_host_name())
+ attr_Timing_info_read.append(" ")
+ attr_Timing_info_read.append("command average minimum maximum calls")
+ attr_Timing_info_read.append(" ")
+ for tmp_name in sorted(self.timing_maps.keys()):
tmp_info = "%41s\t%6.3f\t%6.3f\t%6.3f\t%.0f"%(tmp_name, self.timing_maps[tmp_name].average, self.timing_maps[tmp_name].minimum, self.timing_maps[tmp_name].maximum, self.timing_maps[tmp_name].calls)
- self.attr_Timing_info_read.append(tmp_info)
- return self.attr_Timing_info_read
+ attr_Timing_info_read.append(tmp_info)
+ return attr_Timing_info_read
def read_StoredProcedureRelease(self):
self._log.debug("In read_StoredProcedureRelease()")
@@ -229,10 +211,7 @@ class DataBase(Device):
def read_Timing_minimum(self):
self._log.debug("In read_Timing_minimum()")
- self.attr_Timing_minimum_read[:] = []
- for tmp_name in cmd_list:
- self.attr_Timing_minimum_read.append(self.timing_maps[tmp_name].minimum)
- return self.attr_Timing_minimum_read
+ return [x.minimum for x in self.timing_maps.values()]
# --- commands -----------------------------------------
@@ -1028,7 +1007,7 @@ class DataBase(Device):
:return:
:rtype: PyTango.DevVoid """
self._log.debug("In ResetTimingValues()")
- for tmp_timing in timing_maps.itervalues():
+ for tmp_timing in self.timing_maps.itervalues():
tmp_timing.average = 0.
tmp_timing.minimum = 0.
tmp_timing.maximum = 0.
diff --git a/src/boost/python/databaseds/db_access/beacon.py b/src/boost/python/databaseds/db_access/beacon.py
index 6e63720..a31086b 100644
--- a/src/boost/python/databaseds/db_access/beacon.py
+++ b/src/boost/python/databaseds/db_access/beacon.py
@@ -18,17 +18,20 @@ from ..db_errors import *
from beacon import static,settings
import itertools
-
-def _info(funct) :
- def f(self,*args,**kwargs) :
- self._info("%s: %s %s", funct.__name__,args,kwargs)
- returnVal = funct(self,*args,**kwargs)
- if returnVal is not None:
- self._info("return %s : %s",funct.__name__,returnVal)
- else:
- self._info("return %s",funct.__name__)
- return returnVal
- return f
+if logging.getLogger().isEnabledFor(logging.INFO):
+ def _info(funct) :
+ def f(self,*args,**kwargs) :
+ self._info("%s: %s %s", funct.__name__,args,kwargs)
+ returnVal = funct(self,*args,**kwargs)
+ if returnVal is not None:
+ self._info("return %s : %s",funct.__name__,returnVal)
+ else:
+ self._info("return %s",funct.__name__)
+ return returnVal
+ return f
+else:
+ def _info(funct):
+ return funct
def _filter(wildcard,l) :
wildcard = wildcard.replace('*','.*')
@@ -41,7 +44,7 @@ class beacon(object):
TANGO_ATTR_ALIAS = 'tango.attr.alias'
def __init__(self, personal_name = "",**keys):
- self._config = static.get_config()
+ self._config = static.Config('',3.)
self._logger = logging.getLogger(self.__class__.__name__)
self._debug = self._logger.debug
self._info = self._logger.info
@@ -78,7 +81,7 @@ class beacon(object):
self._parse_list(values,indexing_flag)
elif isinstance(values,dict):
self._parse_dict(values,indexing_flag)
-
+ self._index_tango(values)
def _parse_list(self,l,indexing_flag) :
for v in l:
@@ -164,7 +167,6 @@ class beacon(object):
attr_alias = settings.HashObjSetting(self.TANGO_ATTR_ALIAS)
del attr_alias[alias]
- @_info
def _get_class_attribute(self,klass_name, attr_name) :
self._info("_get_class_attribute(klass_name=%s,attr_name=%s)",
klass_name, attr_name)
@@ -181,7 +183,6 @@ class beacon(object):
class_attribute = self._get_class_attribute(klass_name,attr_name)
del class_attribute[prop_name]
- @_info
def _get_class_properties(self,klass_name,prop_name):
key_name = 'tango.class.properties.%s.%s' % (klass_name,prop_name)
return settings.QueueSetting(key_name)
@@ -191,7 +192,6 @@ class beacon(object):
class_property = self._get_class_properties(klass_name,prop_name)
class_property.clear()
- @_info
def _get_property_attr_device(self,dev_name) :
key_name = 'tango.%s' % dev_name.lower().replace('/','.')
return settings.HashObjSetting(key_name)
@@ -268,7 +268,6 @@ class beacon(object):
def delete_server_info(self, server_instance):
self._warn("Not implemented delete_server_info(server_instance=%s)", (server_instance))
- @_info
def _get_export_device_info(self,dev_name):
key_name = 'tango.info.%s' % dev_name
return settings.HashSetting(key_name)
@@ -442,21 +441,21 @@ class beacon(object):
[str(x) for p in prop_attr.iteritems() for x in p])
return result
- @_info
def get_device_attribute_property2(self, dev_name, attributes):
- prop_attr_device = self._get_property_attr_device(dev_name)
+ prop_attr_device_handler = self._get_property_attr_device(dev_name)
result = [dev_name, str(len(attributes))]
+ prop_attr_device = prop_attr_device_handler.get_all()
for attr_name in attributes:
prop_attr = prop_attr_device.get(attr_name)
if prop_attr is None:
- result.extend([attr_name,'0'])
+ result.extend((attr_name,'0'))
else:
- result.extend([attr_name,str(len(prop_attr))])
+ result.extend((attr_name,str(len(prop_attr))))
for name,values in prop_attr:
if isinstance(values,list):
result.extend([name,len(values)] + [str(x) for x in values])
else:
- result.extend([name,'1',str(values)])
+ result.extend((name,'1',str(values)))
return result
@_info
@@ -495,7 +494,6 @@ class beacon(object):
[n.get('tango_name') for n in self._tango_name_2_node.values()])
return list(set([x.split('/')[1] for x in filtered_names]))
- @_info
def get_device_info(self, dev_name):
dev_name = dev_name.lower()
device_info = self._get_export_device_info(dev_name)
@@ -509,13 +507,13 @@ class beacon(object):
server_node = device_node
else:
server_node = device_node.parent
- result_str.extend([dev_name,
+ result_str.extend((dev_name,
info.get('IOR',''),
str(info.get('version','0')),
server_node.get('server','') + '/' + server_node.get('personal_name',''),
info.get('host','?'),info.get('start-time','?'),'?',
- device_node.get('class','DServer')])
- result_long.extend([info and 1 or 0,info.get('pid',-1)])
+ device_node.get('class','DServer')))
+ result_long.extend((info and 1 or 0,info.get('pid',-1)))
return (result_long,result_str)
@_info
@@ -706,18 +704,19 @@ class beacon(object):
@_info
def get_server_class_list(self,wildcard):
server_names = _filter(wildcard,self._personal_2_node.keys())
- result = []
+ result = set()
for ser_name in server_names:
server_node = self._personal_2_node.get(ser_name)
for device_node in server_node.get('device',[]) :
class_name = device_node.get('class')
if class_name is not None:
- result.append(class_name)
+ result.add(class_name)
- result.append('DServer')
+ result.add('DServer')
+ result = list(result)
result.sort()
return result
- @_info
+
def import_device(self, dev_name):
dev_node = self._tango_name_2_node.get(dev_name)
if dev_node is not None:
@@ -726,7 +725,6 @@ class beacon(object):
th_exc(DB_DeviceNotDefined,
"device " + dev_name + " not defined in the database !",
"DataBase::ImportDevice()")
-
@_info
def import_event(self, event_name):
th_exc(DB_DeviceNotDefined,
@@ -879,7 +877,6 @@ class beacon(object):
#Not use in our case
pass
- @_info
def unexport_device(self, dev_name):
device_info = self._get_export_device_info(dev_name)
device_info.clear()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git
More information about the debian-science-commits
mailing list