[pytango] 384/483: Upgrade documentation

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:15:03 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 58757af1ca0e97febf4586f9408480dcb459dd5b
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Wed May 14 15:48:00 2014 +0000

    Upgrade documentation
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@25598 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 doc/_templates/index.html  |   2 +
 doc/_templates/layout.html |   2 +
 doc/howto.rst              |  93 ++++++++++--
 doc/server_api/device.rst  |   4 +-
 doc/server_api/index.rst   |  53 -------
 doc/server_api/server.rst  | 206 ++++++++++++++++++++++++---
 src/boost/python/server.py | 348 +++++++++++++--------------------------------
 7 files changed, 370 insertions(+), 338 deletions(-)

diff --git a/doc/_templates/index.html b/doc/_templates/index.html
index 92a970d..12281d3 100644
--- a/doc/_templates/index.html
+++ b/doc/_templates/index.html
@@ -272,6 +272,8 @@
      
     <a href="http://www.tango-controls.org/static/PyTango/latest/doc/html">Latest stable</a>
      
+    <a href="http://www.tango-controls.org/static/PyTango/v811/doc/html">8.1.1</a>
+     
     <a href="http://www.tango-controls.org/static/PyTango/v803/doc/html">8.0.3</a>
      
     <a href="http://www.tango-controls.org/static/PyTango/v723/doc/html">7.2.3</a>
diff --git a/doc/_templates/layout.html b/doc/_templates/layout.html
index 0e1e248..dece097 100644
--- a/doc/_templates/layout.html
+++ b/doc/_templates/layout.html
@@ -7,5 +7,7 @@
     <li><a href="{{ pathto('index') }}">home</a>| </li>
     <li><a href="{{ pathto('start') }}">getting started</a>| </li>
     <li><a href="{{ pathto('quicktour') }}">quick tour</a>| </li>
+    <li><a href="{{ pathto('howto') }}">how to</a>| </li>
+    <li><a href="{{ pathto('faq') }}">FAQ</a>| </li>
     <li><a href="{{ pathto('contents') }}">documentation </a> »</li>
 {% endblock %}
diff --git a/doc/howto.rst b/doc/howto.rst
index ef511a3..9bb87c6 100644
--- a/doc/howto.rst
+++ b/doc/howto.rst
@@ -3,6 +3,8 @@
 .. highlight:: python
    :linenothreshold: 3
 
+.. _pytango-howto:
+
 ======
 How to
 ======
@@ -10,8 +12,16 @@ How to
 Check the default TANGO host
 ----------------------------
 
-.. todo::
-   write this how to
+The default TANGO host can be defined using the environment variable 
+:envvar:`TANGO_HOST` or in a `tangorc` file.
+(see `Tango environment variables <http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/node11.html#SECTION0011123000000000000000>`_
+for complete information)
+To check what is the current value that TANGO uses for the default configuration
+simple do::
+ 
+    >>> import PyTango
+    >>> PyTango.ApiUtil.get_env_var("TANGO_HOST")
+    'homer.simpson.com:10000'
 
 
 Work with Groups
@@ -29,14 +39,35 @@ Handle errors
 Check TANGO version
 -------------------
 
-.. todo:: 
-   write this how to
+There are two library versions you might be interested in checking:
+The PyTango version::
+
+    >>> import PyTango
+    >>> PyTango.__version__
+    '8.1.1'
+
+    >>> PyTango.__version_info__
+    (8, 1, 1, 'final', 0)
+
+... and the Tango C++ library version that PyTango was compiled with::
+
+    >>> import PyTango
+    >>> PyTango.constants.TgLibVers
+    '8.1.2'
+
 
 Report a bug
 ------------
 
-.. todo:: 
-   write this how to
+Bugs can be reported `TANGO Source forge tickets <https://sourceforge.net/p/tango-cs/bugs/>`_.
+
+When making a bug report don't forget to select *PyTango* in **Category**.
+
+It is also helpfull if you can put in the ticket description the PyTango information.
+It can be a dump of::
+
+   $ python -c "from PyTango.utils import info; print(info())"
+
 
 Write a server
 --------------
@@ -273,12 +304,54 @@ will output something like::
     1282221947 [-1261438096] DEBUG test/pydsexp/1 46 <- IOLong()
 
 
-Mix multiple device classes in a server
----------------------------------------
+Mix multiple device classes (Python and C++) in a server
+--------------------------------------------------------
 
