[pytango] 02/483: preparing for 7.2.0

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:18 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 d7764b9f27d44ac6f21b89b36804b09bd2d08da6
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Mon Feb 28 09:02:58 2011 +0000

    preparing for 7.2.0
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@15816 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 PyTango/__init__.py         |   1 +
 PyTango/api_util.py         |   5 +-
 PyTango/base_types.py       |  16 -----
 PyTango/device_attribute.py |   1 -
 PyTango/exception.py        | 109 ++++++++++++++++++++++++++++++++++
 PyTango/ipython/ipython.py  |  31 +++++++++-
 PyTango/pytango_init.py     |   2 +
 PyTango/utils.py            | 138 ++++++++++++++++++++++++++++++++++++++++++++
 doc/conf.py                 |   8 +++
 doc/exception.rst           |   9 ---
 doc/revision.rst            |  11 +++-
 doc/server/index.rst        |   8 +--
 doc/spock/highlights.rst    |   6 +-
 setup.py                    |  17 +++---
 14 files changed, 316 insertions(+), 46 deletions(-)

diff --git a/PyTango/__init__.py b/PyTango/__init__.py
index e61ac2d..e6233c5 100644
--- a/PyTango/__init__.py
+++ b/PyTango/__init__.py
@@ -67,3 +67,4 @@ from device_class import *
 from globals import *
 from utils import *
 from tango_numpy import *
+from exception import *
\ No newline at end of file
diff --git a/PyTango/api_util.py b/PyTango/api_util.py
index 463d1f3..0cce36b 100644
--- a/PyTango/api_util.py
+++ b/PyTango/api_util.py
@@ -30,10 +30,11 @@ __docformat__ = "restructuredtext"
 
 from _PyTango import ApiUtil
 
-from utils import document_method, document_static_method
+from utils import document_method, document_static_method, _get_env_var
 
 def __init_api_util():
-    pass
+    if not hasattr(ApiUtil, "get_env_var"):
+        ApiUtil.get_env_var = staticmethod(_get_env_var)
 
 def __doc_api_util():
     
diff --git a/PyTango/base_types.py b/PyTango/base_types.py
index 67aaeb8..1e276c9 100644
--- a/PyTango/base_types.py
+++ b/PyTango/base_types.py
@@ -592,22 +592,6 @@ def __doc_base_types():
         New in PyTango 7.0.0
     """ )
 
-
-    Except.__doc__ = """
-    A containner for the static methods:
-        - throw_exception
-        - re_throw_exception
-        - print_exception
-        - compare_exception"""
-
-    DevError.__doc__ = """
-    Structure describing any error resulting from a command execution,
-    or an attribute query, with following members:
-        - reason : (str)
-        - severity : (ErrSeverity) error severty (WARN, ERR, PANIC)
-        - desc : (str) error description
-        - origin : (str) Tango server method in which the error happened"""
-
     TimeVal.__doc__ = """
     Time value structure with the following members
         - tv_sec : seconds
diff --git a/PyTango/device_attribute.py b/PyTango/device_attribute.py
index f18f072..ef5cb6d 100644
--- a/PyTango/device_attribute.py
+++ b/PyTango/device_attribute.py
@@ -110,7 +110,6 @@ def __init_DeviceAttribute():
     DeviceAttribute.__init_orig = DeviceAttribute.__init__
     DeviceAttribute.__init__ = __DeviceAttribute__init
     DeviceAttribute.ExtractAs = ExtractAs
-    pass
 
 def init(doc=True):
     __init_DeviceAttribute()
