[pytango] 55/483: fixes #3374026

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:24 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 460b54c52dea55d092371660b067d0c2cee82768
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Mon Nov 14 10:23:53 2011 +0000

    fixes #3374026
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@18365 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 PyTango/__init__.py                            | 23 +++++-
 PyTango/attr_data.py                           |  3 +-
 PyTango/base_types.py                          | 12 +++-
 PyTango/device_class.py                        |  5 +-
 PyTango/device_data.py                         |  2 +-
 PyTango/device_proxy.py                        |  6 +-
 PyTango/exception.py                           |  3 +
 PyTango/group_element.py                       |  2 +-
 PyTango/group_reply.py                         |  2 +-
 PyTango/ipython/__init__.py                    | 74 +++++++++++++++++++-
 PyTango/ipython/ipython.py                     | 97 --------------------------
 PyTango/ipython/ipython_00_10/__init__.py      |  2 +
 PyTango/ipython/ipython_00_11/__init__.py      |  3 +
 PyTango/ipython/ipython_00_11/ipython_00_11.py | 95 +++----------------------
 PyTango/log4tango.py                           |  2 +-
 PyTango/tango_numpy.py                         |  6 +-
 PyTango/utils.py                               |  6 +-
 doc/revision.rst                               |  1 +
 18 files changed, 136 insertions(+), 208 deletions(-)

diff --git a/PyTango/__init__.py b/PyTango/__init__.py
index 1c3ee2c..b68ff8c 100644
--- a/PyTango/__init__.py
+++ b/PyTango/__init__.py
@@ -68,5 +68,24 @@ from device_class import *
 from globals import *
 from utils import *
 from tango_numpy import *
-from exception import *
-from encoded_attribute import *
\ No newline at end of file
+
+# The following lines will replace the '*' imports above in the future.
+#from attr_data import AttrData
+#from log4tango import TangoStream, LogIt, DebugIt, InfoIt, WarnIt, \
+#    ErrorIt, FatalIt
+#from device_server import ChangeEventProp, PeriodicEventProp, \
+#    ArchiveEventProp, AttributeAlarm, EventProperties, AttributeConfig, \
+#    AttributeConfig_2, AttributeConfig_3
+#from attribute_proxy import AttributeProxy
+#from group import Group
+#from pyutil import Util
+#from device_class import DeviceClass
+#from globals import get_class, get_classes, get_cpp_class, get_cpp_classes, \
+#    get_constructed_class, get_constructed_classes, class_factory, \
+#    delete_class_list, class_list, cpp_class_list, constructed_class
+#from utils import is_scalar_type, is_array_type, is_numerical_type, \
+#    is_int_type, is_float_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
+#from tango_numpy import NumpyType, numpy_type, numpy_spectrum, numpy_image
\ No newline at end of file
diff --git a/PyTango/attr_data.py b/PyTango/attr_data.py
index d483c4f..34d34f5 100644
--- a/PyTango/attr_data.py
+++ b/PyTango/attr_data.py
@@ -214,7 +214,8 @@ class AttrData(object):
                 
         att_prop = None
         if extra_info:
-            self.att_prop = self.__create_user_default_attr_prop(attr_name, extra_info)
+            att_prop = self.__create_user_default_attr_prop(attr_name, extra_info)
+        self.att_prop = att_prop
     
     def to_attr(self):
         attr = self.attr_class(*self.attr_args)
diff --git a/PyTango/base_types.py b/PyTango/base_types.py
index b68b12b..8b41a5b 100644
--- a/PyTango/base_types.py
+++ b/PyTango/base_types.py
@@ -31,7 +31,17 @@ __docformat__ = "restructuredtext"
 
 import operator
 
