[pytango] 336/483: setting up setup script
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:57 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 9b4df9a767418047240f6ba5b8acee0c1d9f49e6
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date: Fri Dec 6 08:19:06 2013 +0000
setting up setup script
git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@24480 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
Makefile | 6 +-
doc/_static/ipython_motor.html | 12 +--
doc/_static/serial.png | Bin 6365 -> 6323 bytes
doc/_templates/index.html | 4 +-
doc/server/server.rst | 22 +++-
setup.py | 11 +-
src/boost/cpp/server/device_impl.h | 2 +-
.../python/ipython/ipython_10_00/ipython_10_00.py | 112 ++++++++++++++++-----
src/boost/python/ipython/resource/serial.png | Bin 6365 -> 6323 bytes
src/boost/python/server.py | 71 +++----------
10 files changed, 138 insertions(+), 102 deletions(-)
diff --git a/Makefile b/Makefile
index 9e5a7ed..34e4a43 100644
--- a/Makefile
+++ b/Makefile
@@ -126,13 +126,13 @@ INCLUDE_DIRS += -I$(ZMQ_ROOT)/include
endif
INCLUDE_DIRS += \
- -I$(SRC_DIR) \
- -I$(SRC_DIR)/server \
$(PY_INC) \
$(NUMPY_INC)
+QUOTE_INCLUDE_DIRS = -iquote $(SRC_DIR)
+
MACROS := -DNDEBUG -DPYTANGO_HAS_UNIQUE_PTR -DPYTANGO_NUMPY_VERSION=$(PYTANGO_NUMPY_VERSION)
-CFLAGS := -pthread -fno-strict-aliasing -fwrapv -Wall -fPIC $(OPTIMIZE_CC) $(MACROS) $(TANGO_CFLAGS) $(INCLUDE_DIRS)
+CFLAGS := -pthread -fno-strict-aliasing -fwrapv -Wall -fPIC $(OPTIMIZE_CC) $(MACROS) $(TANGO_CFLAGS) $(INCLUDE_DIRS) $(QUOTE_INCLUDE_DIRS)
LNFLAGS := $(LN_DIRS) $(LN_LIBS)
LIB_NAME := _PyTango.so
diff --git a/doc/_static/ipython_motor.html b/doc/_static/ipython_motor.html
index 2f502bd..5c60d85 100644
--- a/doc/_static/ipython_motor.html
+++ b/doc/_static/ipython_motor.html
@@ -8,9 +8,9 @@ p, li { white-space: pre-wrap; }
<p style="-qt-paragraph-type:empty; margin:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;">Running on top of Python 2.6.6, IPython 1.1 and PyTango 8.1.1</p>
<p style="-qt-paragraph-type:empty; margin:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
-<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">ITango [</span><span style=" font-weight:600; color:#000080;">1</span><span style=" color:#000080;">]:</span> m = Motor("sys/tg_test/motor1")</p>
+<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">ITango [</span><span style=" font-weight:600; color:#000080;">1</span><span style=" color:#000080;">]:</span> energy = Motor("energy")</p>
<p style="-qt-paragraph-type:empty; margin:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
-<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">ITango [</span><span style=" font-weight:600; color:#000080;">2</span><span style=" color:#000080;">]:</span> m</p>
+<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">ITango [</span><span style=" font-weight:600; color:#000080;">2</span><span style=" color:#000080;">]:</span> energy</p>
<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#8b0000;">Result [</span><span style=" font-weight:600; color:#8b0000;">2</span><span style=" color:#8b0000;">]:</span> </p>
<p style="-qt-paragraph-type:empty; margin:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<table border="0" style=" margin:0px;" width="100%" cellspacing="2" cellpadding="2">
@@ -20,12 +20,12 @@ p, li { white-space: pre-wrap; }
<td width="140">
<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;">Name:</p></td>
<td>
-<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">sys/tg_test/motor1</span></p></td></tr>
+<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">motor/icepapctrl/34</span></p></td></tr>
<tr>
<td>
<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;">Alias:</p></td>
<td>
-<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;">-----</p></td></tr>
+<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;">energy</p></td></tr>
<tr>
<td>
<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;">Database:</p></td>
@@ -40,7 +40,7 @@ p, li { white-space: pre-wrap; }
<td>
<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;">Server:</p></td>
<td>
-<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;">Motor/M1</p></td></tr>
+<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;">Sardana/energy</p></td></tr>
<tr>
<td>
<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;">Server host:</p></td>
@@ -50,7 +50,7 @@ p, li { white-space: pre-wrap; }
<td>
<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;">Documentation:</p></td>
<td>
-<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.sardana-controls.org"><span style=" text-decoration: underline; color:#0000ff;">http://www.sardana-controls.org</span></a></p></td></tr></table>
+<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.sardana-controls.org"><span style=" text-decoration: underline; color:#0000ff;">www.sardana-controls.org</span></a></p></td></tr></table>
<br/>
<p style="-qt-paragraph-type:empty; margin:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">ITango [</span><span style=" font-weight:600; color:#000080;">3</span><span style=" color:#000080;">]:</span> </p></body></html>
diff --git a/doc/_static/serial.png b/doc/_static/serial.png
index 789d999..a7eef8d 100644
Binary files a/doc/_static/serial.png and b/doc/_static/serial.png differ
diff --git a/doc/_templates/index.html b/doc/_templates/index.html
index 1ccc5a2..478dfae 100644
--- a/doc/_templates/index.html
+++ b/doc/_templates/index.html
@@ -19,14 +19,14 @@
<img src="_static/banner1.png" />
- <img src="_static/banner2.png" />
-
<iframe src="_static/ipython_tango.html" style="width:600px; height:411px;border: 0; "></iframe>
<iframe src="_static/ipython_db.html" style="width:600px; height:411px;border: 0; "></iframe>
<iframe src="_static/ipython_motor.html" style="width:600px; height:411px;border: 0; "></iframe>
+ <iframe src="_static/ipython_serial.html" style="width:600px; height:411px;border: 0; "></iframe>
+
<table style="width:100%;"><tr>
<td>
diff --git a/doc/server/server.rst b/doc/server/server.rst
index 2eb660b..801b18e 100644
--- a/doc/server/server.rst
+++ b/doc/server/server.rst
@@ -47,6 +47,7 @@ using the high level API. The example contains:
:linenos:
from time import time
+ from numpy.random import random_sample
from PyTango import AttrQuality, AttrWriteType, DispLevel, server_run
from PyTango.server import Device, DeviceMeta, attribute, command
@@ -84,13 +85,32 @@ using the high level API. The example contains:
def get_current(self):
return 2.3456, time(), AttrQuality.ATTR_WARNING
-
+
+ def set_current(self, current):
+ print("Current set to %f" % current)
+
+ def get_noise(self):
+ return random_sample((1024, 1024))
+
+ @command(dtype_in=float)
+ def ramp(self, value):
+ print("Ramping up...")
+
*Pretty cool, uh?*
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.server_run`
+
.. automodule:: PyTango.server
.. autoclass:: Device
diff --git a/setup.py b/setup.py
index 4e31d95..854fcb0 100644
--- a/setup.py
+++ b/setup.py
@@ -329,7 +329,7 @@ class install(dftinstall):
sub_commands.append(('install_html', has_html))
-def main():
+def setup_args():
macros = []
directories = {
@@ -515,11 +515,10 @@ def main():
ext_modules=[_pytango],
cmdclass=cmdclass)
- if py2exe:
- opts['console'] = get_script_files()
-
- dist = setup(**opts)
- return dist
+ return opts
+
+def main():
+ return setup(**setup_args())
if __name__ == "__main__":
main()
diff --git a/src/boost/cpp/server/device_impl.h b/src/boost/cpp/server/device_impl.h
index b998d80..eca1630 100644
--- a/src/boost/cpp/server/device_impl.h
+++ b/src/boost/cpp/server/device_impl.h
@@ -15,7 +15,7 @@
#include <boost/python.hpp>
#include <tango.h>
-#include <server/device_class.h>
+#include "server/device_class.h"
/**
* A wrapper around the Tango::DeviceImpl class
diff --git a/src/boost/python/ipython/ipython_10_00/ipython_10_00.py b/src/boost/python/ipython/ipython_10_00/ipython_10_00.py
index 926f119..22a5a80 100644
--- a/src/boost/python/ipython/ipython_10_00/ipython_10_00.py
+++ b/src/boost/python/ipython/ipython_10_00/ipython_10_00.py
@@ -15,10 +15,10 @@ from __future__ import print_function
__all__ = ["load_config", "load_ipython_extension", "unload_ipython_extension"]
-import sys
import os
import re
import io
+import sys
import operator
import textwrap
@@ -398,12 +398,12 @@ def mon(self, parameter_s=''):
raise UsageError("%mon -d: must provide an attribute to unmonitor")
else:
try:
- dev, sep, attr = todel.rpartition("/")
+ dev, _, attr = todel.rpartition("/")
subscriptions = __get_device_subscriptions(dev)
- id = subscriptions[attr.lower()]
+ attr_id = subscriptions[attr.lower()]
del subscriptions[attr.lower()]
d = __get_device_proxy(dev)
- d.unsubscribe_event(id)
+ d.unsubscribe_event(attr_id)
print("Stopped monitoring '%s'" % todel)
except KeyError:
raise UsageError("%%mon -d: Not monitoring '%s'" % todel)
@@ -413,22 +413,23 @@ def mon(self, parameter_s=''):
toadd = args[0]
except IndexError:
raise UsageError("%mon -a: must provide an attribute to monitor")
- dev, sep, attr = toadd.rpartition("/")
+ dev, _, attr = toadd.rpartition("/")
subscriptions = __get_device_subscriptions(dev)
- id = subscriptions.get(attr.lower())
- if id is not None:
+ attr_id = subscriptions.get(attr.lower())
+ if attr_id is not None:
raise UsageError("%%mon -a: Already monitoring '%s'" % toadd)
d = __get_device_proxy(dev)
w = __get_event_log()
model = w.model()
- id = d.subscribe_event(attr, PyTango.EventType.CHANGE_EVENT, model, [])
- subscriptions[attr.lower()] = id
+ attr_id = d.subscribe_event(attr, PyTango.EventType.CHANGE_EVENT,
+ model, [])
+ subscriptions[attr.lower()] = attr_id
print("'%s' is now being monitored. Type 'mon' to see all events" % toadd)
elif 'r' in opts:
for d, v in db._db_cache.devices.items():
d, subs = v[3], v[4]
- for id in subs.values():
- d.unsubscribe_event(id)
+ for _id in subs.values():
+ d.unsubscribe_event(_id)
v[4] = {}
elif 'i' in opts:
try:
@@ -742,7 +743,7 @@ def init_db(parameter_s=''):
r = db.command_inout("DbMySqlSelect", query)
row_nb, column_nb = r[0][-2], r[0][-1]
- results, data = r[0][:-2], r[1]
+ data = r[1]
assert row_nb == len(data) / column_nb
devices, aliases, servers, klasses = data[0::4], data[1::4], data[2::4], data[3::4]
@@ -795,7 +796,7 @@ def init_db(parameter_s=''):
r = db.command_inout("DbMySqlSelect", query)
row_nb, column_nb = r[0][-2], r[0][-1]
- results, data = r[0][:-2], r[1]
+ data = r[1]
assert row_nb == len(data) / column_nb
attributes, aliases = data[0::2], data[1::2]
@@ -879,7 +880,7 @@ def complete(text):
__DIRNAME = os.path.dirname(os.path.abspath(__file__))
__RES_DIR = os.path.join(__DIRNAME, os.path.pardir, 'resource')
-class __TangoInfo(object):
+class __TangoDeviceInfo(object):
"""Helper class for when DeviceProxy.info() is not available"""
def __init__(self, dev):
@@ -893,6 +894,69 @@ class __TangoInfo(object):
self.server_host = 'Unknown'
self.server_id = 'Unknown'
self.server_version = 1
+
+
+def __get_device_class_icon(klass="Device"):
+ icon_prop = "__icon"
+ db = __get_db()
+ try:
+ icon_filename = db.get_class_property(klass, icon_prop)[icon_prop]
+ if icon_filename:
+ icon_filename = icon_filename[0]
+ else:
+ icon_filename = klass.lower() + os.path.extsep + "png"
+ except:
+ icon_filename = klass.lower() + os.path.extsep + "png"
+
+ if os.path.isabs(icon_filename):
+ icon = icon_filename
+ else:
+ icon = os.path.join(__RES_DIR, icon_filename)
+ if not os.path.isfile(icon):
+ icon = os.path.join(__RES_DIR, "_class.png")
+ return icon
+
+
+__DEV_CLASS_HTML_TEMPLATE = """\
+<table border="0" cellpadding="2" width="100%">
+<tr><td width="140" rowspan="7" valign="middle" align="center"><img src="{icon}" height="128"/></td>
+ <td width="140">Name:</td><td><b>{name}</b></td></tr>
+<tr><td width="140">Super class:</td><td>{super_class}</td></tr>
+<tr><td width="140">Database:</td><td>{database}</td></tr>
+<tr><td width="140">Description:</td><td>{description}</td></tr>
+<tr><td width="140">Documentation:</td><td><a target="_blank" href="{doc_url}">{doc_url}</a></td></tr>
+</table>"""
+
+def __get_class_property_str(dev_class, prop_name, default=""):
+ data = __get_db().get_class_property(dev_class, prop_name)[prop_name]
+ if len(data):
+ return data[0]
+ else:
+ return default
+
+def display_deviceclass_html(dev_class):
+ """displayhook function for PyTango.DeviceProxy, rendered as HTML"""
+ fmt = dict(name=dev_class)
+ db = __get_db()
+ try:
+ fmt["database"] = db.get_db_host() + ":" + db.get_db_port()
+ except:
+ try:
+ fmt["database"] = db.get_file_name()
+ except:
+ fmt["database"] = "Unknown"
+
+ doc_url = __get_class_property_str(dev_class, "doc_url", "www.tango-controls.org")
+ try:
+ fmt["doc_url"] = doc_url[doc_url.index("http"):]
+ except ValueError:
+ fmt["doc_url"] = doc_url
+
+ fmt['icon'] = __get_device_class_icon(dev_class)
+ fmt['super_class'] = __get_class_property_str(dev_class, "InheritedFrom", "DeviceImpl")
+ fmt['description'] = __get_class_property_str(dev_class, "Description", "A Tango device class")
+ return __DEV_CLASS_HTML_TEMPLATE.format(**fmt)
+
def __get_device_icon(dev_proxy, klass="Device"):
icon_prop = "__icon"
@@ -935,7 +999,7 @@ def display_deviceproxy_html(dev_proxy):
try:
info = dev_proxy.info()
except:
- info = __TangoInfo(dev_proxy)
+ info = __TangoDeviceInfo(dev_proxy)
name = dev_proxy.dev_name()
fmt = dict(dev_class=info.dev_class, server_id=info.server_id,
server_host=info.server_host, name=name)
@@ -1153,18 +1217,12 @@ def load_config(config):
i_shell = config.InteractiveShell
i_shell.colors = 'Linux'
- if ipy_ver >= "0.12":
- # ------------------------------------
- # PromptManager (ipython >= 0.12)
- # ------------------------------------
- prompt = config.PromptManager
- prompt.in_template = 'ITango [\\#]: '
- prompt.out_template = 'Result [\\#]: '
- else:
- # (Deprecated in ipython >= 0.12 use PromptManager.in_template)
- i_shell.prompt_in1 = 'ITango [\\#]: '
- # (Deprecated in ipython >= 0.12 use PromptManager.out_template)
- i_shell.prompt_out = 'Result [\\#]: '
+ # ------------------------------------
+ # PromptManager (ipython >= 0.12)
+ # ------------------------------------
+ prompt = config.PromptManager
+ prompt.in_template = 'ITango [\\#]: '
+ prompt.out_template = 'Result [\\#]: '
# ------------------------------------
# InteractiveShellApp
diff --git a/src/boost/python/ipython/resource/serial.png b/src/boost/python/ipython/resource/serial.png
index 789d999..a7eef8d 100644
Binary files a/src/boost/python/ipython/resource/serial.png and b/src/boost/python/ipython/resource/serial.png differ
diff --git a/src/boost/python/server.py b/src/boost/python/server.py
index 3384ef3..5c9b885 100644
--- a/src/boost/python/server.py
+++ b/src/boost/python/server.py
@@ -521,7 +521,13 @@ period :obj:`str` None
archive_abs_change :obj:`str` None
archive_rel_change :obj:`str` None
archive_period :obj:`str` None
-===================== ================================ ======================================= ======================================================================================="""
+===================== ================================ ======================================= =======================================================================================
+
+.. note::
+ avoid using *dformat* parameter. If you need a SPECTRUM attribute of say,
+ boolean type, use instead ``dtype=(bool,)``.
+
+"""
def __init__(self, **kwargs):
name = kwargs.pop("name", None)
@@ -551,57 +557,6 @@ archive_period :obj:`str` None
def _attribute(**kwargs):
- """declares a new tango attribute in a :class:`Device`. To be used like
-the python native :obj:`property` function. For example, to declare a
-scalar, `PyTango.DevDouble`, read-only attribute called *voltage* in a
-*PowerSupply* :class:`Device` do::
-
- class PowerSupply(Device):
-
- voltage = attribute()
-
- def read_voltage(self):
- self.voltage = 1.0
-
-It receives multiple keyword arguments.
-
-===================== ================================ ======================================= =======================================================================================
-parameter type default value description
-===================== ================================ ======================================= =======================================================================================
-name :obj:`str` class member name alternative attribute name
-dtype :obj:`object` :obj:`~PyTango.CmdArgType.DevDouble` data type (see :ref:`Data type equivalence <pytango-hlapi-datatypes>`)
-dformat :obj:`~PyTango.AttrDataFormat` :obj:`~PyTango.AttrDataFormat.SCALAR` data format
-max_dim_x :obj:`int` 1 maximum size for x dimension (ignored for SCALAR format)
-max_dim_y :obj:`int` 0 maximum size for y dimension (ignored for SCALAR and SPECTRUM formats)
-display_level :obj:`~PyTango.DispLevel` :obj:`~PyTango.DisLevel.OPERATOR` display level
-polling_period :obj:`int` -1 polling period
-memorized :obj:`bool` False attribute should or not be memorized
-hw_memorized :obj:`bool` False write method should be called at startup when restoring memorize value (dangerous!)
-access :obj:`~PyTango.AttrWriteType` :obj:`~PyTango.AttrWriteType.READ` read only/ read write / write only access
-fget (or fread) :obj:`str` or :obj:`callable` 'read_<attr_name>' read method name or method object
-fset (or fwrite) :obj:`str` or :obj:`callable` 'write_<attr_name>' write method name or method object
-is_allowed :obj:`str` or :obj:`callable` 'is_<attr_name>_allowed' is allowed method name or method object
-label :obj:`str` '<attr_name>' attribute label
-doc (or description) :obj:`str` '' attribute description
-unit :obj:`str` '' physical units the attribute value is in
-standard_unit :obj:`str` '' physical standard unit
-display_unit :obj:`str` '' physical display unit (hint for clients)
-format :obj:`str` '6.2f' attribute representation format
-min_value :obj:`str` None minimum allowed value
-max_value :obj:`str` None maximum allowed value
-min_alarm :obj:`str` None minimum value to trigger attribute alarm
-max_alarm :obj:`str` None maximum value to trigger attribute alarm
-min_warning :obj:`str` None minimum value to trigger attribute warning
-max_warning :obj:`str` None maximum value to trigger attribute warning
-delta_val :obj:`str` None
-delta_t :obj:`str` None
-abs_change :obj:`str` None minimum value change between events that causes event filter to send the event
-rel_change :obj:`str` None minimum relative change between events that causes event filter to send the event (%)
-period :obj:`str` None
-archive_abs_change :obj:`str` None
-archive_rel_change :obj:`str` None
-archive_period :obj:`str` None
-===================== ================================ ======================================= ======================================================================================="""
if 'dtype' in kwargs:
kwargs['dtype'], kwargs['dformat'] = \
get_tango_type_format(kwargs['dtype'], kwargs.get('dformat'))
@@ -624,10 +579,14 @@ def command(f=None, dtype_in=None, dformat_in=None, doc_in="",
# 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 setPressure(self, pressure):
- self.info_stream("Setting pressure on %f..." % pressure)
-
+ dtype_out=bool, doc_out="True if it worked, False otherwise")
+ def pressurize(self, pressure):
+ self.info_stream("Pressurizing to %f..." % pressure)
+
+ .. note::
+ avoid using *dformat* parameter. If you need a SPECTRUM attribute of
+ say, boolean type, use instead ``dtype=(bool,)``.
+
:param dtype_in: a :ref:`data type <pytango-hlapi-datatypes>`
describing the type of parameter. Default is None meaning
no parameter.
--
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