-.. todo::
-   write this how to
+Within the same python interpreter, it is possible to mix several Tango classes.
+Here is an example of the main function of a device server with two Tango classes
+called IRMiror and PLC::
+
+    import PyTango
+    import sys
+
+    if __name__ == '__main__':
+        util = PyTango.Util(sys.argv)
+        util.add_class(PLCClass, PLC, 'PLC')
+        util.add_class(IRMirrorClass, IRMirror, 'IRMirror')
+        
+        U = PyTango.Util.instance()
+        U.server_init()
+        U.server_run()
+
+:Line 6: The Tango class PLC is registered in the device server
+:Line 7: The Tango class IRMirror is registered in the device server
+
+It is also possible to add C++ Tango class in a Python device server as soon as:
+    1. The Tango class is in a shared library
+    2. It exist a C function to create the Tango class
+
+For a Tango class called MyTgClass, the shared library has to be called 
+MyTgClass.so and has to be in a directory listed in the LD_LIBRARY_PATH 
+environment variable. The C function creating the Tango class has to be called 
+_create_MyTgClass_class() and has to take one parameter of type "char \*" which 
+is the Tango class name. Here is an example of the main function of the same 
+device server than before but with one C++ Tango class called SerialLine::
+
+    import PyTango
+    import sys
+    
+    if __name__ == '__main__':
+        py = PyTango.Util(sys.argv)
+        util.add_class('SerialLine', 'SerialLine', language="c++")
+        util.add_class(PLCClass, PLC, 'PLC')
+        util.add_class(IRMirrorClass, IRMirror, 'IRMirror')
+        
+        U = PyTango.Util.instance()
+        U.server_init()
+        U.server_run()
 
+:Line 6: The C++ class is registered in the device server
+:Line 7 and 8: The two Python classes are registered in the device server
 
 Create attributes dynamically
 -----------------------------
diff --git a/doc/server_api/device.rst b/doc/server_api/device.rst
index 0815b24..ce1c421 100644
--- a/doc/server_api/device.rst
+++ b/doc/server_api/device.rst
@@ -1,5 +1,5 @@
-Device classes
-==============
+Device
+======
 
 .. currentmodule:: PyTango
 
diff --git a/doc/server_api/index.rst b/doc/server_api/index.rst
index 6bd2ec5..f2a28ef 100644
--- a/doc/server_api/index.rst
+++ b/doc/server_api/index.rst
@@ -1,58 +1,5 @@
 .. currentmodule:: PyTango
 
-.. highlight:: python
-   :linenothreshold: 3
-   
-
-Mixing Tango classes (Python and C++) in a Python Tango device server
----------------------------------------------------------------------
-
-Within the same python interpreter, it is possible to mix several Tango classes. 
-Here is an example of the main function of a device server with two Tango classes
-called IRMiror and PLC::
-
-    import PyTango
-    import sys
-
-    if __name__ == '__main__':
-        util = PyTango.Util(sys.argv)
-        util.add_class(PLCClass, PLC, 'PLC')
-        util.add_class(IRMirrorClass, IRMirror, 'IRMirror')
-        
-        U = PyTango.Util.instance()
-        U.server_init()
-        U.server_run()
-
-:Line 6: The Tango class PLC is registered in the device server
-:Line 7: The Tango class IRMirror is registered in the device server
-
-It is also possible to add C++ Tango class in a Python device server as soon as:
-    1. The Tango class is in a shared library
-    2. It exist a C function to create the Tango class
-
-For a Tango class called MyTgClass, the shared library has to be called 
-MyTgClass.so and has to be in a directory listed in the LD_LIBRARY_PATH 
-environment variable. The C function creating the Tango class has to be called 
-_create_MyTgClass_class() and has to take one parameter of type "char \*" which 
-is the Tango class name. Here is an example of the main function of the same 
-device server than before but with one C++ Tango class called SerialLine::
-
-    import PyTango
-    import sys
-    
-    if __name__ == '__main__':
-        py = PyTango.Util(sys.argv)
-        util.add_class('SerialLine', 'SerialLine', language="c++")
-        util.add_class(PLCClass, PLC, 'PLC')
-        util.add_class(IRMirrorClass, IRMirror, 'IRMirror')
-        
-        U = PyTango.Util.instance()
-        U.server_init()
-        U.server_run()
-
-:Line 6: The C++ class is registered in the device server
-:Line 7 and 8: The two Python classes are registered in the device server
-
 Server API
 ----------
 