-from _PyTango import *
+from _PyTango import (StdStringVector, StdLongVector, StdDoubleVector, \
+    CommandInfoList, AttributeInfoList, AttributeInfoListEx, DbData, \
+    DbDevInfos, DbDevExportInfos, DbDevImportInfos, DbHistoryList, \
+    DeviceDataHistoryList, StdGroupReplyVector, \
+    StdGroupCmdReplyVector, StdGroupAttrReplyVector, \
+    ArchiveEventInfo, EventData, AttrConfEventData, AttributeAlarmInfo, \
+    AttributeDimension, AttributeEventInfo, DeviceAttributeConfig, \
+    AttributeInfo, AttributeInfoEx, ChangeEventInfo, PeriodicEventInfo, \
+    DevCommandInfo, CommandInfo, DataReadyEventData, DeviceInfo, \
+    LockerInfo, PollDevice, TimeVal)
+
 from utils import document_method
 from utils import document_enum as __document_enum
 
diff --git a/PyTango/device_class.py b/PyTango/device_class.py
index 326a801..6c39b97 100644
--- a/PyTango/device_class.py
+++ b/PyTango/device_class.py
@@ -31,13 +31,12 @@ __docformat__ = "restructuredtext"
 
 import types
 import operator
-import collections
 
 from _PyTango import Except, DevFailed
 from _PyTango import _DeviceClass, Database
-from _PyTango import CmdArgType, AttrDataFormat, AttrWriteType, DispLevel
+from _PyTango import CmdArgType, DispLevel
 from _PyTango import UserDefaultAttrProp
-from _PyTango import Attr, SpectrumAttr, ImageAttr
+
 from pyutil import Util
 
 from utils import seqStr_2_obj, obj_2_str, is_array
diff --git a/PyTango/device_data.py b/PyTango/device_data.py
index c5d99a9..4a7b608 100644
--- a/PyTango/device_data.py
+++ b/PyTango/device_data.py
@@ -26,7 +26,7 @@ This is an internal PyTango module.
 """
 
 __all__ = []
-            
+
 __docformat__ = "restructuredtext"
 
 from utils import document_method as __document_method
diff --git a/PyTango/device_proxy.py b/PyTango/device_proxy.py
index 5d9adc4..3d2ce8b 100644
--- a/PyTango/device_proxy.py
+++ b/PyTango/device_proxy.py
@@ -732,7 +732,7 @@ def __DeviceProxy__subscribe_event ( self, attr_name, event_type, cb_or_queuesiz
 
     event_id = self.__subscribe_event(attr_name, event_type, cb, filters, stateless, extract_as)
 
-    with self.__get_event_map_lock() as lock:
+    with self.__get_event_map_lock():
         se = self.__get_event_map()
         evt_data = se.get(event_id)
         if evt_data is not None:
@@ -760,7 +760,7 @@ def __DeviceProxy__unsubscribe_event(self, event_id):
 
         Throws     : EventSystemFailed
     """
-    with self.__get_event_map_lock() as lock:
+    with self.__get_event_map_lock():
         se = self.__get_event_map()
         if event_id not in se:
             raise IndexError("This device proxy does not own this subscription " + str(event_id))
@@ -768,7 +768,7 @@ def __DeviceProxy__unsubscribe_event(self, event_id):
     self.__unsubscribe_event(event_id)
 
 def __DeviceProxy__unsubscribe_event_all(self):
-    with self.__get_event_map_lock() as lock:
+    with self.__get_event_map_lock():
         se = self.__get_event_map()
         event_ids = se.keys()
         se.clear()
diff --git a/PyTango/exception.py b/PyTango/exception.py
index 22b1522..6c24be0 100644
--- a/PyTango/exception.py
+++ b/PyTango/exception.py
@@ -22,8 +22,11 @@
 ################################################################################
 
 """
+This is an internal PyTango module.
 """
 
+__all__ = []
+
 __docformat__ = "restructuredtext"
 
 from utils import document_static_method as __document_static_method
diff --git a/PyTango/group_element.py b/PyTango/group_element.py
index a5dd2fc..29ccc85 100644
--- a/PyTango/group_element.py
+++ b/PyTango/group_element.py
@@ -26,7 +26,7 @@ This is an internal PyTango module.
 """
 
 __all__ = []
-            
+
 __docformat__ = "restructuredtext"
 
 import operator
diff --git a/PyTango/group_reply.py b/PyTango/group_reply.py
index 54e804e..29a75ba 100644
--- a/PyTango/group_reply.py
+++ b/PyTango/group_reply.py
@@ -26,7 +26,7 @@ This is an internal PyTango module.
 """
 
 __all__ = []
