[pytango] 268/483: made DevError, DevFailed, AttributeInfo and friends pickable

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:48 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 7adba558b560be68a5268c6700682c152c6b5f98
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Mon Jul 15 15:50:57 2013 +0000

    made DevError, DevFailed, AttributeInfo and friends pickable
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@23130 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 Makefile                                  |  49 +++----
 setup.py                                  |   1 +
 src/boost/cpp/archive_event_info.cpp      |   1 +
 src/boost/cpp/attr_conf_event_data.cpp    |   1 -
 src/boost/cpp/attribute_alarm_info.cpp    |   1 +
 src/boost/cpp/attribute_event_info.cpp    |   1 +
 src/boost/cpp/attribute_info.cpp          |   1 +
 src/boost/cpp/attribute_info_ex.cpp       |   1 +
 src/boost/cpp/change_event_info.cpp       |   1 +
 src/boost/cpp/dev_error.cpp               |  45 +++++--
 src/boost/cpp/device_attribute_config.cpp |  18 ++-
 src/boost/cpp/periodic_event_info.cpp     |   1 +
 src/boost/python/base_types.py            | 215 +++++++++++++++++++++++++++++-
 src/boost/python/exception.py             |  26 +++-
 src/boost/python/utils.py                 |  83 ++++++++++--
 15 files changed, 381 insertions(+), 64 deletions(-)

diff --git a/Makefile b/Makefile
index 6b241a0..300c88d 100644
--- a/Makefile
+++ b/Makefile
@@ -56,8 +56,6 @@ endif
 PY_VER_S=$(PY_MAJOR)$(PY_MINOR)
 
 ifndef NUMPY_ROOT
-# NUMPY_ROOT=$(shell $(PY_EXC) -c "import sys, os, numpy; sys.stdout.write(os.path.dirname(numpy.__file__))")/core
-# NUMPY_INC = -I$(NUMPY_ROOT)/include
 NUMPY_INC = -I$(shell $(PY_EXC) -c "import sys, numpy; sys.stdout.write(numpy.get_include())")
 else
 NUMPY_INC = -I$(NUMPY_ROOT)/include
@@ -76,23 +74,23 @@ endif
 SRC_DIR = src/boost/cpp
 
 ifndef OBJS_DIR
-OBJS_DIR = objs_py$(PY_VER_S)
+OBJS_DIR := objs_py$(PY_VER_S)
 endif
 
 CC = gcc
 
-PY_INC = $(shell python$(PY_VER)-config --includes)
+PY_INC := $(shell python$(PY_VER)-config --includes)
 OPTIMIZE_CC = -g -O0
 OPTIMIZE_LN = -O0
 
-PRE_C_H = precompiled_header.hpp
-PRE_C_H_O = $(OBJS_DIR)/$(PRE_C_H).gch
-PRE_C = -include$(OBJS_DIR)/$(PRE_C_H)
-LN = g++ -pthread -shared -Wl,$(OPTIMIZE_LN) -Wl,-Bsymbolic-functions
-LN_STATIC = g++ -pthread -static -Wl,$(OPTIMIZE_LN) -Wl,-Bsymbolic-functions
-LN_VER = -Wl,-h -Wl,--strip-all
-BOOST_LIB = boost_python-py$(PY_VER_S)
-LN_LIBS = -ltango -llog4tango -lpthread -lrt -ldl -lomniORB4 -lomniDynamic4 -lomnithread -lCOS4 -l$(BOOST_LIB) -lzmq
+PRE_C_H := precompiled_header.hpp
+PRE_C_H_O := $(OBJS_DIR)/$(PRE_C_H).gch
+PRE_C := -include$(OBJS_DIR)/$(PRE_C_H)
+LN := g++ -pthread -shared -Wl,$(OPTIMIZE_LN) -Wl,-Bsymbolic-functions
+LN_STATIC := g++ -pthread -static -Wl,$(OPTIMIZE_LN) -Wl,-Bsymbolic-functions
+LN_VER := -Wl,-h -Wl,--strip-all
+BOOST_LIB := boost_python-py$(PY_VER_S)
+LN_LIBS := -ltango -llog4tango -lpthread -lrt -ldl -lomniORB4 -lomniDynamic4 -lomnithread -lCOS4 -l$(BOOST_LIB) -lzmq
 
 INCLUDE_DIRS =
 ifdef TANGO_ROOT
@@ -124,15 +122,15 @@ INCLUDE_DIRS += \
     $(PY_INC) \
     $(NUMPY_INC)
 