diff --git a/doc/server_api/server.rst b/doc/server_api/server.rst
index 530ec06..601af1c 100644
--- a/doc/server_api/server.rst
+++ b/doc/server_api/server.rst
@@ -3,8 +3,18 @@
 
 .. _pytango-hlapi:
 
-High Level API
-==============
+High level server API
+=====================
+
+.. hlist::
+
+   * :class:`~PyTango.server.Device`
+   * :class:`~PyTango.server.attribute`
+   * :class:`~PyTango.server.command`
+   * :class:`~PyTango.server.device_property`
+   * :class:`~PyTango.server.class_property`
+   * :func:`~PyTango.server.run`
+   * :func:`~PyTango.server.server_run`
 
 This module provides a high level device server API. It implements
 :ref:`TEP1 <pytango-TEP1>`. It exposes an easier API for developing a Tango
@@ -109,31 +119,183 @@ using the high level API. The example contains:
         class PowerSupply(Device, metaclass=DeviceMeta)
             pass
 
-API
----
-
-.. hlist::
+.. _pytango-hlapi-datatypes:
+
+.. rubric:: Data types
+
+When declaring attributes, properties or commands, one of the most important
+information is the data type. It is given by the keyword argument *dtype*.
+In order to provide a more *pythonic* interface, this argument is not restricted
+to the :obj:`~PyTango.CmdArgType` options.
+
+For example, to define a *SCALAR* :obj:`~PyTango.CmdArgType.DevLong`
+attribute you have several possibilities:
+
+#. :obj:`int`
+#. 'int'
+#. 'int32'
+#. 'integer' 
+#. :obj:`PyTango.CmdArgType.DevLong`
+#. 'DevLong' 
+#. :obj:`numpy.int32`
+
+To define a *SPECTRUM* attribute simply wrap the scalar data type in any
+python sequence:
+
+* using a *tuple*: ``(:obj:`int`,)`` or
+* using a *list*: ``[:obj:`int`]`` or
+* any other sequence type
+
+To define an *IMAGE* attribute simply wrap the scalar data type in any
+python sequence of sequences:
+
+* using a *tuple*: ``((:obj:`int`,),)`` or
+* using a *list*: ``[[:obj:`int`]]`` or
+* any other sequence type
+
+Below is the complete table of equivalences.
+
+========================================  ========================================
+dtype argument                            converts to tango type                             
+========================================  ========================================
+ ``None``                                  ``DevVoid``
+ ``'None'``                                ``DevVoid``
+ ``DevVoid``                               ``DevVoid``
+ ``'DevVoid'``                             ``DevVoid``
+
+ ``DevState``                              ``DevState``                           
+ ``'DevState'``                            ``DevState``                           
+
+ :py:obj:`bool`                            ``DevBoolean``
+ ``'bool'``                                ``DevBoolean``
+ ``'boolean'``                             ``DevBoolean``
+ ``DevBoolean``                            ``DevBoolean``
+ ``'DevBoolean'``                          ``DevBoolean``
+ :py:obj:`numpy.bool_`                     ``DevBoolean``
+
+ ``'char'``                                ``DevUChar``
+ ``'chr'``                                 ``DevUChar``
+ ``'byte'``                                ``DevUChar``
+ ``chr``                                   ``DevUChar``
+ ``DevUChar``                              ``DevUChar``
+ ``'DevUChar'``                            ``DevUChar``
+ :py:obj:`numpy.uint8`                     ``DevUChar``
+
+ ``'int16'``                               ``DevShort``
+ ``DevShort``                              ``DevShort``
+ ``'DevShort'``                            ``DevShort``
+ :py:obj:`numpy.int16`                     ``DevShort``
+
+ ``'uint16'``                              ``DevUShort``
+ ``DevUShort``                             ``DevUShort``
+ ``'DevUShort'``                           ``DevUShort``
+ :py:obj:`numpy.uint16`                    ``DevUShort``
+
+ :py:obj:`int`                             ``DevLong``
+ ``'int'``                                 ``DevLong``
+ ``'int32'``                               ``DevLong``
+ ``DevLong``                               ``DevLong``
+ ``'DevLong'``                             ``DevLong``
+ :py:obj:`numpy.int32`                     ``DevLong``
+
+ ``'uint'``                                ``DevULong``
+ ``'uint32'``                              ``DevULong``
+ ``DevULong``                              ``DevULong``
+ ``'DevULong'``                            ``DevULong``
+ :py:obj:`numpy.uint32`                    ``DevULong``
+
+ ``'int64'``                               ``DevLong64``
+ ``DevLong64``                             ``DevLong64``
+ ``'DevLong64'``                           ``DevLong64``
+ :py:obj:`numpy.int64`                     ``DevLong64``
+ 
+ ``'uint64'``                              ``DevULong64``
+ ``DevULong64``                            ``DevULong64``
+ ``'DevULong64'``                          ``DevULong64``
+ :py:obj:`numpy.uint64`                    ``DevULong64``
 
