[pytango] 178/483: undo last change which produced an error in complex servers

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:38 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 5ad4cc7c1eea71ce6e8c139b9a3016c50885c5f2
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Wed Dec 26 11:54:41 2012 +0000

    undo last change which produced an error in complex servers
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@21773 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 Makefile                    | 21 +--------------------
 PyTango/device_class.py     | 19 ++++++++-----------
 PyTango/device_server.py    |  9 +++++----
 PyTango/globals.py          | 21 ++-------------------
 src/server/device_class.cpp | 22 +++++++++++++++++++---
 src/server/device_impl.cpp  |  1 +
 6 files changed, 36 insertions(+), 57 deletions(-)

diff --git a/Makefile b/Makefile
index 28881c8..dde091b 100644
--- a/Makefile
+++ b/Makefile
@@ -43,29 +43,15 @@
 # - PY_VER: use a specific python version (default is empty) (ex: 3.2)
 
 ifdef PY_VER
-
-ifdef PY_DEBUG
-PY_EXC=python$(PY_VER)-dbg
-else
 PY_EXC=python$(PY_VER)
-endif # PY_DEBUG
-
 PY_MAJOR=$(shell $(PY_EXC) -c "import sys; sys.stdout.write(str(sys.version_info[0]))")
 PY_MINOR=$(shell $(PY_EXC) -c "import sys; sys.stdout.write(str(sys.version_info[1]))")
-
-else
-
-ifdef PY_DEBUG
-PY_EXC=python-dbg
 else
 PY_EXC=python
-endif # PY_DEBUG
-
-PY_EXC=python
 PY_MAJOR=$(shell $(PY_EXC) -c "import sys; sys.stdout.write(str(sys.version_info[0]))")
 PY_MINOR=$(shell $(PY_EXC) -c "import sys; sys.stdout.write(str(sys.version_info[1]))")
 PY_VER=$(PY_MAJOR).$(PY_MINOR)
-endif # PY_VER
+endif
 
 PY_VER_S=$(PY_MAJOR)$(PY_MINOR)
 
@@ -91,12 +77,7 @@ endif
 
 CC = gcc
 
-ifdef PY_DEBUG
-PY_INC = $(shell python$(PY_VER)-dbg-config --includes)
-else
 PY_INC = $(shell python$(PY_VER)-config --includes)
-endif
-
 NUMPY_INC = -I$(NUMPY_ROOT)/include
 TANGO_INC = -I$(TANGO_ROOT)/include
 PRE_C_H = precompiled_header.hpp
diff --git a/PyTango/device_class.py b/PyTango/device_class.py
index d45bdd9..db2e4e6 100644
--- a/PyTango/device_class.py
+++ b/PyTango/device_class.py
@@ -42,7 +42,7 @@ from .utils import is_pure_str, is_non_str_seq, seqStr_2_obj, obj_2_str, \
 from .utils import document_method as __document_method
 
 from .globals import get_class, get_class_by_class, \
-    get_constructed_class_by_class, delete_class
+    get_constructed_class_by_class
 from .attr_data import AttrData
 
 
@@ -309,9 +309,6 @@ class DeviceClass(_DeviceClass):
     def __repr__(self):
         return '%s(%s)' % (self.__class__.__name__, self.get_name())    
     
-    def __unregister_class(self):
-        delete_class(self)
-    
     def __throw_create_attribute_exception(self, msg):
         """Helper method to throw DevFailed exception when inside create_attribute"""
         Except.throw_exception("PyDs_WrongAttributeDefinition", msg, "create_attribute()")
@@ -536,20 +533,20 @@ class DeviceClass(_DeviceClass):
        
         klass = self.__class__
         klass_name = klass.__name__
-
-        info = get_class_by_class(klass)
+        info, klass = get_class_by_class(klass), get_constructed_class_by_class(klass)
+        
         if info is None:
             raise RuntimeError("Device class '%s' is not registered" % klass_name)
 
-        deviceClass = get_constructed_class_by_class(klass)
-        if deviceClass is None:
+        if klass is None:
             raise RuntimeError("Device class '%s' as not been constructed" % klass_name)
         
-        _, deviceImplClass, deviceImplName = info
-        tmp_dev_list = []
+        deviceClassClass, deviceImplClass, deviceImplName = info
+        deviceImplClass._device_class_instance = klass
 
+        tmp_dev_list = []
         for dev_name in device_list:
-            device = deviceImplClass(deviceClass, dev_name)
+            device = deviceImplClass(klass, dev_name)
             self._add_device(device)
             tmp_dev_list.append(device)
 
