[pytango] 32/483: fixes #3287184
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:21 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 a2ae12d18ed27cd297117fedbd856c27e97b9280
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date: Fri May 6 12:06:34 2011 +0000
fixes #3287184
git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@16805 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
Makefile | 16 +++++++++-----
PyTango/device_class.py | 13 ++++++++++-
PyTango/encoded_attribute.py | 4 +++-
src/base_types.cpp | 18 +++++++++++++++
src/pyutils.h | 48 ++++++++++++++++++++++++++++++++++++++++
src/server/device_class.cpp | 2 +-
src/server/encoded_attribute.cpp | 16 ++++++++++++++
7 files changed, 109 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index 635ef96..8f95c17 100644
--- a/Makefile
+++ b/Makefile
@@ -77,7 +77,8 @@ $(TANGO_INC)/tango \
$(PY_INC) \
$(NUMPY_INC)
-LIBNAME = _PyTango.so
+LIB_NAME = _PyTango.so
+LIB_SYMB_NAME = $(LIB_NAME).dbg
OBJS = \
$(OBJS_DIR)/api_util.o \
@@ -160,7 +161,7 @@ device_impl.h
all: build
-build: init $(LIBNAME)
+build: init $(LIB_NAME)
init:
mkdir -p $(OBJS_DIR)
@@ -186,8 +187,12 @@ $(OBJS_DIR)/%.o: $(SRC_DIR)/server/%.cpp
# The shared libs
#
-$(LIBNAME): $(OBJS)
- $(LN) $(OBJS) $(LN_DIRS) $(LN_LIBS) -o $(OBJS_DIR)/$(LIBNAME) $(LN_VER)
+$(LIB_NAME): $(OBJS)
+ $(LN) $(OBJS) $(LN_DIRS) $(LN_LIBS) -o $(OBJS_DIR)/$(LIB_NAME) $(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:
rm -f *.o core
@@ -197,4 +202,5 @@ clean:
install: build
mkdir -p $(prefix)
rsync -r PyTango $(prefix)
- rsync $(OBJS_DIR)/$(LIBNAME) $(prefix)/PyTango
+ rsync $(OBJS_DIR)/$(LIB_NAME) $(prefix)/PyTango
+ rsync $(OBJS_DIR)/$(LIB_SYMB_NAME) $(prefix)/PyTango
diff --git a/PyTango/device_class.py b/PyTango/device_class.py
index f09f8df..e494694 100644
--- a/PyTango/device_class.py
+++ b/PyTango/device_class.py
@@ -787,13 +787,24 @@ def __doc_DeviceClass():
document_method("register_signal", """
register_signal(self, signo) -> None
+ register_signal(self, signo, own_handler=false) -> None
Register a signal.
Register this class as class to be informed when signal signo
- is sent to to the device server process
+ is sent to to the device server process.
+ The second version of the method is available only under Linux.
Parameters :
- signo : (int) signal identifier
+ - own_handler : (bool) true if you want the device signal handler
+ to be executed in its own handler instead of being
+ executed by the signal thread. If this parameter
+ is set to true, care should be taken on how the
+ handler is written. A default false value is provided
+
+ Throws PyTango.DevFailed:
+ - if the signal number is out of range
+ - if the operating system failed to register a signal for the process.
Return : None
""" )
diff --git a/PyTango/encoded_attribute.py b/PyTango/encoded_attribute.py
index d469a1e..afaefd5 100644
--- a/PyTango/encoded_attribute.py
+++ b/PyTango/encoded_attribute.py
@@ -32,6 +32,7 @@ __docformat__ = "restructuredtext"
import types
import operator
+import _PyTango
from _PyTango import EncodedAttribute
from _PyTango import ExtractAs
from _PyTango import _ImageFormat
@@ -169,7 +170,7 @@ def __EncodedAttribute_encode_gray16(self, gray16, width=0, height=0):
"""Encode a 16 bit grayscale image (no compression)
:param gray16: an object containning image information
- :type gray16: :py:obj:`str` or :class:`numpy.ndarray` or seq< seq<element> >
+ :type gray16: :py:obj:`str` or :py:obj:`buffer` or :class:`numpy.ndarray` or seq< seq<element> >
:param width: image width. **MUST** be given if gray16 is a string or
if it is a :class:`numpy.ndarray` with ndims != 2.
Otherwise it is calculated internally.
@@ -208,6 +209,7 @@ def __EncodedAttribute_encode_gray16(self, gray16, width=0, height=0):
raise ValueError("When giving a string as data, you must also "
"supply width and height")
+
if np and isinstance(gray16, np.ndarray):
if gray16.ndim != 2:
if not width or not height:
diff --git a/src/base_types.cpp b/src/base_types.cpp
index 64b1390..fcae705 100644
--- a/src/base_types.cpp
+++ b/src/base_types.cpp
@@ -180,6 +180,22 @@ int raise_asynch_exception(long thread_id, boost::python::object exp_klass)
return PyThreadState_SetAsyncExc(thread_id, exp_klass.ptr());
}
+bool isBufferLikeType(PyObject* obj)
+{
+#if PY_VERSION_HEX < 0x02060000
+ // Returns true for buffer
+ if (PyBuffer_Check(obj))
+ return true;
+ if (PyString_Check(obj))
+ return true;
+#else
+ // Returns true for str, buffer bytes, bytearray, memoryview
+ if (PyObject_CheckBuffer(obj))
+ return true;
+#endif
+ return false;
+}
+
void export_base_types()
{
enum_<PyTango::ExtractAs>("ExtractAs")
@@ -347,4 +363,6 @@ void export_base_types()
export_time_val();
def("raise_asynch_exception", &raise_asynch_exception);
+
+ def("isBufferLikeType", &isBufferLikeType);
}
diff --git a/src/pyutils.h b/src/pyutils.h
index df43009..36c21f1 100644
--- a/src/pyutils.h
+++ b/src/pyutils.h
@@ -31,6 +31,11 @@
typedef int Py_ssize_t;
#endif
+// -----------------------------------------------------------------------------
+// The following section contains functions that changed signature from <=2.4
+// using char* to >=2.5 using const char*. Basically we defined them here using
+// const std::string
+
inline PyObject *PyObject_GetAttrString_(PyObject *o, const std::string &attr_name)
{
#if PY_VERSION_HEX < 0x02050000
@@ -51,6 +56,49 @@ inline PyObject *PyImport_ImportModule_(const std::string &name)
return PyImport_ImportModule(attr);
}
+// -----------------------------------------------------------------------------
+// The following section defines missing symbols in python <3.0 with macros
+
+#if PY_VERSION_HEX < 0x02070000
+ #if PY_VERSION_HEX < 0x02060000
+ #define PyObject_CheckBuffer(object) (0)
+
+ #define PyObject_GetBuffer(obj, view, flags) (PyErr_SetString(PyExc_NotImplementedError, \
+ "new buffer interface is not available"), -1)
+ #define PyBuffer_FillInfo(view, obj, buf, len, readonly, flags) (PyErr_SetString(PyExc_NotImplementedError, \
+ "new buffer interface is not available"), -1)
+ #define PyBuffer_Release(obj) (PyErr_SetString(PyExc_NotImplementedError, \
+ "new buffer interface is not available"), -1)
+ // Bytes->String
+ #define PyBytes_FromStringAndSize PyString_FromStringAndSize
+ #define PyBytes_FromString PyString_FromString
+ #define PyBytes_AsString PyString_AsString
+ #define PyBytes_Size PyString_Size
+ #endif
+
+ #define PyMemoryView_FromBuffer(info) (PyErr_SetString(PyExc_NotImplementedError, \
+ "new buffer interface is not available"), (PyObject *)NULL)
+ #define PyMemoryView_FromObject(object) (PyErr_SetString(PyExc_NotImplementedError, \
+ "new buffer interface is not available"), (PyObject *)NULL)
+#endif
+
+#if PY_VERSION_HEX >= 0x03000000
+ // for buffers
+ #define Py_END_OF_BUFFER ((Py_ssize_t) 0)
+
+ #define PyObject_CheckReadBuffer(object) (0)
+
+ #define PyBuffer_FromMemory(ptr, s) (PyErr_SetString(PyExc_NotImplementedError, \
+ "old buffer interface is not available"), (PyObject *)NULL)
+ #define PyBuffer_FromReadWriteMemory(ptr, s) (PyErr_SetString(PyExc_NotImplementedError, \
+ "old buffer interface is not available"), (PyObject *)NULL)
+ #define PyBuffer_FromObject(object, offset, size) (PyErr_SetString(PyExc_NotImplementedError, \
+ "old buffer interface is not available"), (PyObject *)NULL)
+ #define PyBuffer_FromReadWriteObject(object, offset, size) (PyErr_SetString(PyExc_NotImplementedError, \
+ "old buffer interface is not available"), (PyObject *)NULL)
+
+#endif
+
inline void raise_(PyObject *type, const char *message)
{
PyErr_SetString(type, message);
diff --git a/src/server/device_class.cpp b/src/server/device_class.cpp
index 3995308..c53164a 100644
--- a/src/server/device_class.cpp
+++ b/src/server/device_class.cpp
@@ -278,7 +278,7 @@ namespace PyDeviceClass
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS (export_device_overload,
CppDeviceClass::export_device, 1, 2)
-#if ((defined sun) || (defined WIN32))
+#if !(defined __linux)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS (register_signal_overload,
Tango::DeviceClass::register_signal, 1, 1)
#else
diff --git a/src/server/encoded_attribute.cpp b/src/server/encoded_attribute.cpp
index 2842f52..ebb6eb1 100644
--- a/src/server/encoded_attribute.cpp
+++ b/src/server/encoded_attribute.cpp
@@ -57,6 +57,7 @@ namespace PyEncodedAttribute
self.encode_gray8(buffer, w, h);
return;
}
+#ifndef DISABLE_PYTANGO_NUMPY
else if (PyArray_Check(py_value_ptr))
{
w = PyArray_DIM(py_value_ptr, 1);
@@ -66,6 +67,7 @@ namespace PyEncodedAttribute
self.encode_gray8(buffer, w, h);
return;
}
+#endif
// It must be a py sequence
// we are sure that w and h are given by python (see encoded_attribute.py)
unsigned char b[w*h];
@@ -167,6 +169,7 @@ namespace PyEncodedAttribute
self.encode_jpeg_gray8(buffer, w, h, quality);
return;
}
+#ifndef DISABLE_PYTANGO_NUMPY
else if (PyArray_Check(py_value_ptr))
{
w = PyArray_DIM(py_value_ptr, 1);
@@ -176,6 +179,7 @@ namespace PyEncodedAttribute
self.encode_jpeg_gray8(buffer, w, h, quality);
return;
}
+#endif
// It must be a py sequence
// we are sure that w and h are given by python (see encoded_attribute.py)
unsigned char b[w*h];
@@ -277,6 +281,7 @@ namespace PyEncodedAttribute
self.encode_gray16(buffer, w, h);
return;
}
+#ifndef DISABLE_PYTANGO_NUMPY
else if (PyArray_Check(py_value_ptr))
{
w = PyArray_DIM(py_value_ptr, 1);
@@ -286,6 +291,7 @@ namespace PyEncodedAttribute
self.encode_gray16(buffer, w, h);
return;
}
+#endif
// It must be a py sequence
// we are sure that w and h are given by python (see encoded_attribute.py)
unsigned short b[w*h];
@@ -386,12 +392,14 @@ namespace PyEncodedAttribute
self.encode_rgb24(buffer, w, h);
return;
}
+#ifndef DISABLE_PYTANGO_NUMPY
else if (PyArray_Check(py_value_ptr))
{
buffer = static_cast<unsigned char*>(PyArray_DATA(py_value_ptr));
self.encode_rgb24(buffer, w, h);
return;
}
+#endif
// It must be a py sequence
// we are sure that w and h are given by python (see encoded_attribute.py)
unsigned char b[w*h];
@@ -496,12 +504,14 @@ namespace PyEncodedAttribute
self.encode_jpeg_rgb24(buffer, w, h, quality);
return;
}
+#ifndef DISABLE_PYTANGO_NUMPY
else if (PyArray_Check(py_value_ptr))
{
buffer = static_cast<unsigned char*>(PyArray_DATA(py_value_ptr));
self.encode_jpeg_rgb24(buffer, w, h, quality);
return;
}
+#endif
// It must be a py sequence
// we are sure that w and h are given by python (see encoded_attribute.py)
unsigned char b[w*h];
@@ -606,12 +616,14 @@ namespace PyEncodedAttribute
self.encode_jpeg_rgb32(buffer, w, h, quality);
return;
}
+#ifndef DISABLE_PYTANGO_NUMPY
else if (PyArray_Check(py_value_ptr))
{
buffer = static_cast<unsigned char*>(PyArray_DATA(py_value_ptr));
self.encode_jpeg_rgb32(buffer, w, h, quality);
return;
}
+#endif
// It must be a py sequence
// we are sure that w and h are given by python (see encoded_attribute.py)
unsigned char b[w*h];
@@ -856,6 +868,7 @@ namespace PyEncodedAttribute
switch (extract_as)
{
case PyTango::ExtractAsNumpy:
+#ifndef DISABLE_PYTANGO_NUMPY
{
npy_intp dims[2] = { height, width };
ret = PyArray_SimpleNewFromData(2, dims, NPY_USHORT, ch_ptr);
@@ -885,6 +898,7 @@ namespace PyEncodedAttribute
PyArray_BASE(ret) = guard;
break;
}
+#endif
case PyTango::ExtractAsString:
{
ret = PyTuple_New(3);
@@ -992,6 +1006,7 @@ namespace PyEncodedAttribute
switch (extract_as)
{
case PyTango::ExtractAsNumpy:
+#ifndef DISABLE_PYTANGO_NUMPY
{
npy_intp dims[2] = { height, width };
ret = PyArray_SimpleNewFromData(2, dims, NPY_UINT32, ch_ptr);
@@ -1021,6 +1036,7 @@ namespace PyEncodedAttribute
PyArray_BASE(ret) = guard;
break;
}
+#endif
case PyTango::ExtractAsString:
{
ret = PyTuple_New(3);
--
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