diff --git a/PyTango/exception.py b/PyTango/exception.py
new file mode 100644
index 0000000..588e006
--- /dev/null
+++ b/PyTango/exception.py
@@ -0,0 +1,109 @@
+#############################################################################
+##
+## This file is part of PyTango, a python binding for Tango
+##
+## http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html
+##
+## (copyleft) CELLS / ALBA Synchrotron, Bellaterra, Spain
+##
+## This is free software; you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with this program; if not, see <http://www.gnu.org/licenses/>.
+###########################################################################
+
+"""
+"""
+
+__docformat__ = "restructuredtext"
+
+from utils import document_static_method as __document_static_method
+from _PyTango import Except, DevError
+
+
+def __doc_Except():
+    def document_static_method(method_name, desc, append=True):
+        return __document_static_method(Except, method_name, desc, append)
+    
+    Except.__doc__ = """
+    A containner for the static methods:
+        - throw_exception
+        - re_throw_exception
+        - print_exception
+        - compare_exception"""
+    
+    document_static_method("throw_exception", """
+    throw_exception(reason, desc, origin, sever=PyTango.ErrSeverity.ERR) -> None
+
+            Generate and throw a TANGO DevFailed exception.
+            The exception is created with a single :class:`~PyTango.DevError` 
+            object. A default value *PyTango.ErrSeverity.ERR* is defined for 
+            the :class:`~PyTango.DevError` severity field.
+        
+        Parameters :
+            - reason : (str) The exception :class:`~PyTango.DevError` object reason field
+            - desc   : (str) The exception :class:`~PyTango.DevError` object desc field
+            - origin : (str) The exception :class:`~PyTango.DevError` object origin field
+            - sever  : (PyTango.ErrSeverity) The exception DevError object severity field
+
+        Throws     : DevFailed
+    """ )
+
+    document_static_method("re_throw_exception", """
+    re_throw_exception(ex, reason, desc, origin, sever=PyTango.ErrSeverity.ERR) -> None
+
+            Re-throw a TANGO :class:`~PyTango.DevFailed` exception with one more error.
+            The exception is re-thrown with one more :class:`~PyTango.DevError` object.
+            A default value *PyTango.ErrSeverity.ERR* is defined for the new
+            :class:`~PyTango.DevError` severity field.
+        
+        Parameters :
+            - ex     : (PyTango.DevFailed) The :class:`~PyTango.DevFailed` exception
+            - reason : (str) The exception :class:`~PyTango.DevError` object reason field
+            - desc   : (str) The exception :class:`~PyTango.DevError` object desc field
+            - origin : (str) The exception :class:`~PyTango.DevError` object origin field
+            - sever  : (PyTango.ErrSeverity) The exception DevError object severity field
+
+        Throws     : DevFailed
+    """ )
+    
+    document_static_method("print_error_stack", """
+    print_error_stack(ex) -> None
+
+            Print all the details of a TANGO error stack.
+        
+        Parameters :
+            - ex     : (PyTango.DevErrorList) The error stack reference
+    """ )
+
+    document_static_method("print_exception", """
+    print_exception(ex) -> None
+
+            Print all the details of a TANGO exception.
+        
+        Parameters :
+            - ex     : (PyTango.DevFailed) The :class:`~PyTango.DevFailed` exception
+    """ )
+
+def __doc_DevError():
+    DevError.__doc__ = """
+    Structure describing any error resulting from a command execution,
+    or an attribute query, with following members:
+        - reason : (str)
+        - severity : (ErrSeverity) error severty (WARN, ERR, PANIC)
+        - desc : (str) error description
+        - origin : (str) Tango server method in which the error happened"""
+
+  
+def init(doc=True):
+    if doc:
+        __doc_Except()
+        __doc_DevError()
\ No newline at end of file
diff --git a/PyTango/ipython/ipython.py b/PyTango/ipython/ipython.py
index 077ca63..c302349 100644
--- a/PyTango/ipython/ipython.py
+++ b/PyTango/ipython/ipython.py
@@ -60,5 +60,34 @@ def __define_init():
         ret = ipython_00_10.init_ipython
     return ret
 
+def get_ipython_dir():
+    """Find the ipython local directory. Usually is <home>/.ipython"""
+    if hasattr(IPython.iplib, 'get_ipython_dir'):
+        # Starting from ipython 0.9 they hadded this method
+        return IPython.iplib.get_ipython_dir()
+    
+    # Try to find the profile in the current directory and then in the 
+    # default IPython dir
+    userdir = os.path.realpath(os.path.curdir)
+    home_dir = IPython.genutils.get_home_dir()
+    
+    if os.name == 'posix':
+        ipdir = '.ipython'
+    else:
+        ipdir = '_ipython'
+    ipdir = os.path.join(home_dir, ipdir)
+    ipythondir = os.path.abspath( os.environ.get('IPYTHONDIR', ipdir) )
+    return ipythondir
+
+def get_ipython_profiles():
+    """Helper functions to find ipython profiles"""
+    ret = []
+    ipydir = get_ipython_dir()
+    if os.path.isdir(ipydir):
+        for i in os.listdir(ipdir):
+            if i.startswith("ipy_profile_") and i.endswith(".py") and \
+                os.path.isfile(i):
+                ret.append(i[len("ipy_profile_"):s.rfind(".")])
+    return ret
+
 init_ipython = __define_init()