diff --git a/PyTango/device_server.py b/PyTango/device_server.py
index 6bd051f..8c05fa5 100644
--- a/PyTango/device_server.py
+++ b/PyTango/device_server.py
@@ -44,7 +44,7 @@ from ._PyTango import DevFailed, DeviceImpl, Device_3Impl, Device_4Impl, \
 from .utils import document_method as __document_method
 from .utils import copy_doc
 from .attr_data import AttrData
-from .globals import get_device_class_from_device_impl
+
 from .log4tango import TangoStream
 
 class AttributeAlarm(object):
@@ -273,9 +273,10 @@ def __init_Attribute():
     Attribute.set_properties = __Attribute__set_properties
     
 def __DeviceImpl__get_device_class(self):
-    if self._device_class_instance is None:
-        self._device_class_instance = get_device_class_from_device_impl(self)
-    return self._device_class_instance
+    try:
+        return self._device_class_instance
+    except AttributeError:
+        return None
 
 def __DeviceImpl__get_device_properties(self, ds_class = None):
     """get_device_properties(self, ds_class = None) -> None
diff --git a/PyTango/globals.py b/PyTango/globals.py
index 8a91bf4..e288607 100644
--- a/PyTango/globals.py
+++ b/PyTango/globals.py
@@ -28,9 +28,7 @@ This is an internal PyTango module.
 __all__ = [ "get_class", "get_classes", "get_cpp_class", "get_cpp_classes",
             "get_constructed_class", "get_constructed_classes",
             "class_factory", "delete_class_list",
-            "class_list", "cpp_class_list", "constructed_class", "delete_class",
-            "get_device_class_from_device_impl",
-            "get_device_class_from_device_impl_class"]
+            "class_list", "cpp_class_list", "constructed_class"]
             
 __docformat__ = "restructuredtext"
 
@@ -85,14 +83,6 @@ def get_constructed_class_by_class(klass):
             return k
     return None
 
-def get_device_class_from_device_impl(device_impl):
-    return get_device_class_from_device_impl_class(device_impl.__class__)
-
-def get_device_class_from_device_impl_class(device_impl_class):
-    for info in get_classes():
-        if info[1] == device_impl_class:
-            return get_constructed_class_by_class(info[0])
-
 #
 # A method to delete Tango classes from Python
 #
@@ -100,14 +90,7 @@ def get_device_class_from_device_impl_class(device_impl_class):
 def delete_class_list():
     global constructed_class
     if len(constructed_class) != 0:
-        del(constructed_class[:])
-
-def delete_class(device_class):
-    constructed_classes = get_constructed_classes()
-    try:
-        constructed_classes.remove(device_class)
-    except ValueError:
-        pass
+       del(constructed_class[:])
 
 #
 # A generic class_factory method
diff --git a/src/server/device_class.cpp b/src/server/device_class.cpp
index 3677a4f..d5b8033 100644
--- a/src/server/device_class.cpp
+++ b/src/server/device_class.cpp
@@ -167,9 +167,7 @@ CppDeviceClassWrap::CppDeviceClassWrap(PyObject *self, const std::string &name)
  * Destructor
  */
 CppDeviceClassWrap::~CppDeviceClassWrap()
-{
-    CALL_DEVCLASS_METHOD(_DeviceClass__unregister_class)
-}
+{}
 
 void CppDeviceClassWrap::init_class()
 {
@@ -306,6 +304,24 @@ namespace PyDeviceClass
         }
         return py_cmd_list;
     }
+        
+    /*
+    void add_device(CppDeviceClass &self, auto_ptr<Tango::DeviceImpl> dev)
+    {
+        self.add_device(dev.get());
+        dev.release();
+    }
+
+    void add_device(CppDeviceClass &self, auto_ptr<Tango::Device_4Impl> dev)
+    {
+        self.add_device(dev.get());
+        dev.release();
+    }
+
+    void (*add_device1)(CppDeviceClass &, auto_ptr<Tango::DeviceImpl>) = &add_device;
+    void (*add_device2)(CppDeviceClass &, auto_ptr<Tango::Device_4Impl>) = &add_device;
+    */
+    
 }
 
 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS (export_device_overload,
diff --git a/src/server/device_impl.cpp b/src/server/device_impl.cpp
index 69b3d4c..16bd950 100644
--- a/src/server/device_impl.cpp
+++ b/src/server/device_impl.cpp
@@ -1198,6 +1198,7 @@ void export_device_impl()
         .def("_add_attribute", &PyDeviceImpl::add_attribute)
         .def("_remove_attribute", &PyDeviceImpl::remove_attribute,
             remove_attribute_overload())
+        //@TODO .def("get_device_class")
         //@TODO .def("get_db_device")
         .def("is_attribute_polled", &PyDeviceImpl::is_attribute_polled)
         .def("is_command_polled", &PyDeviceImpl::is_command_polled)

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