-            
+
 __docformat__ = "restructuredtext"
 
 from utils import document_method as __document_method
diff --git a/PyTango/ipython/__init__.py b/PyTango/ipython/__init__.py
index e7ba900..9cb70e8 100644
--- a/PyTango/ipython/__init__.py
+++ b/PyTango/ipython/__init__.py
@@ -21,6 +21,74 @@
 ##
 ################################################################################
 
-from ipython import init_ipython, install
-from ipython import load_ipython_extension, unload_ipython_extension, \
-    init_ipython, load_config
+__all__ = ["init_ipython", "install", "load_ipython_extension",
+           "unload_ipython_extension", "load_config"]
+
+try:
+    import IPython
+    ipython = IPython
+except:
+    ipython = None
+
+def get_ipython_version():
+    """Returns the current IPython version"""
+    if ipython is None:return None
+    v = None
+    try:
+        try:
+            v = ipython.Release.version
+        except Exception:
+            try:
+                v = ipython.release.version
+            except Exception:
+                pass
+    except Exception:
+        pass
+    return v
+
+def get_ipython_version_list():
+    ipv_str = get_ipython_version()
+
+    if ipv_str is None:
+        ipv = [0, 0]
+    else:
+        ipv = []
+        for i in ipv_str.split(".")[:2]:
+            try:
+                i = int(i)
+            except:
+                i = 0
+            ipv.append(i)
+    return ipv
+
+def default_init_ipython(ip, store=True, pytango=True, colors=True,
+                         console=True, magic=True):
+    print "Unsupported IPython version (%s) for spock profile" \
+        % get_ipython_version()
+    print "Supported IPython versions are: 0.10"
+    print "Starting normal IPython console..."
+
+def default_install(ipydir=None, verbose=True):
+    print "Unsupported IPython version (%s) for spock profile" \
+        % get_ipython_version()
+    print "Supported IPython versions are: 0.10, 0.11 and 0.12"
+    print "Tango extension to IPyhon will NOT be installed."
+
+init_ipython = default_init_ipython
+install = default_install
+
+ipv = get_ipython_version_list()
+if ipv >= [0, 10] and ipv < [0, 11]:
+    import ipython_00_10
+    init_ipython = ipython_00_10.init_ipython
+    install = ipython_00_10.install
+    load_config = None
+    load_ipython_extension = None
+    unload_ipython_extension = None
+elif ipv >= [0, 11] and ipv <= [0, 12]:
+    import ipython_00_11
+    init_ipython = None
+    install = ipython_00_11.install
+    load_config = ipython_00_11.load_config
+    load_ipython_extension = ipython_00_11.load_ipython_extension
+    unload_ipython_extension = ipython_00_11.unload_ipython_extension
diff --git a/PyTango/ipython/ipython.py b/PyTango/ipython/ipython.py
deleted file mode 100644
index faaffba..0000000
--- a/PyTango/ipython/ipython.py
+++ /dev/null
@@ -1,97 +0,0 @@
-################################################################################
-##
-## This file is part of PyTango, a python binding for Tango
-## 
-## http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html
-##
-## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-## 
-## PyTango 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.
-## 
-## PyTango 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 PyTango.  If not, see <http://www.gnu.org/licenses/>.
-##
-################################################################################
-
-__all__ = ["init_ipython", "install", "load_ipython_extension",
-           "unload_ipython_extension", "load_config"]
-
-import os
-
-try:
-    import IPython
-    ipython = IPython
-except:
-    ipython = None
-
-def get_ipython_version():
-    """Returns the current IPython version"""
-    if ipython is None:return None
-    v = None
-    try:
-        try:
-            v = ipython.Release.version
-        except Exception:
-            try:
-                v = ipython.release.version
-            except Exception:
-                pass
-    except Exception:
-        pass
-    return v
-
-def get_ipython_version_list():
-    ipv_str = get_ipython_version()
-
-    if ipv_str is None:
-        ipv = [0, 0]
-    else:
-        ipv = []
-        for i in ipv_str.split(".")[:2]:
-            try:
-                i = int(i)
-            except:
-                i = 0
-            ipv.append(i)
-    return ipv
-
-def default_init_ipython(ip, store=True, pytango=True, colors=True,
-                         console=True, magic=True):
-    print "Unsupported IPython version (%s) for spock profile" \
-        % get_ipython_version()
-    print "Supported IPython versions are: 0.10"
-    print "Starting normal IPython console..."
-
-def default_install(ipydir=None, verbose=True):
-    print "Unsupported IPython version (%s) for spock profile" \
-        % get_ipython_version()
-    print "Supported IPython versions are: 0.10, 0.11 and 0.12"
-    print "Tango extension to IPyhon will NOT be installed."
- 
-init_ipython = default_init_ipython
-install = default_install
-
-ipv = get_ipython_version_list()
-if ipv >= [0, 10] and ipv < [0, 11]:
-    import ipython_00_10
-    init_ipython = ipython_00_10.init_ipython
-    install = ipython_00_10.install
-    load_config = None
-    load_ipython_extension = None
-    unload_ipython_extension = None
-elif ipv >= [0, 11] and ipv <= [0, 12]:
-    import ipython_00_11
-    init_ipython = None
-    install = ipython_00_11.install
-    load_config = ipython_00_11.load_config
-    load_ipython_extension = ipython_00_11.load_ipython_extension
-    unload_ipython_extension = ipython_00_11.unload_ipython_extension
-    
\ No newline at end of file
diff --git a/PyTango/ipython/ipython_00_10/__init__.py b/PyTango/ipython/ipython_00_10/__init__.py
index f3f1841..5e94cb6 100644
--- a/PyTango/ipython/ipython_00_10/__init__.py
+++ b/PyTango/ipython/ipython_00_10/__init__.py
@@ -21,5 +21,7 @@
 ##
 ################################################################################
 