-   * :class:`~PyTango.server.Device`
-   * :class:`~PyTango.server.attribute`
-   * :class:`~PyTango.server.command`
-   * :class:`~PyTango.server.device_property`
-   * :class:`~PyTango.server.class_property`
-   * :func:`~PyTango.server.server_run`
+ ``DevInt``                                ``DevInt``                             
+ ``'DevInt'``                              ``DevInt``                             
+ 
+ ``'float32'``                             ``DevFloat``
+ ``DevFloat``                              ``DevFloat``
+ ``'DevFloat'``                            ``DevFloat``
+ :py:obj:`numpy.float32`                   ``DevFloat``
+ 
+ :py:obj:`float`                           ``DevDouble``
+ ``'double'``                              ``DevDouble``
+ ``'float'``                               ``DevDouble``
+ ``'float64'``                             ``DevDouble``
+ ``DevDouble``                             ``DevDouble``
+ ``'DevDouble'``                           ``DevDouble``
+ :py:obj:`numpy.float64`                   ``DevDouble``
+ 
+ :py:obj:`str`                             ``DevString``
+ ``'str'``                                 ``DevString``
+ ``'string'``                              ``DevString``
+ ``'text'``                                ``DevString``
+ ``DevString``                             ``DevString``
+ ``'DevString'``                           ``DevString``
+ 
+ :py:obj:`bytearray`                       ``DevEncoded``
+ ``'bytearray'``                           ``DevEncoded``
+ ``'bytes'``                               ``DevEncoded``
+ ``DevEncoded``                            ``DevEncoded``
+ ``'DevEncoded'``                          ``DevEncoded``
+
+ ``DevVarBooleanArray``                    ``DevVarBooleanArray``
+ ``'DevVarBooleanArray'``                  ``DevVarBooleanArray``
+ 
+ ``DevVarCharArray``                       ``DevVarCharArray``
+ ``'DevVarCharArray'``                     ``DevVarCharArray``
+ 
+ ``DevVarShortArray``                      ``DevVarShortArray``
+ ``'DevVarShortArray'``                    ``DevVarShortArray``
+ 
+ ``DevVarLongArray``                       ``DevVarLongArray``
+ ``'DevVarLongArray'``                     ``DevVarLongArray``
+ 
+ ``DevVarLong64Array``                     ``DevVarLong64Array``
+ ``'DevVarLong64Array'``                   ``DevVarLong64Array``
+ 
+ ``DevVarULong64Array``                    ``DevVarULong64Array``
+ ``'DevVarULong64Array'``                  ``DevVarULong64Array``
+ 
+ ``DevVarFloatArray``                      ``DevVarFloatArray``
+ ``'DevVarFloatArray'``                    ``DevVarFloatArray``
+ 
+ ``DevVarDoubleArray``                     ``DevVarDoubleArray``
+ ``'DevVarDoubleArray'``                   ``DevVarDoubleArray``
+ 
+ ``DevVarUShortArray``                     ``DevVarUShortArray``
+ ``'DevVarUShortArray'``                   ``DevVarUShortArray``
+ 
+ ``DevVarULongArray``                      ``DevVarULongArray``
+ ``'DevVarULongArray'``                    ``DevVarULongArray``
+ 
+ ``DevVarStringArray``                     ``DevVarStringArray``
+ ``'DevVarStringArray'``                   ``DevVarStringArray``
+ 
+ ``DevVarLongStringArray``                 ``DevVarLongStringArray``
+ ``'DevVarLongStringArray'``               ``DevVarLongStringArray``
+ 
+ ``DevVarDoubleStringArray``               ``DevVarDoubleStringArray``
+ ``'DevVarDoubleStringArray'``             ``DevVarDoubleStringArray``
+========================================  ========================================
 