-#init_ipython(IPython.ipapi.get())
diff --git a/PyTango/pytango_init.py b/PyTango/pytango_init.py
index 7603870..c56d977 100644
--- a/PyTango/pytango_init.py
+++ b/PyTango/pytango_init.py
@@ -30,6 +30,7 @@ __docformat__ = "restructuredtext"
 
 import attribute_proxy
 import base_types
+import exception
 import callback
 import api_util
 import connection
@@ -57,6 +58,7 @@ def __init():
     global __DOC
     doc = __DOC
     base_types.init(doc=doc)
+    exception.init(doc=doc)
     callback.init(doc=doc)
     api_util.init(doc=doc)
     connection.init(doc=doc)
diff --git a/PyTango/utils.py b/PyTango/utils.py
index fb658ce..debd77a 100644
--- a/PyTango/utils.py
+++ b/PyTango/utils.py
@@ -40,6 +40,8 @@ import types
 import operator
 
 from _PyTango import StdStringVector, DbData, DbDevInfos, DbDevExportInfos, CmdArgType, AttrDataFormat
+from _PyTango import EventData, AttrConfEventData, DataReadyEventData
+from _PyTango import ApiUtil
 
 _scalar_int_types = (CmdArgType.DevShort, CmdArgType.DevUShort,
     CmdArgType.DevInt, CmdArgType.DevLong, CmdArgType.DevULong,
@@ -646,3 +648,139 @@ def _notifd2db_real_db(ior_string, host=None, out=sys.stdout):
     if num_retries == 0:
         print >>out, "Failed to export notification service event factory " \
                      "to TANGO database"
+
+
+class evt_cb(object):
+    """
+    Useful event callback for test purposes
+    
+    Usage::
+    
+        dev = PyTango.DeviceProxy(dev_name)
+        cb = PyTango.utils.evt_cb()
+        id = dev.subscribe_event("state", PyTango.EventType.CHANGE_EVENT, cb, [])
+    
+    Allowed format keys are:
+        
+        - date (event timestamp)
+        - reception_date (event reception timestamp)
+        - type (event type)
+        - dev_name (device name)
+        - name (attribute name)
+        - value (event value)
+        
+    New in PyTango 7.2.0
+    """
+
+    def __init__(self, format="{date} {dev_name} {name} {type} {value}",
+                 fd=sys.stdout, max_buf=100):
+        
+        self._msg = format
+        self._fd = fd
+        self._evts = []
+        self._max_buf = max_buf
+    
+    def push_event(self, evt):
+        try:
+            self._push_event(evt)
+        except Exception, e:
+            print >>self._fd, "Unexpected error in callback: %s" % str(e)
+    
+    def _push_event(self, evt):
+        self._append(evt)
+        d = { "date" : evt.get_date().todatetime(),
+              "reception_date" : evt.reception_date.todatetime(),
+              "type" : evt.event.upper(),
+              "dev_name" : evt.device.dev_name().upper(),
+              "name" : evt.attr_name.split("/")[-1].upper(),
+              "value" : self._get_value(evt) }
+        print >>self._fd, self._msg.format(**d)
+
+    def _append(self, evt):
+        evts = self._evts
+        if len(evts) == self._max_buf:
+            evts.pop(0)
+        evts.append(evt)
+        
+    def _get_value(self, evt):
+        if evt.err:
+            e = evt.errors[0]
+            return "[%s] %s" % (e.reason, e.desc)
+        
+        if isinstance(evt, EventData):
+            return "[%s] %s" %(evt.attr_value.quality, str(evt.attr_value.value))
+        elif isinstance(evt, AttrConfEventData):
+            cfg = evt.attr_conf
+            return "label='%s'; unit='%s'" % (cfg.label, cfg.unit)
+        elif isinstance(evt, DataReadyEventData):
+            return ""
+
+def get_home():
+    """
+    Find user's home directory if possible. Otherwise raise error.
+    
+    :return: user's home directory
+    :rtype: str
+    
+    New in PyTango 7.2.0
+    """
+    path=''
+    try:
+        path=os.path.expanduser("~")
+    except:
+        pass
+    if not os.path.isdir(path):
+        for evar in ('HOME', 'USERPROFILE', 'TMP'):
+            try:
+                path = os.environ[evar]
+                if os.path.isdir(path):
+                    break
+            except: pass
+    if path:
+        return path
+    else:
+        raise RuntimeError('please define environment variable $HOME')
+
+def _get_env_var(env_var_name):
+    """
+    Returns the value for the given environment name
+
+    Search order:
+
+        * a real environ var
+        * HOME/.tangorc
+        * /etc/tangorc
+        
+    :param env_var_name: the environment variable name
+    :type env_var_name: str
+    :return: the value for the given environment name
+    :rtype: str
+    
+    New in PyTango 7.2.0
+    """
+    
+    if env_var_name in os.environ:
+        return os.environ[env_var_name]
+    
+    fname = os.path.join(get_home(), '.tangorc')
+    if not os.path.exists(fname):
+        if os.name == 'posix':
+            fname = "/etc/tangorc"
+    if not os.path.exists(fname):
+        return None
+
+    for line in file(fname):
+        strippedline = line.split('#',1)[0].strip()
+        
+        if not strippedline:
+            #empty line
+            continue
+        
+        tup = strippedline.split('=',1)
+        if len(tup) !=2:
+            # illegal line!
+            continue
+        
+        key, val = map(str.strip, tup)
+        if key == env_var_name:
+            return val
\ No newline at end of file
diff --git a/doc/conf.py b/doc/conf.py
index 098d428..a8ea3aa 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -233,6 +233,14 @@ latex_documents = [
 # If false, no module index is generated.
 #latex_use_modindex = True
 
+# -- Options for reference to other documentation ------------------------------
+
+intersphinx_mapping = {
+    'http://docs.python.org/dev': None,
+    'http://docs.scipy.org/doc/scipy/reference' : None,
+    'http://docs.scipy.org/doc/numpy' : None,
+}
+
 def copy_spaces(origin):
     r = ''
     for x in xrange(len(origin)):
diff --git a/doc/exception.rst b/doc/exception.rst
index 817ae35..e31e74d 100644
--- a/doc/exception.rst
+++ b/doc/exception.rst
@@ -90,15 +90,6 @@ Exception API
 .. autoclass:: PyTango.Except
    :show-inheritance:
    :members:
-    
-    .. staticmethod:: print_exception(exception)
-        
-        Prints the Tango exception on the standard output
-
-        :param exception: tango exception
-        :type exception: :class:`DevFailed`
-        :rtype: None
-
 
 .. autoclass:: PyTango.DevError
    :show-inheritance:
diff --git a/doc/revision.rst b/doc/revision.rst
index 4e9c2b8..efedee1 100644
--- a/doc/revision.rst
+++ b/doc/revision.rst
@@ -51,7 +51,9 @@ History of modifications:
 +----------+----------------------------------------------------------------------------------+-----------------------------------------------------+-----------------------+
 | 06/08/10 | `8.6 <http://www.tango-controls.org/static/PyTango/v712/doc/html/index.html>`_   | Update to PyTango 7.1.2                             | T\. Coutinho          |
 +----------+----------------------------------------------------------------------------------+-----------------------------------------------------+-----------------------+
-| 05/11/10 | `8.7 <http://www.tango-controls.org/static/PyTango/v712/doc/html/index.html>`_   | Update to PyTango 7.1.3                             | T\. Coutinho          |
+| 05/11/10 | `8.7 <http://www.tango-controls.org/static/PyTango/v713/doc/html/index.html>`_   | Update to PyTango 7.1.3                             | T\. Coutinho          |
++----------+----------------------------------------------------------------------------------+-----------------------------------------------------+-----------------------+
+| ??/01/11 | `8.8 <http://www.tango-controls.org/static/PyTango/v720/doc/html/index.html>`_   | Update to PyTango 7.2.0                             | T\. Coutinho          |
 +----------+----------------------------------------------------------------------------------+-----------------------------------------------------+-----------------------+
 
 .. _version-history:
@@ -62,6 +64,13 @@ Version history
 +------------+-------------------------------------------------------------------------------------+
 | version    | Changes                                                                             |
 +============+=====================================================================================+
+| 7.2.0      | Features:                                                                           |
+|            |     - None so far                                                                   |
+|            |                                                                                     |
+|            | Bug fixes:                                                                          |
+|            |     - from sourceforge:                                                             |
+|            |         - 3124427: PyTango.WAttribute.set_max_value() changes min value             |
++------------+-------------------------------------------------------------------------------------+
 | 7.1.3      | Features:                                                                           |
 |            |     - tango logging with print statement                                            |
 |            |     - tango logging with decorators                                                 |
diff --git a/doc/server/index.rst b/doc/server/index.rst
index df1d033..e4bd210 100644
--- a/doc/server/index.rst
+++ b/doc/server/index.rst
@@ -831,8 +831,8 @@ called IRMiror and PLC::
         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
+:Line 8: The Tango class PLC is registered in the device server
+:Line 9: 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
@@ -861,8 +861,8 @@ device server than before but with one C++ Tango class called SerialLine::
         U.server_init()
         U.server_run()
 
-:Line 6: The C++ class is registered in the device server
-:Line 8 and 9: The two Python classes are registered in the device server
+:Line 9: The C++ class is registered in the device server
+:Line 10 and 11: The two Python classes are registered in the device server
 
 Server API
 ----------
diff --git a/doc/spock/highlights.rst b/doc/spock/highlights.rst
index 8ff98b7..7371d90 100644
--- a/doc/spock/highlights.rst
+++ b/doc/spock/highlights.rst
@@ -90,7 +90,7 @@ where the attribute resides is running.
     sys/tg_test/1/double_scalar        sys/tg_test/1/string_image_ro
     ...
 
-    Spock <homer:10000> [1]: short_scalar = Attribute("sys/tg_test/1/shost_scalar")
+    Spock <homer:10000> [1]: short_scalar = Attribute("sys/tg_test/1/short_scalar")
     
     Spock <homer:10000> [29]: print test.read()
     DeviceAttribute[
@@ -283,7 +283,7 @@ command.
     switchdb homer 10005
     switchdb homer
     
-    Spock <homer:10000> [2]: switchdb bart      # by default port is 10000
+    Spock <homer:10000> [2]: switchdb bart       # by default port is 10000
     
     Spock <bart:10000> [3]: switchdb lisa 10005  # you can use spaces between host and port
     
@@ -385,7 +385,7 @@ spock features will also be loaded.
 Adding spock to an existing customized profile
 ##############################################
 
-If you have been working with IPython_ before and have already have defined a
+If you have been working with IPython_ before and have already defined a
 customized personal profile, you can extend your profile with spock features 
 without breaking your existing options. The trick is to initialize spock extension
 with a parameter that tells spock to maintain the existing options (like colors,
diff --git a/setup.py b/setup.py
index 1301565..60fb334 100644
--- a/setup.py
+++ b/setup.py
@@ -25,14 +25,13 @@ import sys
 import errno
 import platform
 
-from ez_setup import use_setuptools
-use_setuptools()
+#from ez_setup import use_setuptools
+#use_setuptools()
+#from setuptools import setup
+#from setuptools import Extension, Distribution
+from distutils.core import setup, Extension
+from distutils.dist import Distribution
 
-from setuptools import setup
-from setuptools import Extension, Distribution
-
-#from distutils.core import setup, Extension
-#from distutils.dist import Distribution
 import distutils.sysconfig
 
 
@@ -270,8 +269,8 @@ _pytango = Extension(name               = '_PyTango',
                      depends            = []
                      )
 
-from setuptools import Command
-#from distutils.cmd import Command
+#from setuptools import Command
+from distutils.cmd import Command
 from distutils.command.build import build as dftbuild
 from distutils.command.build_ext import build_ext as dftbuild_ext
 from distutils.unixccompiler import UnixCCompiler

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