+__all__ = ['init_ipython', 'install']
+
 from ipython_00_10 import init_ipython
 from ipy_install import install
\ No newline at end of file
diff --git a/PyTango/ipython/ipython_00_11/__init__.py b/PyTango/ipython/ipython_00_11/__init__.py
index 0481dde..5e43cec 100644
--- a/PyTango/ipython/ipython_00_11/__init__.py
+++ b/PyTango/ipython/ipython_00_11/__init__.py
@@ -21,6 +21,9 @@
 ##
 ################################################################################
 
+__all__ = ['load_ipython_extension', 'unload_ipython_extension', 'load_config',
+           'install']
+
 from ipython_00_11 import load_ipython_extension, unload_ipython_extension, \
     load_config
 from ipy_install import install
\ No newline at end of file
diff --git a/PyTango/ipython/ipython_00_11/ipython_00_11.py b/PyTango/ipython/ipython_00_11/ipython_00_11.py
index 2042447..285f75f 100644
--- a/PyTango/ipython/ipython_00_11/ipython_00_11.py
+++ b/PyTango/ipython/ipython_00_11/ipython_00_11.py
@@ -713,42 +713,6 @@ def __store(ip, var):
 # Initialization methods
 #-------------------------------------------------------------------------------
 
-def init_colors(ip):
-    InputColors = ColorANSI.InputTermColors
-    TermColors = ColorANSI.TermColors
-    
-    name = "Tango"
-    scheme = __build_color_scheme(ip, name)
-    for k, v in scheme.items():
-        v[0].add_scheme(v[1])
-
-    name = "PurpleTango"
-    scheme = __build_color_scheme(ip, name)
-    for k, v in scheme.items():
-        v[0].add_scheme(v[1])
-
-    name = "BlueTango"
-    scheme = __build_color_scheme(ip, name)
-    prompt = scheme["prompt"][1]
-    prompt.colors.in_prompt  = InputColors.Blue
-    prompt.colors.in_number  = InputColors.LightBlue
-    prompt.colors.in_prompt2 = InputColors.Blue
-    prompt.colors.out_prompt = TermColors.Cyan
-    prompt.colors.out_number = TermColors.LightCyan
-    for k, v in scheme.items():
-        v[0].add_scheme(v[1])
-
-    name = "GreenTango"
-    scheme = __build_color_scheme(ip, name)
-    prompt = scheme["prompt"][1]
-    prompt.colors.in_prompt  = InputColors.Green
-    prompt.colors.in_number  = InputColors.LightGreen
-    prompt.colors.in_prompt2 = InputColors.Green
-    prompt.colors.out_prompt = TermColors.Red
-    prompt.colors.out_number = TermColors.LightRed
-    for k, v in scheme.items():
-        v[0].add_scheme(v[1])
-
 def init_pytango(ip):
     """Initializes the IPython environment with PyTango elements"""
 
