def get(self, i): from taurus.core.util.log import deprecated deprecated(dep='Using ints for accessing elements of %s' % self.palette, alt='"%s"' % self[i], rel='4.0') return self[i]
def initialize(name=None, strict=True, logging=True, resources=True, remove_inputhook=True): __log.deprecated(dep='taurus.external.qt.initialize', rel='4.0.4') return getQt()
def getIcon(key): """Returns a PyQt4.QtGui.QIcon object for the given key. It supports QDir's searchPath prefixes (see :meth:`QDir.setSearchPaths`). Note that taurus.qt.qtgui.resource already sets several search paths based on .path files :param key: (str) the pixmap file name. (optionally with a prefix) :return: (PyQt4.QtGui.QIcon) a PyQt4.QtGui.QIcon for the given key""" # handle resource syntax (deprecated) if key.startswith(':'): head, tail = os.path.split(key[1:]) # logos used to be in the resource root. Now they are in 'logos' prefix = sanitizePrefix(head or 'logos') alt = 'Qt.QIcon("%s:%s")' % (prefix, tail) ret = Qt.QIcon('%s:%s' % (prefix, tail)) elif not Qt.QFile.exists(key) and Qt.QIcon.hasThemeIcon(key): alt = 'QIcon.fromTheme("%s")' % key ret = Qt.QIcon.fromTheme(key) else: alt = 'QIcon("%s")' % key ret = Qt.QIcon(key) deprecated(dep='getIcon("%s")' % key, alt=alt, rel='4.0') return ret
def getIcon(key): """Returns a PyQt4.QtGui.QIcon object for the given key. It supports QDir's searchPath prefixes (see :meth:`QDir.setSearchPaths`). Note that taurus.qt.qtgui.resource already sets several search paths based on .path files :param key: (str) the pixmap file name. (optionally with a prefix) :return: (PyQt4.QtGui.QIcon) a PyQt4.QtGui.QIcon for the given key""" # handle resource syntax (deprecated) if key.startswith(":"): head, tail = os.path.split(key[1:]) # logos used to be in the resource root. Now they are in 'logos' prefix = sanitizePrefix(head or "logos") alt = 'Qt.QIcon("%s:%s")' % (prefix, tail) ret = Qt.QIcon("%s:%s" % (prefix, tail)) elif not Qt.QFile.exists(key) and Qt.QIcon.hasThemeIcon(key): alt = 'QIcon.fromTheme("%s")' % key ret = Qt.QIcon.fromTheme(key) else: alt = 'QIcon("%s")' % key ret = Qt.QIcon(key) deprecated(dep='getIcon("%s")' % key, alt=alt, rel="4.0") return ret
def __init__(self, attr=None, pytango_dev_attr=None, config=None): # config parameter is kept for backwards compatibility only TaurusAttrValue.__init__(self) if config is not None: from taurus.core.util.log import deprecated deprecated(dep='"config" kwarg', alt='"attr"', rel='4.0') attr = config if attr is None: self._attrRef = None else: self._attrRef = weakref.proxy(attr) self.config = self._attrRef # bck-compat self._pytango_dev_attr = p = pytango_dev_attr if p is None: self._pytango_dev_attr = p = PyTango.DeviceAttribute() return if self._attrRef is None: return numerical = (PyTango.is_numerical_type(self._attrRef._tango_data_type, inc_array=True) or p.type == PyTango.CmdArgType.DevUChar) if p.has_failed: self.error = PyTango.DevFailed(*p.get_err_stack()) else: # spectra and images can be empty without failing if p.is_empty and self._attrRef.data_format != DataFormat._0D: dtype = FROM_TANGO_TO_NUMPY_TYPE.get( self._attrRef._tango_data_type) if self._attrRef.data_format == DataFormat._1D: shape = (0, ) elif self._attrRef.data_format == DataFormat._2D: shape = (0, 0) p.value = numpy.empty(shape, dtype=dtype) if not (numerical or self._attrRef.type == DataType.Boolean): # generate a nested empty list of given shape p.value = [] for _ in xrange(len(shape) - 1): p.value = [p.value] rvalue = p.value wvalue = p.w_value if numerical: units = self._attrRef._units if rvalue is not None: rvalue = Quantity(rvalue, units=units) if wvalue is not None: wvalue = Quantity(wvalue, units=units) elif isinstance(rvalue, PyTango._PyTango.DevState): rvalue = DevState[str(rvalue)] self.rvalue = rvalue self.wvalue = wvalue self.time = p.time # TODO: decode this into a TaurusTimeVal self.quality = quality_from_tango(p.quality)
def getPixmap(key, size=None): # handle resource syntax (deprecated) if key.startswith(':'): head, tail = os.path.split(key[1:]) # logos used to be in the resource root. Now they are in 'logos' prefix = sanitizePrefix(head or 'logos') alt = 'getCachedPixmap("%s:%s [, size]")' % (prefix, tail) ret = getCachedPixmap('%s:%s' % (prefix, tail), size) deprecated(dep='getPixmap("%s" [, size])' % key, alt=alt, rel='4.0') return ret
def getPixmap(key, size=None): # handle resource syntax (deprecated) if key.startswith(":"): head, tail = os.path.split(key[1:]) # logos used to be in the resource root. Now they are in 'logos' prefix = sanitizePrefix(head or "logos") alt = 'getCachedPixmap("%s:%s [, size]")' % (prefix, tail) ret = getCachedPixmap("%s:%s" % (prefix, tail), size) deprecated(dep='getPixmap("%s" [, size])' % key, alt=alt, rel="4.0") return ret
def __getattr__(self, name): try: ret = getattr(self._attrRef, name) except AttributeError: raise AttributeError('%s has no attribute %s' % (self.__class__.__name__, name)) # return the attr but only after warning from taurus.core.util.log import deprecated deprecated(dep='EvaluationAttrValue.%s' % name, alt='EvaluationAttribute.%s' % name, rel='4.0') return ret
def getQt(name=None, strict=True): __log.deprecated(dep='taurus.external.qt.getQt', rel='4.0.4') if PYQT5: import PyQt5 as _qt elif PYQT4: import PyQt4 as _qt elif PYSIDE: import PySide as _qt else: raise ImportError("No suitable Qt found") return _qt
def __init__(self, attr=None, config=None): # config parameter is kept for backwards compatibility only TaurusAttrValue.__init__(self) if config is not None: from taurus.core.util.log import deprecated deprecated(dep='"config" kwarg', alt='"attr"', rel='4.0') attr = config if attr is None: self._attrRef = None else: self._attrRef = weakref.proxy(attr) self.config = self._attrRef
def __getattr__(self, name): try: ret = getattr(self._attrRef, name) except AttributeError: try: ret = getattr(self._pytango_dev_attr, name) except AttributeError: raise AttributeError("%s has no attribute %s" % (self.__class__.__name__, name)) # return the attr but only after warning from taurus.core.util.log import deprecated deprecated(dep="TangoAttrValue.%s" % name, alt="TangoAttribute.%s" % name, rel="4.0") return ret
def __getattr__(self, name): # Do not try to delegate special methods if name.startswith('__') and name.endswith('__'): raise AttributeError("'%s' object has no attribute %s" % (self.__class__.__name__, name)) try: ret = getattr(self._attrRef, name) except AttributeError: raise AttributeError('%s has no attribute %s' % (self.__class__.__name__, name)) # return the attr but only after warning from taurus.core.util.log import deprecated deprecated(dep='EvaluationAttrValue.%s' % name, alt='EvaluationAttribute.%s' % name, rel='4.0') return ret
def test_deprecations(caplog): """Test the check_taurus_deprecations context manager""" with check_taurus_deprecations(caplog, expected=1): deprecated(dep="foo", alt="bar") with check_taurus_deprecations(caplog): pass with check_taurus_deprecations(caplog, expected=0): pass with pytest.raises(AssertionError): with check_taurus_deprecations(caplog, expected=1): pass with pytest.raises(AssertionError): with check_taurus_deprecations(caplog, expected=0): deprecated(dep="foo", alt="bar") with pytest.raises(AssertionError): with check_taurus_deprecations(caplog, expected=10): deprecated(dep="foo", alt="bar")
## 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. ## ## Taurus 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 Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################## """This module exposes the QtUiTools module (deprecated in taurus). It only makes sense when using PySide(2) (which were not supported before taurus 4.5) """ from . import PYSIDE, PYSIDE2, API_NAME from taurus.core.util import log as __log __log.deprecated(dep="taurus.external.qt.QtUiTools", rel="4.5", alt='PySide(2).QtUiTools or PyQt(4,5).loadUi') if PYSIDE2: from PySide2.QtUiTools import * elif PYSIDE: from PySide.QtUiTools import * else: raise ImportError('QtUiTools not supported for {}'.format(API_NAME))
# 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. ## # Taurus 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 Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################# """DEPRECATED since 4.0,4. Use `silx.gui.console`""" __docformat__ = 'restructuredtext' from taurus.core.util.log import deprecated deprecated(dep='TaurusConsole', alt='silx.gui.console.IPythonWidget', rel='4.0.4') try: from silx.gui.console import IPythonWidget as TaurusConsole except Exception, e: from taurus.qt.qtgui.display import TaurusFallBackWidget class TaurusConsole(TaurusFallBackWidget): pass
## ## This file is part of Taurus ## ## http://taurus-scada.org ## ## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain ## ## Taurus 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. ## ## Taurus 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 Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################## from taurus.core.util import log as __log __log.deprecated(dep='taurus.external.enum', rel='4.3.2', alt='enum (enum34 module)') from enum import * # enum is provided by the enum34 package for python2.7
## ## Taurus 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 Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################## from __future__ import absolute_import from taurus.core.util.log import deprecated deprecated(dep='taurus.external.ordereddict', rel='4.0', alt='ordereddict') try: # ordereddict from python 2.7 or from ordereddict installed package? from ordereddict import * except ImportError: # ordereddict from local import import os import sys import warnings warnings.warn("ordereddict not available. Using local ordereddict", ImportWarning) sys.path.append(os.path.dirname(__file__)) from ordereddict import * del warnings del sys
def requires(origin=None, exc_class=ImportError, **kwargs): __log.deprecated(dep='taurus.external.qt.requires', rel='4.0.4') return True
taurus.qt.qtgui.tpg. Note that if you really want to continue using the old Qwt5-based widgets and avoid deprecation warnings, you can import the old API from taurus.qt.qtgui.qwt5 Note that `PyQwt5 module <http://pyqwt.sourceforge.net/>`_ only works with Python2 and PyQt4 and is no longer supported, so taurus is moving to other modules for plotting (pyqtgraph, silx, ...) """ from __future__ import absolute_import from taurus.core.util import log as __log __log.deprecated(dep='taurus.qt.qtgui.plot', rel='4.5', alt='taurus.qt.qtgui.tpg or taurus.qt.qtgui.qwt5') try: from taurus.qt.qtgui.qwt5 import * except: try: from taurus.qt.qtgui.tpg import TaurusPlot, TaurusTrend __log.info( 'plot: Using taurus.qt.qtgui.tpg to provide a minimal API ' + 'to facilitate the transition') except: __log.info('plot: Cannot import taurus.qt.qtgui.tpg to provide a ' + 'minimal API for transition')
w = GUI() w.show() sys.exit(app.exec_()) """ __all__ = [ "get_taurus_parser", "init_taurus_args", "parse_taurus_args", "split_taurus_args" ] __docformat__ = "restructuredtext" from taurus.core.util import log as __log __log.deprecated(dep='taurus.core.util.argparse', rel='4.5.4', alt='argparse or (better) click') def get_taurus_parser(parser=None): """ Returns a :class:`optparse.OptionParser` initialized with a :class:`optparse.OptionGroup` containning some taurus options. If a parser is given as parameter then it uses this parser instead of creating a new one. :param parser: an option parser or None (default) to create a new parser :type parser: :class:`optparse.OptionParser` :return: an option parser or the given parser if it is not None :rtype: :class:`optparse.OptionParser`""" import optparse if parser is None:
logging=True, resources=True, remove_inputhook=True): __log.deprecated(dep='taurus.external.qt.initialize', rel='4.0.4') return getQt() def requires(origin=None, exc_class=ImportError, **kwargs): __log.deprecated(dep='taurus.external.qt.requires', rel='4.0.4') return True # Handle rename of DEFAULT_QT_AUTO_API --> DEFAULT_QT_API if hasattr(__config, 'DEFAULT_QT_AUTO_API'): __log.deprecated(dep='DEFAULT_QT_AUTO_API', alt='DEFAULT_QT_API', rel='4.0.4') if not hasattr(__config, 'DEFAULT_QT_API'): __config.DEFAULT_QT_API = __config.DEFAULT_QT_AUTO_API # -------------------------------------------------------------------------- #: Qt API environment variable name QT_API = 'QT_API' #: names of the expected PyQt5 api PYQT5_API = ['pyqt5'] #: names of the expected PyQt4 api PYQT4_API = [ 'pyqt', # name used in IPython.qt 'pyqt4' # pyqode.qt original name ]
# -*- coding: utf-8 -*- ############################################################################## ## ## This file is part of Taurus ## ## http://taurus-scada.org ## ## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain ## ## Taurus 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. ## ## Taurus 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 Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################## from taurus.core.util import log as __log __log.deprecated(dep='taurus.external.argparse', rel='4.3.2', alt='argparse') from argparse import *
## # You should have received a copy of the GNU Lesser General Public License # along with Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################# """[DEPRECATED] Rope patch for better performance. Based on spyder.rope_patch""" __all__ = ["apply"] __docformat__ = 'restructuredtext' from taurus.core.util.log import deprecated deprecated(dep='taurusropepatch module', rel='4.0.1') def apply(): """Monkey patching rope for better performances""" import rope if rope.VERSION not in ('0.9.3', '0.9.2'): raise ImportError, "rope %s can't be patched" % rope.VERSION # Patching pycore.PyCore, so that forced builtin modules (i.e. modules # that were declared as 'extension_modules' in rope preferences) # will be indeed recognized as builtins by rope, as expected from rope.base import pycore class PatchedPyCore(pycore.PyCore):
## # You should have received a copy of the GNU Lesser General Public License # along with Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################# """[DEPRECATED] Rope patch for better performance. Based on spyder.rope_patch""" __all__ = ["apply"] __docformat__ = 'restructuredtext' from taurus.core.util.log import deprecated deprecated(dep='taurusropepatch module', rel='4.0.1') def apply(): """Monkey patching rope for better performances""" import rope if rope.VERSION not in ('0.9.3', '0.9.2'): raise ImportError("rope %s can't be patched" % rope.VERSION) # Patching pycore.PyCore, so that forced builtin modules (i.e. modules # that were declared as 'extension_modules' in rope preferences) # will be indeed recognized as builtins by rope, as expected from rope.base import pycore class PatchedPyCore(pycore.PyCore):
## ## Taurus 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. ## ## Taurus 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 Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################## from __future__ import absolute_import from sys import version_info as __vi from taurus.core.util import log as __log __log.deprecated(dep='taurus.external.unittest', rel='4.3.2', alt='unittest') if __vi[:2] < (2, 7): try: from unittest2 import * except ImportError: raise ImportError("With python <= 2.6 taurus requires unittest2 " "which is not available") else: from unittest import *
def getQtName(name=None, strict=True): __log.deprecated(dep='taurus.external.qt.getQtName', alt='taurus.external.qt.API_NAME', rel='4.0.4') return API_NAME
def __init__(self, attr=None, pytango_dev_attr=None, config=None): # config parameter is kept for backwards compatibility only TaurusAttrValue.__init__(self) if config is not None: from taurus.core.util.log import deprecated deprecated(dep='"config" kwarg', alt='"attr"', rel="4.0") attr = config if attr is None: self._attrRef = None else: self._attrRef = weakref.proxy(attr) self.config = self._attrRef # bck-compat self._pytango_dev_attr = p = pytango_dev_attr if p is None: self._pytango_dev_attr = p = PyTango.DeviceAttribute() return if self._attrRef is None: return numerical = PyTango.is_numerical_type(self._attrRef._tango_data_type, inc_array=True) if p.has_failed: self.error = PyTango.DevFailed(*p.get_err_stack()) else: if p.is_empty: # spectra and images can be empty without failing dtype = FROM_TANGO_TO_NUMPY_TYPE.get(self._attrRef._tango_data_type) if self._attrRef.data_format == DataFormat._1D: shape = (0,) elif self._attrRef.data_format == DataFormat._2D: shape = (0, 0) p.value = numpy.empty(shape, dtype=dtype) if not (numerical or self._attrRef.type == DataType.Boolean): # generate a nested empty list of given shape p.value = [] for _ in xrange(len(shape) - 1): p.value = [p.value] rvalue = p.value wvalue = p.w_value if numerical: units = self._attrRef._units if rvalue is not None: rvalue = Quantity(rvalue, units=units) if wvalue is not None: wvalue = Quantity(wvalue, units=units) elif isinstance(rvalue, PyTango._PyTango.DevState): rvalue = DevState[str(rvalue)] elif p.type == PyTango.CmdArgType.DevUChar: if self._attrRef.data_format == DataFormat._0D: rvalue = chr(rvalue) wvalue = chr(wvalue) else: rvalue = rvalue.view("S1") wvalue = wvalue.view("S1") self.rvalue = rvalue self.wvalue = wvalue self.time = p.time # TODO: decode this into a TaurusTimeVal self.quality = quality_from_tango(p.quality)
def __init__(self, attrName): Qt.QObject.__init__(self) from taurus.core.util.log import deprecated deprecated(dep="DoorAttrListener", rel="2.5.1") self.attrName = attrName self.attrObj = None
def getQt(name=None, strict=True): __log.deprecated(dep='taurus.external.qt.getQt', rel='4.0.4') from importlib import import_module return import_module(API_NAME)
## Taurus 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 Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################## from __future__ import absolute_import from taurus.core.util.log import deprecated deprecated(dep='taurus.external.ordereddict', rel='4.0', alt='ordereddict') try: # ordereddict from python 2.7 or from ordereddict installed package? from ordereddict import * except ImportError: # ordereddict from local import import os import sys import warnings warnings.warn("ordereddict not available. Using local ordereddict", ImportWarning) sys.path.append(os.path.dirname(__file__)) from ordereddict import * del warnings
############################################################################## ## ## This file is part of Taurus ## ## http://taurus-scada.org ## ## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain ## ## Taurus 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. ## ## Taurus 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 Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################## from taurus.core.util import log as __log __log.deprecated(dep='taurus.external.ordereddict', rel='4.0.3', alt='collections.OrderedDict') from collections import OrderedDict
## This file is part of Taurus ## ## http://taurus-scada.org ## ## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain ## ## Taurus 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. ## ## Taurus 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 Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################## from taurus.core.util import log as __log __log.deprecated( dep='taurus.external.pint', rel='4.3.2', alt='pint (for the module) or taurus.core.units (for UR and Q_)') from pint import * from taurus.core.units import UR, Q_