-CCFLAGS = -pthread -fno-strict-aliasing -DNDEBUG $(OPTIMIZE_CC) -fwrapv -Wall -fPIC -std=c++0x -DPYTANGO_HAS_UNIQUE_PTR $(INCLUDE_DIRS)
+CCFLAGS := -pthread -fno-strict-aliasing -DNDEBUG $(OPTIMIZE_CC) -fwrapv -Wall -fPIC -std=c++0x -DPYTANGO_HAS_UNIQUE_PTR $(INCLUDE_DIRS)
 
-LIB_NAME = _PyTango.so
-LIB_NAME_STATIC = _PyTangoStatic.so
-LIB_SYMB_NAME = $(LIB_NAME).dbg
+LIB_NAME := _PyTango.so
+LIB_NAME_STATIC := _PyTangoStatic.so
+LIB_SYMB_NAME := $(LIB_NAME).dbg
 
 
 
-OBJS = \
+OBJS := \
 $(OBJS_DIR)/api_util.o \
 $(OBJS_DIR)/archive_event_info.o \
 $(OBJS_DIR)/attr_conf_event_data.o \
@@ -192,7 +190,7 @@ $(OBJS_DIR)/tango_util.o \
 $(OBJS_DIR)/user_default_attr_prop.o \
 $(OBJS_DIR)/wattribute.o
 
-INC = callback.h \
+INC := callback.h \
 defs.h \
 device_attribute.h \
 exception.h \
@@ -225,15 +223,6 @@ $(PRE_C_H_O): $(SRC_DIR)/$(PRE_C_H)
 	@$(CC) $(CCFLAGS) -c $< -o $(PRE_C_H_O)
 
 #
-# Rule for shared library
-#
-
-#.SUFFIXES: .o .cpp
-#.cpp.o: $(PRE_C_H_O)
-#	@echo Compiling 1 $(<) ...
-#	@$(CC) $(CCFLAGS) -c $< -o $*.o
-
-#
 # Rule for API files
 #
 $(OBJS_DIR)/%.o: $(SRC_DIR)/%.cpp
@@ -251,11 +240,6 @@ $(OBJS_DIR)/%.o: $(SRC_DIR)/server/%.cpp
 $(LIB_NAME): $(PRE_C_H_0) $(OBJS)
 	@echo Linking shared $(LIB_NAME) ...
 	@$(LN) $(OBJS) $(LN_DIRS) $(LN_LIBS) -o $(OBJS_DIR)/$(LIB_NAME) $(LN_VER)
-#	@$(LN_STATIC) $(OBJS) $(LN_DIRS) $(LN_LIBS) -o $(OBJS_DIR)/$(LIB_NAME_STATIC) $(LN_VER)
-#	objcopy --only-keep-debug $(OBJS_DIR)/$(LIB_NAME) $(OBJS_DIR)/$(LIB_SYMB_NAME)
-#	objcopy --strip-debug --strip-unneeded $(OBJS_DIR)/$(LIB_NAME)
-#	objcopy --add-gnu-debuglink=$(OBJS_DIR)/$(LIB_SYMB_NAME) $(OBJS_DIR)/$(LIB_NAME)
-#	chmod -x $(OBJS_DIR)/$(LIB_SYMB_NAME)
 
 clean:
 	@echo Cleaning ...
@@ -271,5 +255,4 @@ install-py:
 install: build install-py
 	@echo Installing binary files into $(prefix)/PyTango ...
 	@rsync $(OBJS_DIR)/$(LIB_NAME) $(prefix)/PyTango
-#	rsync $(OBJS_DIR)/$(LIB_SYMB_NAME) $(prefix)/PyTango
  