@@ -875,47 +839,6 @@ def init_db(ip, parameter_s=''):
     
     return db
 
-def init_store(ip):
-    # recover the environment
-    ip.magic("store -r")
-    spock_store = ip.user_ns.get(_SPOCK_STORE)
-    
-    if spock_store is None:
-        print "Initializing spock store (should only happen once)"
-        spock_store = {}
-        ip.user_ns.update( { _SPOCK_STORE : spock_store} )
-        __store(ip, _SPOCK_STORE)
-        
-def init_console(ip):
-    from IPython.utils.coloransi import TermColors
-    
-    d = { "version" : PyTango.Release.version,
-          "pyver" : __get_python_version(),
-          "ipyver" : __get_ipython_version(),
-          "pytangover" : __get_pytango_version() }
-    d.update(TermColors.__dict__)
-
-    so = Struct(
-        spock_banner="""%(Blue)shint: Try typing: mydev = Device("%(LightBlue)s<tab>%(Normal)s\n""")
-
-    so = ip.user_ns.get("spock_options", so)
-    
-    ip.colors = "Linux"
-    ip.prompt_in1 = "Spock <$DB_NAME> [\\#]: "
-    ip.prompt_out = "Result [\\#]: "
-    banner = """
-%(Purple)sSpock %(version)s%(Normal)s -- An interactive %(Purple)sTango%(Normal)s client.
-
-Running on top of Python %(pyver)s, IPython %(ipyver)s and PyTango %(pytangover)s
-
-help      -> Spock's help system.
-object?   -> Details about 'object'. ?object also works, ?? prints more.
-
-""" + so.spock_banner
-    ip.banner = banner % d
-    if hasattr(ip.banner, "format"):
-        ip.banner = ip.banner.format(**d)
-    
 def init_magic(ip):
     __expose_magic(ip, "refreshdb", magic_refreshdb)
     __expose_magic(ip, "reloaddb", magic_refreshdb)