-.. automodule:: PyTango.server
+.. autoclass:: Device
+   :show-inheritance:
+   :inherited-members:
+   :members:
 
-   .. autoclass:: Device
-      :show-inheritance:
-      :inherited-members:
-      :members:
+.. autoclass:: attribute
 
-   .. autoclass:: attribute
+.. autofunction:: command
 
-   .. autofunction:: command
+.. autoclass:: device_property
 
-   .. autoclass:: device_property
+.. autoclass:: class_property
 
-   .. autoclass:: class_property
+.. autofunction:: run
 
-   .. autofunction:: server_run
+.. autofunction:: server_run
diff --git a/src/boost/python/server.py b/src/boost/python/server.py
index 895ed2e..a3d9d7f 100644
--- a/src/boost/python/server.py
+++ b/src/boost/python/server.py
@@ -9,172 +9,7 @@
 # See LICENSE.txt for more info.
 # ------------------------------------------------------------------------------
 
-"""High Level API for writing Tango device servers.
-
-.. _pytango-hlapi-datatypes:
-
-.. rubric:: Data types
-
-When declaring attributes, properties or commands, one of the most important
-information is the data type. It is given by the keyword argument *dtype*.
-In order to provide a more *pythonic* interface, this argument is not restricted
-to the :obj:`~PyTango.CmdArgType` options.
-
-For example, to define a *SCALAR* :obj:`~PyTango.CmdArgType.DevLong`
-attribute you have several possibilities:
-
-#. :obj:`int`
-#. 'int'
-#. 'int32'
-#. 'integer' 
-#. :obj:`PyTango.CmdArgType.DevLong`
-#. 'DevLong' 
-#. :obj:`numpy.int32`
-
-To define a *SPECTRUM* attribute simply wrap the scalar data type in any
-python sequence:
-
-* using a *tuple*: ``(:obj:`int`,)`` or
-* using a *list*: ``[:obj:`int`]`` or
-* any other sequence type
-
-To define an *IMAGE* attribute simply wrap the scalar data type in any
-python sequence of sequences:
-
-* using a *tuple*: ``((:obj:`int`,),)`` or
-* using a *list*: ``[[:obj:`int`]]`` or
-* any other sequence type
-
-Below is the complete table of equivalences.
-
-========================================  ========================================
- type                                      tango type                             
-========================================  ========================================
- ``None``                                  ``DevVoid``
- ``'None'``                                ``DevVoid``
- ``DevVoid``                               ``DevVoid``
- ``'DevVoid'``                             ``DevVoid``
-
- ``DevState``                              ``DevState``                           
- ``'DevState'``                            ``DevState``                           
-
- :py:obj:`bool`                            ``DevBoolean``
- ``'bool'``                                ``DevBoolean``
- ``'boolean'``                             ``DevBoolean``
- ``DevBoolean``                            ``DevBoolean``
- ``'DevBoolean'``                          ``DevBoolean``
- :py:obj:`numpy.bool_`                     ``DevBoolean``
-
- ``'char'``                                ``DevUChar``
- ``'chr'``                                 ``DevUChar``
- ``'byte'``                                ``DevUChar``
- ``chr``                                   ``DevUChar``
- ``DevUChar``                              ``DevUChar``
- ``'DevUChar'``                            ``DevUChar``
- :py:obj:`numpy.uint8`                     ``DevUChar``
-
- ``'int16'``                               ``DevShort``
- ``DevShort``                              ``DevShort``
- ``'DevShort'``                            ``DevShort``
- :py:obj:`numpy.int16`                     ``DevShort``
-
- ``'uint16'``                              ``DevUShort``
- ``DevUShort``                             ``DevUShort``
- ``'DevUShort'``                           ``DevUShort``
- :py:obj:`numpy.uint16`                    ``DevUShort``
-
- :py:obj:`int`                             ``DevLong``
- ``'int'``                                 ``DevLong``
- ``'int32'``                               ``DevLong``
- ``DevLong``                               ``DevLong``
- ``'DevLong'``                             ``DevLong``
- :py:obj:`numpy.int32`                     ``DevLong``
-
- ``'uint'``                                ``DevULong``
- ``'uint32'``                              ``DevULong``
- ``DevULong``                              ``DevULong``
- ``'DevULong'``                            ``DevULong``
- :py:obj:`numpy.uint32`                    ``DevULong``
-
- ``'int64'``                               ``DevLong64``
- ``DevLong64``                             ``DevLong64``
- ``'DevLong64'``                           ``DevLong64``
- :py:obj:`numpy.int64`                     ``DevLong64``
- 
- ``'uint64'``                              ``DevULong64``
- ``DevULong64``                            ``DevULong64``
- ``'DevULong64'``                          ``DevULong64``
- :py:obj:`numpy.uint64`                    ``DevULong64``
-
- ``DevInt``                                ``DevInt``                             
- ``'DevInt'``                              ``DevInt``                             
- 
- ``'float32'``                             ``DevFloat``
- ``DevFloat``                              ``DevFloat``
- ``'DevFloat'``                            ``DevFloat``
- :py:obj:`numpy.float32`                   ``DevFloat``
- 
- :py:obj:`float`                           ``DevDouble``
- ``'double'``                              ``DevDouble``
- ``'float'``                               ``DevDouble``
- ``'float64'``                             ``DevDouble``
- ``DevDouble``                             ``DevDouble``
- ``'DevDouble'``                           ``DevDouble``
- :py:obj:`numpy.float64`                   ``DevDouble``
- 
- :py:obj:`str`                             ``DevString``
- ``'str'``                                 ``DevString``
- ``'string'``                              ``DevString``
- ``'text'``                                ``DevString``
- ``DevString``                             ``DevString``
- ``'DevString'``                           ``DevString``
- 
- :py:obj:`bytearray`                       ``DevEncoded``
- ``'bytearray'``                           ``DevEncoded``
- ``'bytes'``                               ``DevEncoded``
- ``DevEncoded``                            ``DevEncoded``
- ``'DevEncoded'``                          ``DevEncoded``
-
- ``DevVarBooleanArray``                    ``DevVarBooleanArray``
- ``'DevVarBooleanArray'``                  ``DevVarBooleanArray``
- 
- ``DevVarCharArray``                       ``DevVarCharArray``
- ``'DevVarCharArray'``                     ``DevVarCharArray``
- 
- ``DevVarShortArray``                      ``DevVarShortArray``
- ``'DevVarShortArray'``                    ``DevVarShortArray``
- 
- ``DevVarLongArray``                       ``DevVarLongArray``
- ``'DevVarLongArray'``                     ``DevVarLongArray``
- 
- ``DevVarLong64Array``                     ``DevVarLong64Array``
- ``'DevVarLong64Array'``                   ``DevVarLong64Array``
- 
- ``DevVarULong64Array``                    ``DevVarULong64Array``
- ``'DevVarULong64Array'``                  ``DevVarULong64Array``
- 
- ``DevVarFloatArray``                      ``DevVarFloatArray``
- ``'DevVarFloatArray'``                    ``DevVarFloatArray``
- 
- ``DevVarDoubleArray``                     ``DevVarDoubleArray``
- ``'DevVarDoubleArray'``                   ``DevVarDoubleArray``
- 
- ``DevVarUShortArray``                     ``DevVarUShortArray``
- ``'DevVarUShortArray'``                   ``DevVarUShortArray``
- 
- ``DevVarULongArray``                      ``DevVarULongArray``
- ``'DevVarULongArray'``                    ``DevVarULongArray``
- 
- ``DevVarStringArray``                     ``DevVarStringArray``
- ``'DevVarStringArray'``                   ``DevVarStringArray``
- 
- ``DevVarLongStringArray``                 ``DevVarLongStringArray``
- ``'DevVarLongStringArray'``               ``DevVarLongStringArray``
- 
- ``DevVarDoubleStringArray``               ``DevVarDoubleStringArray``
- ``'DevVarDoubleStringArray'``             ``DevVarDoubleStringArray``
-========================================  ========================================
-"""
+"""Server helper classes for writing Tango device servers."""
 
 from __future__ import with_statement
 from __future__ import print_function
