[pytango] 173/483: prepare 8.0.3
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:37 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 4b78a0331e2269c1281920d910b854dd039b7850
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date: Fri Nov 9 16:31:40 2012 +0000
prepare 8.0.3
git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@21556 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
PyTango/api2.py | 126 ++++++++++---------------
PyTango/db.py | 4 +-
PyTango/ipython/ipython_00_11/ipython_00_11.py | 41 ++++----
PyTango/utils.py | 71 +++++++++++---
src/constants.cpp | 69 ++++++++++++++
src/server/attribute.cpp | 2 +-
6 files changed, 202 insertions(+), 111 deletions(-)
diff --git a/PyTango/api2.py b/PyTango/api2.py
index c6ca9b5..3a0672d 100644
--- a/PyTango/api2.py
+++ b/PyTango/api2.py
@@ -533,84 +533,60 @@ native :obj:`property` function. For exampke, to declare a scalar,
It receives multiple keyword arguments.
- :param name: alternative attribute name [default: class member name]
- :type name: :obj:`str`
- :param dtype: data type (see :ref:`Data type equivalence <pytango-api2-datatypes>`)
- [default: :obj:`~PyTango.CmdArgType`\ ``.DevDouble``]
- :type dtype: :obj:`object`
- :param dformat: data format [default: :obj:`~PyTango.AttrDataFormat`\ ``.SCALAR``]
- :type dformat: :obj:`~PyTango.AttrDataFormat`
- :param max_dim_x: maximum size for x dimension (ignored for
- :obj:`~PyTango.AttrDataFormat`\ ``.SCALAR`` format) [default: 1]
- :type max_dim_x: :obj:`int`
- :param max_dim_y: maximum size for y dimension (ignored for
- :obj:`~PyTango.AttrDataFormat`\ ``.SCALAR`` and
- :obj:`~PyTango.AttrDataFormat`\ ``.SPECTRUM`` formats) [default: 0]
- :type max_dim_y: :obj:`int`
- :param display_level: display level [default: :obj:`~PyTango.DisLevel`\ ``.OPERATOR``]
- :type display_level: :obj:`~PyTango.DispLevel`
- :param polling_period: polling period [default: -1, meaning no polling]
- :type polling_period: :obj:`int`
- :param memorized: attribute should or not be memorized [default: False]
- :type memorized: :obj:`bool`
- :param hw_memorized: attribute write method should be called at startup when
- restoring memorize value (dangerous!) [default: False]
- :type hw_memorized: :obj:`bool`
- :param access: read/write access. [default: if no fread and no fwrite methods
- are given it is :obj:`~PyTango.AttrWriteType`\ ``.READ``. If
- only fread is given then :obj:`~PyTango.AttrWriteType`\ ``.READ``.
- if only fwrite is given then :obj:`~PyTango.AttrWriteType`\ ``.WRITE``.
- if both fread and fwrite are given then :obj:`~PyTango.AttrWriteType`\ ``.READ_WRITE``
- :type access: :obj:`~PyTango.AttrWriteType`
- :param fread: read method name or method object [default: 'read_<attr_name>']
- :type fread: :obj:`str` or :obj:`callable`
- :param fwrite: write method name or method object [default: 'write_<attr_name>']
- :type fwrite: :obj:`str` or :obj:`callable`
- :param is_allowed: is allowed method name or method object [default: 'is_<attr_name>_allowed']
- :type is_allowed: :obj:`str` or :obj:`callable`
- :param label: attribute label [default: attribute name]
- :type label: :obj:`str`
- :param description: attribute description [default: empty string]
- :type description: :obj:`str`
- :param unit: attribute unit [default: empty string]
- :type unit: :obj:`str`
- :param standard_unit: attribute standard unit [default: empty string]
- :type standard_unit: :obj:`str`
- :param display_unit: attribute display unit [default: empty string]
- :type display_unit: :obj:`str`
- :param format: attribute representation format [default: '6.2f']
- :type format: :obj:`str`
- :param min_value: attribute minimum allowed value [default: None]
- :type min_value: :obj:`str`
- :param max_value: attribute maximum allowed value [default: None]
- :type max_value: :obj:`str`
- :param min_alarm: minimum value to trigger attribute alarm [default: None]
- :type min_alarm: :obj:`str`
- :param max_alarm: maxmimum value to trigger attribute alarm [default: None]
- :type max_alarm: :obj:`str`
- :param min_warning: minimum value to trigger attribute warning [default: None]
- :type min_warning: :obj:`str`
- :param max_warning: attribute maxmimum value to trigger attribute warning [default: None]
- :type max_warning: :obj:`str`
- :param delta_val: attribute
- :type delta_val: :obj:`str`
- :param delta_t: attribute
- :type delta_t: :obj:`str`
- :param abs_change: attribute
- :type abs_change: :obj:`str`
- :param rel_change: attribute
- :type rel_change: :obj:`str`
- :param period: attribute
- :type period: :obj:`str`
- :param archive_abs_change: attribute
- :type archive_abs_change: :obj:`str`
- :param archive_rel_change: attribute
- :type archive_rel_change: :obj:`str`
- :param archive_period: attribute
- :type archive_period: :obj:`str`
+===================== ========================================== ============================================== =======================================================================================
+parameter type default value description
+===================== ========================================== ============================================== =======================================================================================
+name :obj:`str` class member name alternative attribute name
+dtype :obj:`object` :obj:`~PyTango.CmdArgType`\ ``.DevDouble`` data type (see :ref:`Data type equivalence <pytango-api2-datatypes>`)
+dformat :obj:`~PyTango.AttrDataFormat` :obj:`~PyTango.AttrDataFormat`\ ``.SCALAR`` data format
+max_dim_x :obj:`int` 1 maximum size for x dimension (ignored for SCALAR format)
+max_dim_y :obj:`int` 0 maximum size for y dimension (ignored for SCALAR and SPECTRUM formats)
+display_level :obj:`~PyTango.DispLevel` :obj:`~PyTango.DisLevel`\ ``.OPERATOR`` display level
+polling_period :obj:`int` -1 polling period
+memorized :obj:`bool` False attribute should or not be memorized
+hw_memorized :obj:`bool` False write method should be called at startup when restoring memorize value (dangerous!)
+param access :obj:`~PyTango.AttrWriteType` :obj:`~PyTango.AttrWriteType`\ ``.READ`` read only/ read write / write only access
+fread :obj:`str` or :obj:`callable` 'read_<attr_name>' read method name or method object
+fwrite :obj:`str` or :obj:`callable` 'write_<attr_name>' write method name or method object
+is_allowed :obj:`str` or :obj:`callable` 'is_<attr_name>_allowed' is allowed method name or method object
+label :obj:`str` '<attr_name>' attribute label
+description :obj:`str` '' attribute description
+unit :obj:`str` '' physical units the attribute value is in
+standard_unit :obj:`str` '' physical standard unit
+display_unit :obj:`str` '' physical display unit (hint for clients)
+format :obj:`str` '6.2f' attribute representation format
+min_value :obj:`str` None minimum allowed value
+max_value :obj:`str` None maximum allowed value
+min_alarm :obj:`str` None minimum value to trigger attribute alarm
+max_alarm :obj:`str` None maximum value to trigger attribute alarm
+min_warning :obj:`str` None minimum value to trigger attribute warning
+max_warning :obj:`str` None maximum value to trigger attribute warning
+delta_val :obj:`str` None
+delta_t :obj:`str` None
+abs_change :obj:`str` None minimum value change between events that causes event filter to send the event
+rel_change :obj:`str` None minimum relative change between events that causes event filter to send the event (%)
+period :obj:`str` None
+archive_abs_change :obj:`str` None
+archive_rel_change :obj:`str` None
+archive_period :obj:`str` None
+===================== ========================================== ============================================== =======================================================================================
.. _pytango-api2-datatypes:
+The `dtype` parameter in :func:`attribute` is not retricted to the :obj:`~PyTango.CmdArgType options.
+For example, to define a :obj:`~PyTango.CmdArgType`\ ``.DevLong`` attribute you
+have several possibilities:
+
+ #. :obj:`int`
+ #. 'int'
+ #. 'int32'
+ #. 'integer'
+ #. :obj:`~PyTango.CmdArgType`\ ``.DevLong``
+ #. 'DevLong'
+ #. :obj:`numpy.int32`
+
+Below is the complete table of equivalences.
+
.. rubric:: Data type equivalence
""" + __type_doc
diff --git a/PyTango/db.py b/PyTango/db.py
index 8ac9034..dad4d9a 100644
--- a/PyTango/db.py
+++ b/PyTango/db.py
@@ -521,7 +521,9 @@ def __Database__put_device_attribute_property(self, dev_name, value):
if is_non_str_seq(v2):
seq_2_StdStringVector(v2, db_datum.value_string)
else:
- db_datum.value_string.append(str(v2))
+ if not is_pure_str(v2):
+ v2 = repr(v2)
+ db_datum.value_string.append(v2)
new_value.append(db_datum)
value = new_value
else:
diff --git a/PyTango/ipython/ipython_00_11/ipython_00_11.py b/PyTango/ipython/ipython_00_11/ipython_00_11.py
index c2e0526..38a951c 100644
--- a/PyTango/ipython/ipython_00_11/ipython_00_11.py
+++ b/PyTango/ipython/ipython_00_11/ipython_00_11.py
@@ -1115,26 +1115,6 @@ def init_display(ip):
html_formatter.for_type(PyTango.GroupAttrReply, display_groupreply_html)
html_formatter.for_type(PyTango.GroupCmdReply, display_groupreply_html)
-# overwrite the original IPython Qt widget with our own so we can put a
-# customized banner. IPython may have been installed without Qt support so we
-# protect this code agaist an import error
-try:
- from IPython.utils.traitlets import Unicode
- from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
-
- class ITangoConsole(RichIPythonWidget):
-
- banner = Unicode(config=True)
-
- def _banner_default(self):
- config = get_config()
- return config.ITangoConsole.banner
-
- import IPython.frontend.qt.console.qtconsoleapp
- IPythonQtConsoleApp = IPython.frontend.qt.console.qtconsoleapp.IPythonQtConsoleApp
- IPythonQtConsoleApp.widget_factory = ITangoConsole
-except ImportError:
- pass
def init_ipython(ip=None, store=True, pytango=True, colors=True, console=True,
magic=True):
@@ -1268,6 +1248,27 @@ def unload_ipython_extension(ipython):
def run():
+ # overwrite the original IPython Qt widget with our own so we can put a
+ # customized banner. IPython may have been installed without Qt support so we
+ # protect this code against an import error
+ try:
+ from IPython.utils.traitlets import Unicode
+ from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
+
+ class ITangoConsole(RichIPythonWidget):
+
+ banner = Unicode(config=True)
+
+ def _banner_default(self):
+ config = get_config()
+ return config.ITangoConsole.banner
+
+ import IPython.frontend.qt.console.qtconsoleapp
+ IPythonQtConsoleApp = IPython.frontend.qt.console.qtconsoleapp.IPythonQtConsoleApp
+ IPythonQtConsoleApp.widget_factory = ITangoConsole
+ except ImportError:
+ pass
+
argv = sys.argv
try:
diff --git a/PyTango/utils.py b/PyTango/utils.py
index 69a3509..6de5409 100644
--- a/PyTango/utils.py
+++ b/PyTango/utils.py
@@ -265,7 +265,8 @@ def seq_2_StdStringVector(seq, vec=None):
vec = StdStringVector()
if not isinstance(vec, StdStringVector):
raise TypeError('vec must be a PyTango.StdStringVector')
- for e in seq: vec.append(str(e))
+ for e in seq:
+ vec.append(str(e))
return vec
def StdStringVector_2_seq(vec, seq=None):
@@ -281,7 +282,8 @@ def StdStringVector_2_seq(vec, seq=None):
if seq is None: seq = []
if not isinstance(vec, StdStringVector):
raise TypeError('vec must be a PyTango.StdStringVector')
- for e in vec: seq.append(str(e))
+ for e in vec:
+ seq.append(str(e))
return seq
def seq_2_StdDoubleVector(seq, vec=None):
@@ -300,7 +302,8 @@ def seq_2_StdDoubleVector(seq, vec=None):
vec = StdDoubleVector()
if not isinstance(vec, StdDoubleVector):
raise TypeError('vec must be a PyTango.StdDoubleVector')
- for e in seq: vec.append(str(e))
+ for e in seq:
+ vec.append(str(e))
return vec
def StdDoubleVector_2_seq(vec, seq=None):
@@ -1044,7 +1047,7 @@ def from_version_str_to_hex_str(version_str):
def from_version_str_to_int(version_str):
return int(from_version_str_to_hex_str(version_str, 16))
-def __server_run(classes, args=None, msg_stream=sys.stderr):
+def __server_run(classes, args=None, msg_stream=sys.stderr, util=None):
import PyTango
if msg_stream is None:
import io
@@ -1052,7 +1055,9 @@ def __server_run(classes, args=None, msg_stream=sys.stderr):
if args is None:
args = sys.argv
- util = PyTango.Util(args)
+
+ if util is None:
+ util = PyTango.Util(args)
if is_seq(classes):
for klass_info in classes:
@@ -1077,21 +1082,48 @@ def __server_run(classes, args=None, msg_stream=sys.stderr):
u_instance.server_init()
msg_stream.write("Ready to accept request\n")
u_instance.server_run()
+ return util
-def server_run(classes, args=None, msg_stream=sys.stderr, verbose=False):
+def server_run(classes, args=None, msg_stream=sys.stderr, verbose=False, util=None):
"""Provides a simple way to run a tango server. It handles exceptions
- by writting a message to the msg_stream
+ by writting a message to the msg_stream.
+
+ The `classes` parameter can be either a sequence of :class:`~PyTango.api2.Device`
+ classes or a dictionary where:
+
+ * key is the tango class name
+ * value is either:
+ #. a :class:`~PyTango.api2.Device` class or
+ #. a a sequence of two elements :class:`~PyTango.DeviceClass`, :class:`~PyTango.DeviceImpl`
+
+ Example 1: registering and running a PowerSupply inheriting from :class:`~PyTango.api2.Device`::
- For example, if you want to expose a server of type "MyServer" which
- is defined by tango classes `MyServerClass` and `MyServer` then::
+ from PyTango import server_run
+ from PyTango.api2 import Device, DeviceMeta
+
+ class PowerSupply(Device):
+ __metaclass__ = DeviceMeta
+
+ server_run((PowerSupply,))
+
+ Example 2: registering and running a MyServer defined by tango classes
+ `MyServerClass` and `MyServer`::
import PyTango
+
+ class MyServer(PyTango.Device_4Impl):
+ pass
+
+ class MyServerClass(PyTango.DeviceClass):
+ pass
+
PyTango.server_run({"MyServer": (MyServerClass, MyServer)})
-
+
:param classes:
+ a sequence of :class:`~PyTango.api2.Device` classes or
a dictionary where keyword is the tango class name and value is a
- sequence of Tango Class python class, and Tango python class
- :type classes: dict
+ sequence of Tango Device Class python class, and Tango Device python class
+ :type classes: sequence or dict
:param args:
list of command line arguments [default: None, meaning use sys.argv]
@@ -1100,14 +1132,25 @@ def server_run(classes, args=None, msg_stream=sys.stderr, verbose=False):
:param msg_stream:
stream where to put messages [default: sys.stderr]
- .. versionadded:: 8.0.0"""
+ :param util:
+ PyTango Util object [default: None meaning create a Util instance]
+ :type util: :class:`~PyTango.Util`
+
+ :return: The Util singleton object
+ :rtype: :class:`~PyTango.Util`
+
+ .. versionadded:: 8.0.0
+
+ .. versionchanged:: 8.0.3
+ Added `util` keyword parameter.
+ Returns util object"""
if msg_stream is None:
import io
msg_stream = io.BytesIO()
write = msg_stream.write
try:
- return __server_run(classes, args=args)
+ return __server_run(classes, args=args, util=util)
write("Exiting:\n")
except KeyboardInterrupt:
write("Exiting: Keyboard interrupt\n")
diff --git a/src/constants.cpp b/src/constants.cpp
index 99b4524..e771477 100644
--- a/src/constants.cpp
+++ b/src/constants.cpp
@@ -201,4 +201,73 @@ void export_constants()
consts_scope.attr("TANGO_LONG64") = false;
#endif
+ consts_scope.attr("API_AttrConfig") = "API_AttrConfig";
+ consts_scope.attr("API_AttrEventProp") = "API_AttrEventProp";
+ consts_scope.attr("API_AttrIncorrectDataNumber") = "API_AttrIncorrectDataNumber";
+ consts_scope.attr("API_AttrNoAlarm") = "API_AttrNoAlarm";
+ consts_scope.attr("API_AttrNotAllowed") = "API_AttrNotAllowed";
+ consts_scope.attr("API_AttrNotFound") = "API_AttrNotFound";
+ consts_scope.attr("API_AttrNotWritable") = "API_AttrNotWritable";
+ consts_scope.attr("API_AttrOptProp") = "API_AttrOptProp";
+ consts_scope.attr("API_AttrPropValueNotSet") = "API_AttrPropValueNotSet";
+ consts_scope.attr("API_AttrValueNotSet") = "API_AttrValueNotSet";
+ consts_scope.attr("API_AttrWrongDefined") = "API_AttrWrongDefined";
+ consts_scope.attr("API_AttrWrongMemValue") = "API_AttrWrongMemValue";
+ consts_scope.attr("API_BadConfigurationProperty") = "API_BadConfigurationProperty";
+ consts_scope.attr("API_BlackBoxArgument") = "API_BlackBoxArgument";
+ consts_scope.attr("API_BlackBoxEmpty") = "API_BlackBoxEmpty";
+ consts_scope.attr("API_CannotCheckAccessControl") = "API_CannotCheckAccessControl";
+ consts_scope.attr("API_CannotOpenFile") = "API_CannotOpenFile";
+ consts_scope.attr("API_CantActivatePOAManager") = "API_CantActivatePOAManager";
+ consts_scope.attr("API_CantCreateClassPoa") = "API_CantCreateClassPoa";
+ consts_scope.attr("API_CantCreateLockingThread") = "API_CantCreateLockingThread";
+ consts_scope.attr("API_CantFindLockingThread") = "API_CantFindLockingThread";
+ consts_scope.attr("API_CantGetClientIdent") = "API_CantGetClientIdent";
+ consts_scope.attr("API_CantGetDevObjectId") = "API_CantGetDevObjectId";
+ consts_scope.attr("API_CantInstallSignal") = "API_CantInstallSignal";
+ consts_scope.attr("API_CantRetrieveClass") = "API_CantRetrieveClass";
+ consts_scope.attr("API_CantRetrieveClassList") = "API_CantRetrieveClassList";
+ consts_scope.attr("API_CantStoreDeviceClass") = "API_CantStoreDeviceClass";
+ consts_scope.attr("API_ClassNotFound") = "API_ClassNotFound";
+ consts_scope.attr("API_CmdArgumentTypeNotSupported") = "API_CmdArgumentTypeNotSupported";
+ consts_scope.attr("API_CommandNotAllowed") = "API_CommandNotAllowed";
+ consts_scope.attr("API_CommandNotFound") = "API_CommandNotFound";
+ consts_scope.attr("API_CorbaSysException") = "API_CorbaSysException";
+ consts_scope.attr("API_CorruptedDatabase") = "API_CorruptedDatabase";
+ consts_scope.attr("API_DatabaseAccess") = "API_DatabaseAccess";
+ consts_scope.attr("API_DeviceLocked") = "API_DeviceLocked";
+ consts_scope.attr("API_DeviceNotFound") = "API_DeviceNotFound";
+ consts_scope.attr("API_DeviceNotLocked") = "API_DeviceNotLocked";
+ consts_scope.attr("API_DeviceUnlockable") = "API_DeviceUnlockable";
+ consts_scope.attr("API_DeviceUnlocked") = "API_DeviceUnlocked";
+ consts_scope.attr("API_EventSupplierNotConstructed") = "API_EventSupplierNotConstructed";
+ consts_scope.attr("API_IncoherentDbData") = "API_IncoherentDbData";
+ consts_scope.attr("API_IncoherentDevData") = "API_IncoherentDevData";
+ consts_scope.attr("API_IncoherentValues") = "API_IncoherentValues";
+ consts_scope.attr("API_IncompatibleAttrDataType") = "API_IncompatibleAttrDataType";
+ consts_scope.attr("API_IncompatibleCmdArgumentType") = "API_IncompatibleCmdArgumentType";
+ consts_scope.attr("API_InitMethodNotFound") = "API_InitMethodNotFound";
+ consts_scope.attr("API_InitNotPublic") = "API_InitNotPublic";
+ consts_scope.attr("API_InitThrowsException") = "API_InitThrowsException";
+ consts_scope.attr("API_JavaRuntimeSecurityException") = "API_JavaRuntimeSecurityException";
+ consts_scope.attr("API_MemoryAllocation") = "API_MemoryAllocation";
+ consts_scope.attr("API_MethodArgument") = "API_MethodArgument";
+ consts_scope.attr("API_MethodNotFound") = "API_MethodNotFound";
+ consts_scope.attr("API_MissedEvents") = "API_MissedEvents";
+ consts_scope.attr("API_NotSupportedFeature") = "API_NotSupportedFeature";
+ consts_scope.attr("API_NtDebugWindowError") = "API_NtDebugWindowError";
+ consts_scope.attr("API_OverloadingNotSupported") = "API_OverloadingNotSupported";
+ consts_scope.attr("API_PolledDeviceNotInPoolConf") = "API_PolledDeviceNotInPoolConf";
+ consts_scope.attr("API_PolledDeviceNotInPoolMap") = "API_PolledDeviceNotInPoolMap";
+ consts_scope.attr("API_PollingThreadNotFound") = "API_PollingThreadNotFound";
+ consts_scope.attr("API_ReadOnlyMode") = "API_ReadOnlyMode";
+ consts_scope.attr("API_SignalOutOfRange") = "API_SignalOutOfRange";
+ consts_scope.attr("API_SystemCallFailed") = "API_SystemCallFailed";
+ consts_scope.attr("API_WAttrOutsideLimit") = "API_WAttrOutsideLimit";
+ consts_scope.attr("API_WizardConfError") = "API_WizardConfError";
+ consts_scope.attr("API_WrongEventData") = "API_WrongEventData";
+ consts_scope.attr("API_WrongHistoryDataBuffer") = "API_WrongHistoryDataBuffer";
+ consts_scope.attr("API_WrongLockingStatus") = "API_WrongLockingStatus";
+ consts_scope.attr("API_ZmqInitFailed") = "API_ZmqInitFailed";
+
}
diff --git a/src/server/attribute.cpp b/src/server/attribute.cpp
index 6137671..e74eb86 100644
--- a/src/server/attribute.cpp
+++ b/src/server/attribute.cpp
@@ -275,7 +275,7 @@ namespace PyAttribute
TangoSys_OMemStream o;
o << "Wrong Python type for attribute " << att.get_name()
- << "of type " << arg_type << ". Expected a sequence." << ends;
+ << " of type " << arg_type << ". Expected a sequence." << ends;
Tango::Except::throw_exception(
"PyDs_WrongPythonDataTypeForAttribute",
--
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