[pytango] 330/483: fixes #637

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:56 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 ee7eb27eff383f82061d0f59335a419193968067
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Wed Nov 27 14:15:24 2013 +0000

    fixes #637
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@24400 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 src/boost/cpp/device_attribute.cpp | 12 ++++++---
 src/boost/cpp/group.cpp            | 52 +++++++++++++++++++++++++++++---------
 2 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/src/boost/cpp/device_attribute.cpp b/src/boost/cpp/device_attribute.cpp
index b7a3b61..ad11024 100644
--- a/src/boost/cpp/device_attribute.cpp
+++ b/src/boost/cpp/device_attribute.cpp
@@ -692,7 +692,7 @@ namespace PyDeviceAttribute
     reset(Tango::DeviceAttribute & self, const Tango::AttributeInfo &attr_info,
           bopy::object py_value)
     {
-        self.set_name(const_cast<std::string&>(attr_info.name));
+        self.set_name(attr_info.name.c_str());
         reset_values(self, attr_info.data_type, attr_info.data_format, py_value);
     }
 
@@ -700,12 +700,18 @@ namespace PyDeviceAttribute
     reset(Tango::DeviceAttribute & self, const std::string &attr_name,
           Tango::DeviceProxy &dev_proxy, bopy::object py_value)
     {
+        self.set_name(attr_name.c_str());
         Tango::AttributeInfoEx attr_info;
         {
             AutoPythonAllowThreads guard;
-            attr_info = dev_proxy.get_attribute_config(attr_name);
+            try
+            {
+                attr_info = dev_proxy.get_attribute_config(attr_name);
+            }
+            catch(...)
+            {}
         }
-        reset(self, attr_info, py_value);
+        reset_values(self, attr_info.data_type, attr_info.data_format, py_value);
     }
 
 };
diff --git a/src/boost/cpp/group.cpp b/src/boost/cpp/group.cpp
index ac30bc4..87e3cba 100644
--- a/src/boost/cpp/group.cpp
+++ b/src/boost/cpp/group.cpp
@@ -103,10 +103,29 @@ namespace PyGroup
         if(!dev_proxy)
         {   
             Tango::DeviceAttribute dev_attr;
+            dev_attr.set_name(attr_name.c_str());
             AutoPythonAllowThreads guard;
             return self.write_attribute_asynch(dev_attr, forward);
         }
         
+        // Try to see if we can get attribute information from any device in
+        // the group
+        Tango::AttributeInfoEx attr_info;
+        bool has_attr_info = false;
+        {
+            AutoPythonAllowThreads guard;
+            for(long dev_idx = 1; dev_idx <= self.get_size(); ++dev_idx)
+            {
+                try
+                {
+                    attr_info = self[dev_idx]->get_attribute_config(attr_name);
+                    has_attr_info = true;
+                    break;
+                }
+                catch(...) {}
+            }
+        }
+
         if(multi)
         {
             if(!PySequence_Check(py_value.ptr()))
@@ -116,28 +135,37 @@ namespace PyGroup
                        "(ex: list or tuple)" );
             }
             
-            Tango::AttributeInfoEx attr_info;
-            {
-                AutoPythonAllowThreads guard;
-                attr_info = dev_proxy->get_attribute_config(attr_name);
-            }
-                        
             Py_ssize_t attr_nb = bopy::len(py_value);
             std::vector<Tango::DeviceAttribute> dev_attr(attr_nb);
-            for(Py_ssize_t i = 0; i < attr_nb; ++i)
+
+            if (has_attr_info)
             {
-                PyDeviceAttribute::reset(dev_attr[i], attr_info, py_value[i]);
+                for(Py_ssize_t i = 0; i < attr_nb; ++i)
+                {
+                    PyDeviceAttribute::reset(dev_attr[i], attr_info, py_value[i]);
+                }
+            }
+            else
+            {
+                for(Py_ssize_t i = 0; i < attr_nb; ++i)
+                {
+                    dev_attr[i].set_name(attr_name.c_str());
+                }
             }
-            
             AutoPythonAllowThreads guard;
             return self.write_attribute_asynch(dev_attr, forward);
         }
         else
         {
             Tango::DeviceAttribute dev_attr;
-            Tango::DeviceProxy* dev_proxy = self.get_device(1);
-            if (dev_proxy)
-                PyDeviceAttribute::reset(dev_attr, attr_name, *dev_proxy, py_value);
+            if (has_attr_info)
+            {
+                PyDeviceAttribute::reset(dev_attr, attr_info, py_value);
+            }
+            else
+            {
+                dev_attr.set_name(attr_name.c_str());
+            }
             // If !dev_proxy (no device added in self or his children) then we
             // don't initialize dev_attr. As a result, the reply will be empty.
             /// @todo or should we raise an exception instead?

-- 
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