diff --git a/setup.py b/setup.py
index 27b7809..42209ec 100644
--- a/setup.py
+++ b/setup.py
@@ -298,6 +298,7 @@ def main():
 
     packages = [
         'PyTango',
+        'PyTango.green',
         'PyTango.ipython',
         'PyTango.ipython.ipython_00_10',
         'PyTango.ipython.ipython_00_11',
diff --git a/src/boost/cpp/archive_event_info.cpp b/src/boost/cpp/archive_event_info.cpp
index 78cfc7a..f3fad46 100644
--- a/src/boost/cpp/archive_event_info.cpp
+++ b/src/boost/cpp/archive_event_info.cpp
@@ -29,6 +29,7 @@ using namespace boost::python;
 void export_archive_event_info()
 {
     class_<Tango::ArchiveEventInfo>("ArchiveEventInfo")
+        .enable_pickling()
         .def_readwrite("archive_rel_change", &Tango::ArchiveEventInfo::archive_rel_change)
         .def_readwrite("archive_abs_change", &Tango::ArchiveEventInfo::archive_abs_change)
         .def_readwrite("archive_period", &Tango::ArchiveEventInfo::archive_period)
diff --git a/src/boost/cpp/attr_conf_event_data.cpp b/src/boost/cpp/attr_conf_event_data.cpp
index c3441f1..5f0b7c5 100644
--- a/src/boost/cpp/attr_conf_event_data.cpp
+++ b/src/boost/cpp/attr_conf_event_data.cpp
@@ -30,7 +30,6 @@ void export_attr_conf_event_data()
 {
     class_<Tango::AttrConfEventData>("AttrConfEventData",
         init<const Tango::AttrConfEventData &>())
-
         // The original Tango::EventData structure has a 'device' field.
         // However, if we returned this directly we would get a different
         // python device each time. So we are doing our weird things to make
diff --git a/src/boost/cpp/attribute_alarm_info.cpp b/src/boost/cpp/attribute_alarm_info.cpp
index 48e182f..e83904d 100644
--- a/src/boost/cpp/attribute_alarm_info.cpp
+++ b/src/boost/cpp/attribute_alarm_info.cpp
@@ -29,6 +29,7 @@ using namespace boost::python;
 void export_attribute_alarm_info()
 {
     class_<Tango::AttributeAlarmInfo>("AttributeAlarmInfo")
+        .enable_pickling()
         .def_readwrite("min_alarm", &Tango::AttributeAlarmInfo::min_alarm)
         .def_readwrite("max_alarm", &Tango::AttributeAlarmInfo::max_alarm)
         .def_readwrite("min_warning", &Tango::AttributeAlarmInfo::min_warning)
diff --git a/src/boost/cpp/attribute_event_info.cpp b/src/boost/cpp/attribute_event_info.cpp
index b617f8c..ca60153 100644
--- a/src/boost/cpp/attribute_event_info.cpp
+++ b/src/boost/cpp/attribute_event_info.cpp
@@ -29,6 +29,7 @@ using namespace boost::python;
 void export_attribute_event_info()
 {
     class_<Tango::AttributeEventInfo>("AttributeEventInfo")
+       .enable_pickling()
        .def_readwrite("ch_event", &Tango::AttributeEventInfo::ch_event)
        .def_readwrite("per_event", &Tango::AttributeEventInfo::per_event)
        .def_readwrite("arch_event", &Tango::AttributeEventInfo::arch_event)
diff --git a/src/boost/cpp/attribute_info.cpp b/src/boost/cpp/attribute_info.cpp
index 215ef9c..965daf6 100644
--- a/src/boost/cpp/attribute_info.cpp
+++ b/src/boost/cpp/attribute_info.cpp
@@ -31,6 +31,7 @@ void export_attribute_info()
     class_<Tango::AttributeInfo, bases<Tango::DeviceAttributeConfig> >
         ("AttributeInfo")
         .def(init<const Tango::AttributeInfo&>())
+        .enable_pickling()
         .def_readwrite("disp_level", &Tango::AttributeInfo::disp_level)
     ;
 }
diff --git a/src/boost/cpp/attribute_info_ex.cpp b/src/boost/cpp/attribute_info_ex.cpp
index eab4c13..11c7217 100644
--- a/src/boost/cpp/attribute_info_ex.cpp
+++ b/src/boost/cpp/attribute_info_ex.cpp
@@ -31,6 +31,7 @@ void export_attribute_info_ex()
     class_<Tango::AttributeInfoEx, bases<Tango::AttributeInfo> >
         ("AttributeInfoEx")
         .def(init<const Tango::AttributeInfoEx&>())
+        .enable_pickling()
         .def_readwrite("alarms", &Tango::AttributeInfoEx::alarms)
         .def_readwrite("events", &Tango::AttributeInfoEx::events)
         .def_readwrite("sys_extensions", &Tango::AttributeInfoEx::sys_extensions)
diff --git a/src/boost/cpp/change_event_info.cpp b/src/boost/cpp/change_event_info.cpp
index 261355b..b72c15c 100644
--- a/src/boost/cpp/change_event_info.cpp
+++ b/src/boost/cpp/change_event_info.cpp
@@ -29,6 +29,7 @@ using namespace boost::python;
 void export_change_event_info()
 {
     class_<Tango::ChangeEventInfo>("ChangeEventInfo")
+        .enable_pickling()
         .def_readwrite("rel_change", &Tango::ChangeEventInfo::rel_change)
         .def_readwrite("abs_change", &Tango::ChangeEventInfo::abs_change)
         .def_readwrite("extensions", &Tango::ChangeEventInfo::extensions)
diff --git a/src/boost/cpp/dev_error.cpp b/src/boost/cpp/dev_error.cpp
index c630721..1572fc6 100644
--- a/src/boost/cpp/dev_error.cpp
+++ b/src/boost/cpp/dev_error.cpp
@@ -25,25 +25,48 @@
 #include "pyutils.h"
 #include <tango.h>
 
-struct PyDevError
+namespace PyDevError
 {
-    static inline PyObject* get_reason(Tango::DevError &de)
-    { return from_char_to_str(de.reason); }
+    static void from_str_to_char(PyObject* in, CORBA::String_member& out)
+    {
+        if (PyUnicode_Check(in))
+        {
+            PyObject *bytes_in = PyUnicode_AsLatin1String(in);
+            out = CORBA::string_dup(PyBytes_AsString(bytes_in));
+            Py_DECREF(bytes_in);
+        }
+        else 
+        {
+            out = CORBA::string_dup(PyBytes_AsString(in));
+        }
+    }
 
-    static inline PyObject* get_desc(Tango::DevError &de)
-    { return from_char_to_str(de.desc); }
+    static inline PyObject* get_reason(Tango::DevError &self)
+    { return from_char_to_str(self.reason); }
 
-    static inline PyObject* get_origin(Tango::DevError &de)
-    { return from_char_to_str(de.origin); }
+    static inline void set_reason(Tango::DevError &self, PyObject *str)
+    { PyDevError::from_str_to_char(str, self.reason); }
 
+    static inline PyObject* get_desc(Tango::DevError &self)
+    { return from_char_to_str(self.desc); }
+
+    static inline void set_desc(Tango::DevError &self, PyObject *str)
+    { PyDevError::from_str_to_char(str, self.desc); }
+
+    static inline PyObject* get_origin(Tango::DevError &self)
+    { return from_char_to_str(self.origin); }
+
+    static inline void set_origin(Tango::DevError &self, PyObject *str)
+    { PyDevError::from_str_to_char(str, self.origin); }
 };
 
 void export_dev_error()
 {
     bopy::class_<Tango::DevError>("DevError")
-        .add_property("reason", &PyDevError::get_reason)
-        .def_readonly("severity", &Tango::DevError::severity)
-        .add_property("desc", &PyDevError::get_desc)
-        .add_property("origin", &PyDevError::get_origin)
+        .enable_pickling()
+        .add_property("reason", &PyDevError::get_reason, &PyDevError::set_reason)
+        .def_readwrite("severity", &Tango::DevError::severity)
+        .add_property("desc", &PyDevError::get_desc, &PyDevError::set_desc)
+        .add_property("origin", &PyDevError::get_origin, &PyDevError::set_origin)
     ;
 }
diff --git a/src/boost/cpp/device_attribute_config.cpp b/src/boost/cpp/device_attribute_config.cpp
index 9ad336c..620b137 100644
--- a/src/boost/cpp/device_attribute_config.cpp
+++ b/src/boost/cpp/device_attribute_config.cpp
@@ -22,14 +22,16 @@
 *******************************************************************************/
 
 #include "precompiled_header.hpp"
-#include <tango.h>
-
-using namespace boost::python;
+#include "pytgutils.h"
 
 void export_device_attribute_config()
 {
-    class_<Tango::DeviceAttributeConfig>("DeviceAttributeConfig")
-        .def(init<const Tango::DeviceAttributeConfig&>())
+    bopy::class_<Tango::DeviceAttributeConfig>("DeviceAttributeConfig")
+        .def(bopy::init<const Tango::DeviceAttributeConfig&>())
+
+        .enable_pickling()
+//        .def_pickle(PyDeviceAttributeConfig::PickleSuite())
+
         .def_readwrite("name", &Tango::DeviceAttributeConfig::name)
         .def_readwrite("writable", &Tango::DeviceAttributeConfig::writable)
         .def_readwrite("data_format", &Tango::DeviceAttributeConfig::data_format)
@@ -38,8 +40,10 @@ void export_device_attribute_config()
         .def_readwrite("max_dim_y", &Tango::DeviceAttributeConfig::max_dim_y)
         .def_readwrite("description", &Tango::DeviceAttributeConfig::description)
         //.def_readwrite("label", &Tango::DeviceAttributeConfig::label)
-        .add_property("label", make_getter(&Tango::DeviceAttributeConfig::label, return_value_policy<return_by_value>()),
-                               make_setter(&Tango::DeviceAttributeConfig::label, return_value_policy<return_by_value>()))
+        .add_property("label", bopy::make_getter(&Tango::DeviceAttributeConfig::label,
+                                                 bopy::return_value_policy<bopy::return_by_value>()),
+                               bopy::make_setter(&Tango::DeviceAttributeConfig::label,
+                                                 bopy::return_value_policy<bopy::return_by_value>()))
         .def_readwrite("unit", &Tango::DeviceAttributeConfig::unit)
         .def_readwrite("standard_unit", &Tango::DeviceAttributeConfig::standard_unit)
         .def_readwrite("display_unit", &Tango::DeviceAttributeConfig::display_unit)
diff --git a/src/boost/cpp/periodic_event_info.cpp b/src/boost/cpp/periodic_event_info.cpp
index 15b4c69..793a038 100644
--- a/src/boost/cpp/periodic_event_info.cpp
+++ b/src/boost/cpp/periodic_event_info.cpp
@@ -29,6 +29,7 @@ using namespace boost::python;
 void export_periodic_event_info()
 {
     class_<Tango::PeriodicEventInfo>("PeriodicEventInfo")
+        .enable_pickling()
         .def_readwrite("period", &Tango::PeriodicEventInfo::period)
         .def_readwrite("extensions", &Tango::PeriodicEventInfo::extensions)
     ;
diff --git a/src/boost/python/base_types.py b/src/boost/python/base_types.py
index 6e25eb9..909a0f4 100644
--- a/src/boost/python/base_types.py
+++ b/src/boost/python/base_types.py
@@ -39,10 +39,11 @@ from ._PyTango import (StdStringVector, StdLongVector, StdDoubleVector, \
     AttributeDimension, AttributeEventInfo, DeviceAttributeConfig, \
     AttributeInfo, AttributeInfoEx, ChangeEventInfo, PeriodicEventInfo, \
     DevCommandInfo, CommandInfo, DataReadyEventData, DeviceInfo, \
-    LockerInfo, PollDevice, TimeVal)
+    LockerInfo, PollDevice, TimeVal, AttrWriteType, AttrDataFormat, DispLevel)
 
 from .utils import document_method, is_integer
 from .utils import document_enum as __document_enum
+from .utils import seq_2_StdStringVector, StdStringVector_2_seq
 
 def __StdVector__add(self, seq):
     ret = seq.__class__(self)
@@ -85,7 +86,184 @@ def __fillVectorClass(klass):
     klass.__imul__ = __StdVector__imul
     klass.__original_getitem = klass.__getitem__
     klass.__getitem__ = __StdVector__getitem
-    
+
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+# DeviceAttributeConfig pickle
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+
+def __DeviceAttributeConfig__getinitargs__(self):
+    return ()
+
+def __DeviceAttributeConfig__getstate__(self):
+    ret = self.name, \
+          int(self.writable), \
+          int(self.data_format), \
+          self.data_type, \
+          self.max_dim_x, \
+          self.max_dim_y, \
+          self.description, \
+          self.label, \
+          self.unit, \
+          self.standard_unit, \
+          self.display_unit, \
+          self.format, \
+          self.min_value, \
+          self.max_value, \
+          self.min_alarm, \
+          self.max_alarm, \
+          self.writable_attr_name, \
+          StdStringVector_2_seq(self.extensions)
+    return ret
+
+def __DeviceAttributeConfig__setstate__(self, state):
+    self.name = state[0]
+    self.writable = AttrWriteType(state[1])
+    self.data_format = AttrDataFormat(state[2])
+    self.data_type = state[3]
+    self.max_dim_x = state[4]
+    self.max_dim_y = state[5]
+    self.description = state[6]
+    self.label = state[7]
+    self.unit = state[8]
+    self.standard_unit = state[9]
+    self.display_unit = state[10]
+    self.format = state[11]
+    self.min_value = state[12]
+    self.max_value = state[13]
+    self.min_alarm = state[14]
+    self.max_alarm = state[15]
+    self.writable_attr_name = state[16]
+    self.extensions = seq_2_StdStringVector(state[17])
+
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+# AttributeInfo pickle
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+
+def __AttributeInfo__getinitargs__(self):
+    return ()
+
+def __AttributeInfo__getstate__(self):
+    ret = list(__DeviceAttributeConfig__getstate__(self))
+    ret.append(int(self.disp_level))
+    return tuple(ret)
+
+def __AttributeInfo__setstate__(self, state):
+    __DeviceAttributeConfig__setstate__(self, state)
+    self.disp_level = DispLevel(state[18])
+
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+# AttributeAlarmInfo pickle
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+
+def __AttributeAlarmInfo__getinitargs__(self):
+    return ()
+
+def __AttributeAlarmInfo__getstate__(self):
+    return self.min_alarm, \
+           self.max_alarm, \
+           self.min_warning, \
+           self.max_warning, \
+           self.delta_t, \
+           self.delta_val, \
+           StdStringVector_2_seq(self.extensions)
+
+def __AttributeAlarmInfo__setstate__(self, state):
+    self.min_alarm = state[0]
+    self.max_alarm = state[1]
+    self.min_warning = state[2]
+    self.max_warning = state[3]
+    self.delta_t = state[4]
+    self.delta_val = state[5]
+    self.extensions = seq_2_StdStringVector(state[6])
+
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+# ChangeEventInfo pickle
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+
+def __ChangeEventInfo__getinitargs__(self):
+    return ()
+
+def __ChangeEventInfo__getstate__(self):
+    return self.rel_change, \
+           self.abs_change, \
+           StdStringVector_2_seq(self.extensions)
+
+def __ChangeEventInfo__setstate__(self, state):
+    self.rel_change = state[0]
+    self.abs_change = state[1]
+    self.extensions = seq_2_StdStringVector(state[2])
+
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+# PeriodicEventInfo pickle
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+
+def __PeriodicEventInfo__getinitargs__(self):
+    return ()
+
+def __PeriodicEventInfo__getstate__(self):
+    return self.period, \
+        StdStringVector_2_seq(self.extensions)
+
+def __PeriodicEventInfo__setstate__(self, state):
+    self.period = state[0]
+    self.extensions = seq_2_StdStringVector(state[1])
+
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+# ArchiveEventInfo pickle
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+
+def __ArchiveEventInfo__getinitargs__(self):
+    return ()
+
+def __ArchiveEventInfo__getstate__(self):
+    return self.archive_rel_change, \
+           self.archive_abs_change, \
+           self.archive_period, \
+           StdStringVector_2_seq(self.extensions)
+
+def __ArchiveEventInfo__setstate__(self, state):
+    self.archive_rel_change = state[0]
+    self.archive_abs_change = state[1]
+    self.archive_period = state[2]
+    self.extensions = seq_2_StdStringVector(state[3])
+
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+# AttributeEventInfo pickle
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+
+def __AttributeEventInfo__getinitargs__(self):
+    return ()
+
+def __AttributeEventInfo__getstate__(self):
+    return self.ch_event, \
+           self.per_event, \
+           self.arch_event
+
+def __AttributeEventInfo__setstate__(self, state):
+    self.ch_event = state[0]
+    self.per_event = state[1]
+    self.arch_event = state[2]
+
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+# AttributeInfoEx pickle
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+
+def __AttributeInfoEx__getinitargs__(self):
+    return ()
+
+def __AttributeInfoEx__getstate__(self):
+    ret = list(__AttributeInfo__getstate__(self))
+    ret.append(self.alarms)
+    ret.append(self.events)
+    ret.append(StdStringVector_2_seq(self.sys_extensions))
+    return tuple(ret)
+
+def __AttributeInfoEx__setstate__(self, state):
+    __AttributeInfo__setstate__(self, state)
+    self.alarms = state[19]
+    self.events = state[20]
+    self.sys_extensions = seq_2_StdStringVector(state[21])
+
 def __init_base_types():
     
     v_klasses = (StdStringVector,StdLongVector,StdDoubleVector,CommandInfoList, \
@@ -97,6 +275,39 @@ def __init_base_types():
     for v_klass in v_klasses:
         __fillVectorClass(v_klass)
 
+    DeviceAttributeConfig.__getinitargs__ = __DeviceAttributeConfig__getinitargs__
+    DeviceAttributeConfig.__getstate__ = __DeviceAttributeConfig__getstate__
+    DeviceAttributeConfig.__setstate__ = __DeviceAttributeConfig__setstate__
+
+    AttributeInfo.__getinitargs__ = __AttributeInfo__getinitargs__
+    AttributeInfo.__getstate__ = __AttributeInfo__getstate__
+    AttributeInfo.__setstate__ = __AttributeInfo__setstate__
+
+    AttributeAlarmInfo.__getinitargs__ = __AttributeAlarmInfo__getinitargs__
+    AttributeAlarmInfo.__getstate__ = __AttributeAlarmInfo__getstate__
+    AttributeAlarmInfo.__setstate__ = __AttributeAlarmInfo__setstate__
+
+    ChangeEventInfo.__getinitargs__ = __ChangeEventInfo__getinitargs__
+    ChangeEventInfo.__getstate__ = __ChangeEventInfo__getstate__
+    ChangeEventInfo.__setstate__ = __ChangeEventInfo__setstate__
+
+    PeriodicEventInfo.__getinitargs__ = __PeriodicEventInfo__getinitargs__
+    PeriodicEventInfo.__getstate__ = __PeriodicEventInfo__getstate__
+    PeriodicEventInfo.__setstate__ = __PeriodicEventInfo__setstate__
+
+    ArchiveEventInfo.__getinitargs__ = __ArchiveEventInfo__getinitargs__
+    ArchiveEventInfo.__getstate__ = __ArchiveEventInfo__getstate__
+    ArchiveEventInfo.__setstate__ = __ArchiveEventInfo__setstate__
+
+    AttributeEventInfo.__getinitargs__ = __AttributeEventInfo__getinitargs__
+    AttributeEventInfo.__getstate__ = __AttributeEventInfo__getstate__
+    AttributeEventInfo.__setstate__ = __AttributeEventInfo__setstate__
+
+    AttributeInfoEx.__getinitargs__ = __AttributeInfoEx__getinitargs__
+    AttributeInfoEx.__getstate__ = __AttributeInfoEx__getstate__
+    AttributeInfoEx.__setstate__ = __AttributeInfoEx__setstate__
+    
+
 def __doc_base_types():
     
     def document_enum(enum_name, desc):
diff --git a/src/boost/python/exception.py b/src/boost/python/exception.py
index b172e04..55c799d 100644
--- a/src/boost/python/exception.py
+++ b/src/boost/python/exception.py
@@ -30,7 +30,7 @@ __all__ = ["exception_init"]
 __docformat__ = "restructuredtext"
 
 from .utils import document_static_method as __document_static_method
-from ._PyTango import Except, DevError
+from ._PyTango import Except, DevError, ErrSeverity
 
 def __to_dev_failed(exc_type=None, exc_value=None, traceback=None):
     """to_dev_failed(exc_type, exc_value, traceback) -> PyTango.DevFailed
@@ -58,6 +58,27 @@ def __to_dev_failed(exc_type=None, exc_value=None, traceback=None):
     except Exception as e:
         return e
 
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+# DevError pickle
+# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
+
+def __DevError__getinitargs__(self):
+    return ()
+
+def __DevError__getstate__(self):
+    return self.reason, self.desc, self.origin, int(self.severity)
+
+def __DevError__setstate__(self, state):
+    self.reason = state[0]
+    self.desc = state[1]
+    self.origin = state[2]
+    self.severity = ErrSeverity(state[3])
+
+def __init_DevError():
+    DevError.__getinitargs__ = __DevError__getinitargs__
+    DevError.__getstate__ = __DevError__getstate__
+    DevError.__setstate__ = __DevError__setstate__
+
 def __init_Except():
     Except.to_dev_failed = staticmethod(__to_dev_failed)
 
@@ -162,6 +183,7 @@ def __doc_DevError():
   
 def exception_init(doc=True):
     __init_Except()
+    __init_DevError()
     if doc:
         __doc_Except()
-        __doc_DevError()
\ No newline at end of file
+        __doc_DevError()
diff --git a/src/boost/python/utils.py b/src/boost/python/utils.py
index 6de5409..c47c8e1 100644
--- a/src/boost/python/utils.py
+++ b/src/boost/python/utils.py
@@ -30,11 +30,13 @@ from __future__ import print_function
 
 __all__ = [ "is_pure_str", "is_seq", "is_non_str_seq", "is_integer",
             "is_number", "is_scalar_type", "is_array_type", "is_numerical_type",
-            "is_int_type", "is_float_type", "obj_2_str", "seqStr_2_obj",
+            "is_int_type", "is_float_type", "is_bool_type", "is_bin_type",
+            "is_str_type", "obj_2_str", "seqStr_2_obj",
             "document_method", "document_static_method", "document_enum",
             "CaselessList", "CaselessDict", "EventCallBack", "get_home",
             "from_version_str_to_hex_str", "from_version_str_to_int",
-            "server_run", "decorator" ]
+            "server_run", "decorator",
+            "seq_2_StdStringVector", "StdStringVector_2_seq" ]
 
 __docformat__ = "restructuredtext"
 
@@ -60,9 +62,10 @@ _scalar_numerical_types = _scalar_int_types + _scalar_float_types
 
 _scalar_str_types = (CmdArgType.DevString, CmdArgType.ConstDevString,)
 
+_scalar_bool_types = (CmdArgType.DevBoolean,)
+
 _scalar_types = _scalar_numerical_types + _scalar_str_types + \
-    (CmdArgType.DevBoolean, CmdArgType.DevEncoded,
-     CmdArgType.DevUChar, CmdArgType.DevVoid)
+    _scalar_bool_types + (CmdArgType.DevEncoded, CmdArgType.DevUChar)
 
 _array_int_types = (CmdArgType.DevVarShortArray, CmdArgType.DevVarUShortArray,
                     CmdArgType.DevVarLongArray, CmdArgType.DevVarULongArray,
@@ -72,10 +75,15 @@ _array_float_types = (CmdArgType.DevVarFloatArray, CmdArgType.DevVarDoubleArray)
 
 _array_numerical_types = _array_int_types + _array_float_types
 
-_array_types = _array_numerical_types + (CmdArgType.DevVarBooleanArray,
-    CmdArgType.DevVarStringArray,
-    CmdArgType.DevVarCharArray, CmdArgType.DevVarDoubleStringArray,
-    CmdArgType.DevVarLongStringArray)
+_array_str_types = (CmdArgType.DevVarStringArray,)
+
+_array_bool_types = (CmdArgType.DevVarBooleanArray,)
+
+_array_types = _array_numerical_types + _array_bool_types + _array_str_types + \
+    (CmdArgType.DevVarCharArray, 
+     CmdArgType.DevVarDoubleStringArray, CmdArgType.DevVarLongStringArray)
+
+_binary_types = (CmdArgType.DevEncoded, CmdArgType.DevVarCharArray)
 
 _scalar_to_array_type = {
     CmdArgType.DevBoolean : CmdArgType.DevVarBooleanArray,
@@ -249,6 +257,65 @@ def is_float(tg_type, inc_array=False):
 
 is_float_type = is_float
 
+def is_bool(tg_type, inc_array=False):
+    """Tells if the given tango type is boolean
+    
+    :param tg_type: tango type
+    :type tg_type: :class:`PyTango.CmdArgType`
+    :param inc_array: (optional, default is False) determines if include array 
+                      in the list of checked types
+    :type inc_array: :py:obj:`bool`
+    
+    :return: True if the given tango type is boolean or False otherwise
+    :rtype: :py:obj:`bool`
+    """
+    global _scalar_bool_types, _array_bool_types
+    if tg_type in _scalar_bool_types:
+        return True
+    if not inc_array:
+        return False
+    return tg_type in _array_bool_types
+
+is_bool_type = is_bool
+
+def is_str(tg_type, inc_array=False):
+    """Tells if the given tango type is string
+    
+    :param tg_type: tango type
+    :type tg_type: :class:`PyTango.CmdArgType`
+    :param inc_array: (optional, default is False) determines if include array 
+                      in the list of checked types
+    :type inc_array: :py:obj:`bool`
+    
+    :return: True if the given tango type is string or False otherwise
+    :rtype: :py:obj:`bool`
+    """
+    global _scalar_str_types, _array_str_types
+    if tg_type in _scalar_str_types:
+        return True
+    if not inc_array:
+        return False
+    return tg_type in _array_str_types
+
+is_str_type = is_str
+
+def is_bin(tg_type, inc_array=False):
+    """Tells if the given tango type is binary
+    
+    :param tg_type: tango type
+    :type tg_type: :class:`PyTango.CmdArgType`
+    :param inc_array: (optional, default is False) determines if include array 
+                      in the list of checked types
+    :type inc_array: :py:obj:`bool`
+    
+    :return: True if the given tango type is binary or False otherwise
+    :rtype: :py:obj:`bool`
+    """
+    global _scalar_bin_types
+    return tg_type in _scalar_bin_types
+
+is_bin_type = is_bin
+
 def seq_2_StdStringVector(seq, vec=None):
     """Converts a python sequence<str> object to a :class:`PyTango.StdStringVector`
         

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