@@ -595,23 +430,31 @@ def _attribute(**kwargs):
 
 def command(f=None, dtype_in=None, dformat_in=None, doc_in="",
             dtype_out=None, dformat_out=None, doc_out="",):
-    """declares a new tango command in a :class:`Device`.
+    """
+    Declares a new tango command in a :class:`Device`.
     To be used like a decorator in the methods you want to declare as tango
-    commands. For example, to declare a *ramp* command that receives a
-    `PyTango.DevDouble` parameter called *current*, do::
+    commands. The following example declares commands:
+
+        * `void TurnOn(void)`
+        * `void Ramp(DevDouble current)`
+        * `DevBool Pressurize(DevDouble pressure)`
+    
+    ::
 
         class PowerSupply(Device):
             __metaclass__ = DeviceMeta
-            
+
+            @command
+            def TurnOn(self):
+                self.info_stream("Turning on the power supply")
+    
             @command(dtype_in=float)
-            def ramp(self, current):
+            def Ramp(self, current):
                 self.info_stream("Ramping on %f..." % current)
 
-            # Another more elaborate command
-            
             @command(dtype_in=float, doc_in="the pressure to be set",
                      dtype_out=bool, doc_out="True if it worked, False otherwise")
-            def pressurize(self, pressure):
+            def Pressurize(self, pressure):
                 self.info_stream("Pressurizing to %f..." % pressure)
 
     .. note::
