summaryrefslogtreecommitdiff
path: root/lib/taurus/core/tango
diff options
context:
space:
mode:
Diffstat (limited to 'lib/taurus/core/tango')
-rw-r--r--[-rwxr-xr-x]lib/taurus/core/tango/tangoattribute.py17
-rw-r--r--lib/taurus/core/tango/tangodatabase.py31
-rw-r--r--[-rwxr-xr-x]lib/taurus/core/tango/tangodevice.py2
-rw-r--r--[-rwxr-xr-x]lib/taurus/core/tango/test/test_tangofactory.py0
-rw-r--r--[-rwxr-xr-x]lib/taurus/core/tango/util/formatter.py0
5 files changed, 27 insertions, 23 deletions
diff --git a/lib/taurus/core/tango/tangoattribute.py b/lib/taurus/core/tango/tangoattribute.py
index 9bd9af00..b0620881 100755..100644
--- a/lib/taurus/core/tango/tangoattribute.py
+++ b/lib/taurus/core/tango/tangoattribute.py
@@ -119,8 +119,10 @@ class TangoAttrValue(TaurusAttrValue):
for _ in range(len(shape) - 1):
p.value = [p.value]
- rvalue = p.value
- wvalue = p.w_value
+ # Protect against DeviceAttribute not providing .value in some cases,
+ # seen e.g. in PyTango 9.3.0
+ rvalue = getattr(p, 'value', None)
+ wvalue = getattr(p, 'w_value', None)
if numerical:
units = self._attrRef._units
if rvalue is not None:
@@ -324,6 +326,7 @@ class TangoAttribute(TaurusAttribute):
def cleanUp(self):
self.trace("[TangoAttribute] cleanUp")
self._unsubscribeConfEvents()
+ self._unsubscribeChangeEvents()
TaurusAttribute.cleanUp(self)
self.__dev_hw_obj = None
self._pytango_attrinfoex = None
@@ -417,7 +420,7 @@ class TangoAttribute(TaurusAttribute):
elif fmt in (DataFormat._1D, DataFormat._2D):
if PyTango.is_int_type(tgtype):
# cast to integer because the magnitude conversion gives floats
- attrvalue = magnitude.astype('int64')
+ attrvalue = numpy.array(magnitude, copy=False, dtype='int64')
elif tgtype == PyTango.CmdArgType.DevUChar:
attrvalue = magnitude.view('uint8')
else:
@@ -600,7 +603,7 @@ class TangoAttribute(TaurusAttribute):
assert len(listeners) >= 1
if self.__subscription_state == SubscriptionState.Unsubscribed and len(listeners) == 1:
- self._subscribeEvents()
+ self._subscribeChangeEvents()
# if initial_subscription_state == SubscriptionState.Subscribed:
if (len(listeners) > 1
@@ -630,7 +633,7 @@ class TangoAttribute(TaurusAttribute):
return ret
if self.__subscription_state != SubscriptionState.Unsubscribed:
- self._unsubscribeEvents()
+ self._unsubscribeChangeEvents()
return ret
@@ -654,7 +657,7 @@ class TangoAttribute(TaurusAttribute):
def _process_event_exception(self, ex):
pass
- def _subscribeEvents(self):
+ def _subscribeChangeEvents(self):
""" Enable subscription to the attribute events. If change events are
not supported polling is activated """
@@ -705,7 +708,7 @@ class TangoAttribute(TaurusAttribute):
return self.__chg_evt_id
- def _unsubscribeEvents(self):
+ def _unsubscribeChangeEvents(self):
# Careful in this method: This is intended to be executed in the cleanUp
# so we should not access external objects from the factory, like the
# parent object
diff --git a/lib/taurus/core/tango/tangodatabase.py b/lib/taurus/core/tango/tangodatabase.py
index 0d29365b..cb138566 100644
--- a/lib/taurus/core/tango/tangodatabase.py
+++ b/lib/taurus/core/tango/tangodatabase.py
@@ -643,21 +643,22 @@ def get_env_var(env_var_name):
if not os.path.exists(fname):
return None
- for line in file(fname):
- strippedline = line.split('#', 1)[0].strip()
-
- if not strippedline:
- # empty line
- continue
-
- tup = strippedline.split('=', 1)
- if len(tup) != 2:
- # illegal line!
- continue
-
- key, val = list(map(str.strip, tup))
- if key == env_var_name:
- return val
+ with open(fname) as f:
+ for line in f:
+ strippedline = line.split('#', 1)[0].strip()
+
+ if not strippedline:
+ # empty line
+ continue
+
+ tup = strippedline.split('=', 1)
+ if len(tup) != 2:
+ # illegal line!
+ continue
+
+ key, val = list(map(str.strip, tup))
+ if key == env_var_name:
+ return val
class TangoAuthority(TaurusAuthority):
diff --git a/lib/taurus/core/tango/tangodevice.py b/lib/taurus/core/tango/tangodevice.py
index 562faa66..60e979c8 100755..100644
--- a/lib/taurus/core/tango/tangodevice.py
+++ b/lib/taurus/core/tango/tangodevice.py
@@ -75,7 +75,7 @@ class TangoDevice(TaurusDevice):
# This way we can call for example read_attribute on an object of this
# class
def __getattr__(self, name):
- if self._deviceObj is not None:
+ if name != "_deviceObj" and self._deviceObj is not None:
return getattr(self._deviceObj, name)
cls_name = self.__class__.__name__
raise AttributeError("'%s' has no attribute '%s'" % (cls_name, name))
diff --git a/lib/taurus/core/tango/test/test_tangofactory.py b/lib/taurus/core/tango/test/test_tangofactory.py
index 7c7c3a8a..7c7c3a8a 100755..100644
--- a/lib/taurus/core/tango/test/test_tangofactory.py
+++ b/lib/taurus/core/tango/test/test_tangofactory.py
diff --git a/lib/taurus/core/tango/util/formatter.py b/lib/taurus/core/tango/util/formatter.py
index ce5ebd0d..ce5ebd0d 100755..100644
--- a/lib/taurus/core/tango/util/formatter.py
+++ b/lib/taurus/core/tango/util/formatter.py