@@ -965,15 +888,13 @@ def init_ipython(ip=None, store=True, pytango=True, colors=True, console=True,
     global _spock_init
     if _spock_init is True: return
     
-    #ip.IP._orig_complete = ip.IP.complete
-    #ip.IP.complete = complete
+    if pytango:
+        init_pytango(ip)
     
-    if colors:  init_colors(ip)
-    if store:   init_store(ip)
-    if pytango: init_pytango(ip)
     init_db(ip)
-    #if console: init_console(ip)
-    if magic:   init_magic(ip)
+
+    if magic:
+        init_magic(ip)
     
     _spock_init = True
 
@@ -995,7 +916,7 @@ def load_config(config):
     # Application
     # ------------------------------------
     app = config.Application
-    config.log_level = 30
+    app.log_level = 30
 
     # ------------------------------------
     # InteractiveShell
@@ -1024,12 +945,12 @@ def load_config(config):
     # ------------------------------------
     # IPKernelApp: options for the  Qt Console
     # ------------------------------------
-    kernel_app = config.IPKernelApp
+    #kernel_app = config.IPKernelApp
     ipython_widget = config.IPythonWidget
     ipython_widget.in_prompt  = 'Spock [<span class="in-prompt-number">%i</span>]: '
     ipython_widget.out_prompt = '  Out [<span class="out-prompt-number">%i</span>]: '
     
-    zmq_i_shell = config.ZMQInteractiveShell
+    #zmq_i_shell = config.ZMQInteractiveShell
     
     # ------------------------------------
     # TerminalInteractiveShell
diff --git a/PyTango/log4tango.py b/PyTango/log4tango.py
index f7f4102..e99e3df 100644
--- a/PyTango/log4tango.py
+++ b/PyTango/log4tango.py
@@ -40,7 +40,7 @@ Example::
 
 __all__ = [ "TangoStream", "LogIt", "DebugIt", "InfoIt", "WarnIt", 
             "ErrorIt", "FatalIt" ]
-            
+
 __docformat__ = "restructuredtext"
 
 import functools
diff --git a/PyTango/tango_numpy.py b/PyTango/tango_numpy.py
index 37868d5..bb3edaf 100644
--- a/PyTango/tango_numpy.py
+++ b/PyTango/tango_numpy.py
@@ -146,10 +146,8 @@ def _define_numpy():
                 else:
                     return numpy.ndarray(shape=(dim_y,dim_x,), dtype=np_type)
         
-        return NumpyType, NumpyType.spectrum, NumpyType.image, NumpyType.tango_to_numpy
-        numpy_spectrum = NumpyType.spectrum
-        numpy_image = NumpyType.image
-        numpy_type = NumpyType.tango_to_numpy
+        return NumpyType, NumpyType.spectrum, \
+            NumpyType.image, NumpyType.tango_to_numpy
     except Exception:
         return None, _numpy_invalid, _numpy_invalid, _numpy_invalid
 
diff --git a/PyTango/utils.py b/PyTango/utils.py
index de61c1c..fe0248b 100644
--- a/PyTango/utils.py
+++ b/PyTango/utils.py
@@ -726,7 +726,7 @@ def _notifd2db_file_db(ior_string, files, out=sys.stdout):
     print >>out, "going to export notification service event factory to " \
                  "device server property file(s) ..."
     for f in files:
-        with file(f, "w") as out_file:
+        with file(f, "w"):
             pass
     return
 
@@ -825,8 +825,8 @@ class EventCallBack(object):
         try:
             self._push_event(evt)
         except Exception, e:
-            name = evt.attr_name
-            print >>self._fd, "Unexpected error in callback for %s: %s" % (str(evt), str(e))
+            print >>self._fd, "Unexpected error in callback for %s: %s" \
+                % (str(evt), str(e))
     
     def _push_event(self, evt):
         """Internal usage only"""
diff --git a/doc/revision.rst b/doc/revision.rst
index e7facab..eb9224f 100644
--- a/doc/revision.rst
+++ b/doc/revision.rst
@@ -76,6 +76,7 @@ Version history
 |            |     - from sourceforge:                                                                                                                                                      |
 |            |         - `3305251: DS dynamic attributes discards some Attr properties <https://sourceforge.net/tracker/?func=detail&aid=3305251&group_id=57612&atid=484769>`_              |
 |            |         - `3365792: DeviceProxy.<cmd_name> could be documented <https://sourceforge.net/tracker/?func=detail&aid=3365792&group_id=57612&atid=484772>`_                       |
+|            |         - `3437654: throw python exception as tango exception <https://sourceforge.net/tracker/?func=detail&aid=3437654&group_id=57612&atid=484772>`_                        |
 |            | Bug fixes:                                                                                                                                                                   |
 |            |     - from sourceforge:                                                                                                                                                      |
 |            |         - `3372371: write attribute of DevEncoded doesn't work <https://sourceforge.net/tracker/?func=detail&aid=3372371&group_id=57612&atid=484769>`_                       |

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