@@ -706,9 +549,10 @@ def __server_run(classes, args=None, msg_stream=sys.stdout, util=None,
                  event_loop=None, post_init_callback=None):
     import PyTango
     if msg_stream is None:
-        import io
-        msg_stream = io.BytesIO()
-
+        write = lambda msg: None
+    else:
+        write = msg_stream.write
+        
     if args is None:
         args = sys.argv
 
@@ -742,98 +586,100 @@ def __server_run(classes, args=None, msg_stream=sys.stdout, util=None,
         u_instance.server_set_event_loop(event_loop)
     u_instance.server_init()
     post_init_callback()
-    msg_stream.write("Ready to accept request\n")
+    write("Ready to accept request\n")
     u_instance.server_run()
     return util
 
 
-def server_run(classes, args=None, msg_stream=sys.stdout,
-               verbose=False, util=None, event_loop=None,
-               post_init_callback=None):
-    """Provides a simple way to run a tango server. It handles exceptions
-       by writting a message to the msg_stream.
-
-       The `classes` parameter can be either a sequence of :class:`~PyTango.server.Device`
-       classes or a dictionary where:
-
-       The optional `post_init_callback` can be a callable (without arguments)
-       or a tuple where the first element is the callable, the second is a list
-       of arguments(optional) and the third is a dictionary of keyword arguments
-       (also optional). Examples::
-       
-       * key is the tango class name
-       * value is either:
-           #. a :class:`~PyTango.server.Device` class or
-           #. a a sequence of two elements :class:`~PyTango.DeviceClass`, :class:`~PyTango.DeviceImpl`
+def run(classes, args=None, msg_stream=sys.stdout,
+        verbose=False, util=None, event_loop=None,
+        post_init_callback=None):
+    """
+    Provides a simple way to run a tango server. It handles exceptions
+    by writting a message to the msg_stream.
 
-       Example 1: registering and running a PowerSupply inheriting from :class:`~PyTango.server.Device`::
+    The `classes` parameter can be either a sequence of :class:`~PyTango.server.Device`
+    classes or a dictionary where:
+
+    * key is the tango class name
+    * value is either:
+        * a :class:`~PyTango.server.Device` class or
+        * a sequence of two elements :class:`~PyTango.DeviceClass` , :class:`~PyTango.DeviceImpl`
+
+    The optional `post_init_callback` can be a callable (without arguments)
+    or a tuple where the first element is the callable, the second is a list
+    of arguments(optional) and the third is a dictionary of keyword arguments
+    (also optional).
+           
+    Example 1: registering and running a PowerSupply inheriting from :class:`~PyTango.server.Device`::
        
-           from PyTango import server_run
-           from PyTango.server import Device, DeviceMeta
+        from PyTango.server import Device, DeviceMeta, run
        
-           class PowerSupply(Device):
-               __metaclass__ = DeviceMeta
+        class PowerSupply(Device):
+            __metaclass__ = DeviceMeta
                
-           server_run((PowerSupply,))
+        run((PowerSupply,))
            
-       Example 2: registering and running a MyServer defined by tango classes 
-       `MyServerClass` and `MyServer`::
+    Example 2: registering and running a MyServer defined by tango classes 
+    `MyServerClass` and `MyServer`::
        
-           import PyTango
-
-           class MyServer(PyTango.Device_4Impl):
-               pass
+        import PyTango
+        from PyTango.server import run
+    
+        class MyServer(PyTango.Device_4Impl):
+            pass
                
-           class MyServerClass(PyTango.DeviceClass):
-               pass
+        class MyServerClass(PyTango.DeviceClass):
+            pass
        
-           PyTango.server_run({"MyServer": (MyServerClass, MyServer)})
+        run({"MyServer": (MyServerClass, MyServer)})
        
-       :param classes:
-           a sequence of :class:`~PyTango.server.Device` classes or
-           a dictionary where keyword is the tango class name and value is a 
-           sequence of Tango Device Class python class, and Tango Device python class
-       :type classes: sequence or dict
+    :param classes:
+        a sequence of :class:`~PyTango.server.Device` classes or
+        a dictionary where keyword is the tango class name and value is a 
+        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]
-       :type args: list
+    :param args:
+        list of command line arguments [default: None, meaning use sys.argv]
+    :type args: list
        
-       :param msg_stream:
-           stream where to put messages [default: sys.stdout]
+    :param msg_stream:
+        stream where to put messages [default: sys.stdout]
        
-       :param util:
-           PyTango Util object [default: None meaning create a Util instance]
-       :type util: :class:`~PyTango.Util`
+    :param util:
+        PyTango Util object [default: None meaning create a Util instance]
+    :type util: :class:`~PyTango.Util`
 
-       :param event_loop: event_loop callable
-       :type event_loop: callable
+    :param event_loop: event_loop callable
+    :type event_loop: callable
        
-       :param post_init_callback: an optional callback that is executed between
-                                  the calls Util.server_init and Util.server_run
-       :type post_init_callback: callable or tuple (see description above)
+    :param post_init_callback:
+        an optional callback that is executed between the calls Util.server_init
+        and Util.server_run
+    :type post_init_callback: callable or tuple (see description above)
 
-       :return: The Util singleton object
-       :rtype: :class:`~PyTango.Util`
+    :return: The Util singleton object
+    :rtype: :class:`~PyTango.Util`
        
-       .. versionadded:: 8.0.0
+    .. versionadded:: 8.0.0
        
-       .. versionchanged:: 8.0.3
-           Added `util` keyword parameter.
-           Returns util object
+    .. versionchanged:: 8.0.3
+        Added `util` keyword parameter.
+        Returns util object
 
-       .. versionchanged:: 8.1.1
-           Changed default msg_stream from *stderr* to *stdout*
-           Added `event_loop` keyword parameter.
-           Returns util object
+    .. versionchanged:: 8.1.1
+        Changed default msg_stream from *stderr* to *stdout*
+        Added `event_loop` keyword parameter.
+        Returns util object
 
-       .. versionchanged:: 8.1.2
-           Added `post_init_callback` keyword parameter
+    .. versionchanged:: 8.1.2
+        Added `post_init_callback` keyword parameter
     """
     if msg_stream is None:
-        import io
-        msg_stream = io.BytesIO()
-    write = msg_stream.write
+        write = lambda msg : None
+    else:
+        write = msg_stream.write
     try:
         return __server_run(classes, args=args, msg_stream=msg_stream,
                             util=util, event_loop=event_loop,
@@ -850,14 +696,14 @@ def server_run(classes, args=None, msg_stream=sys.stdout,
             write(traceback.format_exc())
     write("\nExited\n")
 
-def run(classes, args=None, msg_stream=sys.stdout,
+def server_run(classes, args=None, msg_stream=sys.stdout,
         verbose=False, util=None, event_loop=None,
         post_init_callback=None):
-    """Just an alias to :func:`~PyTango.server.server_run`
     """
-    return server_run(classes, args=args, msg_stream=msg_stream,
-                      verbose=verbose, util=util, event_loop=event_loop,
-                      post_init_callback=post_init_callback)
-
-run.__doc__ += server_run.__doc__
+    Just an alias to :func:`~PyTango.server.run`.
+    Use :func:`~PyTango.server.run` instead.
+    """
+    return run(classes, args=args, msg_stream=msg_stream,
+               verbose=verbose, util=util, event_loop=event_loop,
+               post_init_callback=post_init_callback)
 

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