From 16649fe9f6c9f14844b646c9667ecb49a59d26ea Mon Sep 17 00:00:00 2001 From: Henrik Norgren Date: Mon, 12 Jun 2023 09:56:39 +0200 Subject: [PATCH] Change version number to 3.0.0 + Rename package. --- .gitignore | 2 +- README.md | 6 +++--- docs/deprecated.rst | 16 +++++++++++++--- docs/index.rst | 20 ++++++++++---------- examples/advanced_example.py | 10 +++++----- examples/asyncio_everything.py | 22 +++++++++++----------- examples/basic_example.py | 4 ++-- examples/calibration_example.py | 10 +++++----- examples/qt_example/qt_example.py | 12 ++++++------ examples/qt_example/requirements.txt | 2 +- examples/stream_6dof_example.py | 8 ++++---- {qtm => qtm_rt}/__init__.py | 2 +- {qtm => qtm_rt}/control.py | 2 +- {qtm => qtm_rt}/data/Demo.qtm | Bin {qtm => qtm_rt}/discovery.py | 2 +- {qtm => qtm_rt}/packet.py | 2 +- {qtm => qtm_rt}/protocol.py | 10 +++++----- {qtm => qtm_rt}/qrt.py | 20 ++++++++++---------- {qtm => qtm_rt}/reboot.py | 2 +- {qtm => qtm_rt}/receiver.py | 8 ++++---- setup.py | 12 ++++++------ test/qrtconnection_test.py | 4 ++-- test/qtmprotocol_test.py | 4 ++-- 23 files changed, 95 insertions(+), 85 deletions(-) rename {qtm => qtm_rt}/__init__.py (94%) rename {qtm => qtm_rt}/control.py (94%) rename {qtm => qtm_rt}/data/Demo.qtm (100%) rename {qtm => qtm_rt}/discovery.py (98%) rename {qtm => qtm_rt}/packet.py (99%) rename {qtm => qtm_rt}/protocol.py (96%) rename {qtm => qtm_rt}/qrt.py (95%) rename {qtm => qtm_rt}/reboot.py (96%) rename {qtm => qtm_rt}/receiver.py (88%) diff --git a/.gitignore b/.gitignore index c76b7d9..efdf6ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /build /dist -/qtm.egg-info +/qtm_rt.egg-info /env /env3 /.idea diff --git a/README.md b/README.md index 63889d1..53f0b55 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ The Qualisys SDK for Python implements our RealTime(RT) protocol and works with Installation ------------ -The easiest way to install the qtm package is by using [pip]((https://pip.pypa.io/en/stable/installing/)): +The easiest way to install the qtm_rt package is by using [pip]((https://pip.pypa.io/en/stable/installing/)): ``` python -m pip install pip --upgrade # Upgrade to latest pip -python -m pip install qtm +python -m pip install qtm-rt ``` It's also possible to install from github: @@ -19,7 +19,7 @@ It's also possible to install from github: python -m pip install git+https://github.com/qualisys/qualisys_python_sdk.git ``` -Or just clone the repo and copy the qtm folder into you project folder, +Or just clone the repo and copy the qtm_rt folder into you project folder, Documentation ------------- diff --git a/docs/deprecated.rst b/docs/deprecated.rst index 4996334..b6a1d7c 100644 --- a/docs/deprecated.rst +++ b/docs/deprecated.rst @@ -1,6 +1,18 @@ .. _deprecated_version: -Upgrade information +3.0.0 +------------------- + +The package has been renamed to qtm_rt (qtm-rt on pip). Otherwise everything is identical to 2.1.2. +Older versions will remain under the qtm name to avoid breaking existing code. + +To install the old version: + +.. code-block:: console + + python -m pip install qtm==2.1.2 + +2.0.0 ------------------- The basic functionality is the same, but the package now @@ -8,8 +20,6 @@ uses `asyncio `_ instead of `t This reduces dependencies and simplifies installation but raises the required version of Python to 3.5. If you cannot use Python 3, stay on the earlier versions of this SDK. -QRest is still not implemented in 2.0. - To install the old version: .. code-block:: console diff --git a/docs/index.rst b/docs/index.rst index b110f8a..3d79e8a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,9 +1,9 @@ Welcome to Qualisys SDK for Python's documentation! =================================================== -This document describes the Qualisys SDK for Python version 2.1.2 +This document describes the Qualisys SDK for Python version 3.0.0 -**NOTE:** Version 2.0.0 introduces breaking changes. :ref:`More info...` +**NOTE:** Major versions introduces breaking changes. :ref:`More info...` .. contents:: :depth: 2 @@ -22,7 +22,7 @@ This package is a pure python package and requires at least Python 3.5.3, the ea .. code-block:: console - python -m pip install qtm + python -m pip install qtm-rt Example usage: -------------- @@ -36,40 +36,40 @@ already streaming data, either live or RT from file. QTM RT Protocol --------------- -An instance of QRTConnection is returned when qtm.connect_ successfully connects to QTM. +An instance of QRTConnection is returned when qtm_rt.connect_ successfully connects to QTM. Functions marked as coroutines need to be run in a async function and awaited, please see example above. -.. autocofunction:: qtm.connect +.. autocofunction:: qtm_rt.connect QRTConnection ~~~~~~~~~~~~~ -.. autoclass:: qtm.QRTConnection +.. autoclass:: qtm_rt.QRTConnection :members: QRTPacket ~~~~~~~~~ -.. autoclass:: qtm.QRTPacket +.. autoclass:: qtm_rt.QRTPacket :members: QRTEvent ~~~~~~~~~ -.. autoclass:: qtm.QRTEvent +.. autoclass:: qtm_rt.QRTEvent :members: :undoc-members: QRTComponentType ~~~~~~~~~~~~~~~~ -.. autoclass:: qtm.packet.QRTComponentType +.. autoclass:: qtm_rt.packet.QRTComponentType :members: :undoc-members: Exceptions ~~~~~~~~~~ -.. autoclass:: qtm.QRTCommandException +.. autoclass:: qtm_rt.QRTCommandException diff --git a/examples/advanced_example.py b/examples/advanced_example.py index d0a846d..de3304a 100644 --- a/examples/advanced_example.py +++ b/examples/advanced_example.py @@ -3,7 +3,7 @@ import asyncio import logging -import qtm +import qtm_rt LOG = logging.getLogger("example") @@ -47,18 +47,18 @@ async def shutdown(delay, connection, receiver_future, queue): async def setup(): """ main function """ - connection = await qtm.connect("127.0.0.1") + connection = await qtm_rt.connect("127.0.0.1") if connection is None: return -1 - async with qtm.TakeControl(connection, "password"): + async with qtm_rt.TakeControl(connection, "password"): state = await connection.get_state() - if state != qtm.QRTEvent.EventConnected: + if state != qtm_rt.QRTEvent.EventConnected: await connection.new() try: - await connection.await_event(qtm.QRTEvent.EventConnected, timeout=10) + await connection.await_event(qtm_rt.QRTEvent.EventConnected, timeout=10) except asyncio.TimeoutError: LOG.error("Failed to start new measurement") return -1 diff --git a/examples/asyncio_everything.py b/examples/asyncio_everything.py index b3be17f..40ea8c3 100644 --- a/examples/asyncio_everything.py +++ b/examples/asyncio_everything.py @@ -5,14 +5,14 @@ import argparse import pkg_resources -import qtm +import qtm_rt logging.basicConfig(level=logging.INFO) LOG = logging.getLogger("example") -QTM_FILE = pkg_resources.resource_filename("qtm", "data/Demo.qtm") +QTM_FILE = pkg_resources.resource_filename("qtm_rt", "data/Demo.qtm") class AsyncEnumerate: @@ -48,7 +48,7 @@ async def choose_qtm_instance(interface): """ List running QTM instances, asks for input and return chosen QTM """ instances = {} print("Available QTM instances:") - async for i, qtm_instance in AsyncEnumerate(qtm.Discover(interface), start=1): + async for i, qtm_instance in AsyncEnumerate(qtm_rt.Discover(interface), start=1): instances[i] = qtm_instance print("{} - {}".format(i, qtm_instance.info)) @@ -75,7 +75,7 @@ async def main(interface=None): while True: - connection = await qtm.connect(qtm_ip, 22223, version="1.18") + connection = await qtm_rt.connect(qtm_ip, 22223, version="1.18") if connection is None: return @@ -83,11 +83,11 @@ async def main(interface=None): await connection.get_state() await connection.byte_order() - async with qtm.TakeControl(connection, "password"): + async with qtm_rt.TakeControl(connection, "password"): result = await connection.close() if result == b"Closing connection": - await connection.await_event(qtm.QRTEvent.EventConnectionClosed) + await connection.await_event(qtm_rt.QRTEvent.EventConnectionClosed) await connection.load(QTM_FILE) @@ -103,7 +103,7 @@ async def main(interface=None): await connection.stream_frames( components=["incorrect"], on_packet=queue.put_nowait ) - except qtm.QRTCommandException as exception: + except qtm_rt.QRTCommandException as exception: LOG.info("exception %s", exception) await connection.stream_frames( @@ -122,13 +122,13 @@ async def main(interface=None): await connection.await_event() await connection.new() - await connection.await_event(qtm.QRTEvent.EventConnected) + await connection.await_event(qtm_rt.QRTEvent.EventConnected) await connection.start() - await connection.await_event(qtm.QRTEvent.EventWaitingForTrigger) + await connection.await_event(qtm_rt.QRTEvent.EventWaitingForTrigger) await connection.trig() - await connection.await_event(qtm.QRTEvent.EventCaptureStarted) + await connection.await_event(qtm_rt.QRTEvent.EventCaptureStarted) await asyncio.sleep(0.5) @@ -139,7 +139,7 @@ async def main(interface=None): await asyncio.sleep(0.5) await connection.stop() - await connection.await_event(qtm.QRTEvent.EventCaptureStopped) + await connection.await_event(qtm_rt.QRTEvent.EventCaptureStopped) await connection.save(r"measurement.qtm") diff --git a/examples/basic_example.py b/examples/basic_example.py index 0b36ca9..1b875bf 100644 --- a/examples/basic_example.py +++ b/examples/basic_example.py @@ -5,7 +5,7 @@ """ import asyncio -import qtm +import qtm_rt def on_packet(packet): @@ -19,7 +19,7 @@ def on_packet(packet): async def setup(): """ Main function """ - connection = await qtm.connect("127.0.0.1") + connection = await qtm_rt.connect("127.0.0.1") if connection is None: return diff --git a/examples/calibration_example.py b/examples/calibration_example.py index 6202a39..03ba224 100644 --- a/examples/calibration_example.py +++ b/examples/calibration_example.py @@ -2,7 +2,7 @@ import asyncio import logging -import qtm +import qtm_rt from lxml import etree LOG = logging.getLogger("example") @@ -10,18 +10,18 @@ async def setup(): """ main function """ - connection = await qtm.connect("127.0.0.1") + connection = await qtm_rt.connect("127.0.0.1") if connection is None: return -1 - async with qtm.TakeControl(connection, "password"): + async with qtm_rt.TakeControl(connection, "password"): state = await connection.get_state() - if state != qtm.QRTEvent.EventConnected: + if state != qtm_rt.QRTEvent.EventConnected: await connection.new() try: - await connection.await_event(qtm.QRTEvent.EventConnected, timeout=10) + await connection.await_event(qtm_rt.QRTEvent.EventConnected, timeout=10) except asyncio.TimeoutError: LOG.error("Failed to start new measurement") return -1 diff --git a/examples/qt_example/qt_example.py b/examples/qt_example/qt_example.py index 0e61a1e..834a6d0 100644 --- a/examples/qt_example/qt_example.py +++ b/examples/qt_example/qt_example.py @@ -17,8 +17,8 @@ from PyQt5.QtCore import pyqtSignal, QObject, pyqtProperty from PyQt5 import uic -import qtm -from qtm import QRTEvent +import qtm_rt +from qtm_rt import QRTEvent from quamash import QSelectorEventLoop main_window_class, _ = uic.loadUiType("./ui/main.ui") @@ -67,7 +67,7 @@ def discover(self): async def _discover_qtm(self, interface): try: - async for qtm_instance in qtm.Discover(interface): + async for qtm_instance in qtm_rt.Discover(interface): info = qtm_instance.info.decode("utf-8").split(",")[0] if not info in self._found_qtms: @@ -155,7 +155,7 @@ def connect_qtm(self): async def _connect_qtm(self): ip = self.qtm_combo.currentText().split(" ")[1] - self._connection = await qtm.connect( + self._connection = await qtm_rt.connect( ip, on_disconnect=self.on_disconnect, on_event=self.on_event ) @@ -193,7 +193,7 @@ def set_3d_values(self, controls, values): control.setText("{0:.3f}".format(component)) def on_packet(self, packet): - if qtm.packet.QRTComponentType.Component3d in packet.components: + if qtm_rt.packet.QRTComponentType.Component3d in packet.components: _, markers = packet.get_3d_markers() if self._trajectory_index is not None: marker = markers[self._trajectory_index] @@ -201,7 +201,7 @@ def on_packet(self, packet): [self.x_trajectory, self.y_trajectory, self.z_trajectory], marker ) - if qtm.packet.QRTComponentType.Component6d in packet.components: + if qtm_rt.packet.QRTComponentType.Component6d in packet.components: _, sixdofs = packet.get_6d() if self._sixdof_index is not None: position, _ = sixdofs[self._sixdof_index] diff --git a/examples/qt_example/requirements.txt b/examples/qt_example/requirements.txt index 7726e38..34ee4ad 100644 --- a/examples/qt_example/requirements.txt +++ b/examples/qt_example/requirements.txt @@ -1,3 +1,3 @@ -qtm +qtm_rt PyQt5==5.9 Quamash==0.6.1 \ No newline at end of file diff --git a/examples/stream_6dof_example.py b/examples/stream_6dof_example.py index b9247d4..69f0d56 100644 --- a/examples/stream_6dof_example.py +++ b/examples/stream_6dof_example.py @@ -6,9 +6,9 @@ import xml.etree.ElementTree as ET import pkg_resources -import qtm +import qtm_rt -QTM_FILE = pkg_resources.resource_filename("qtm", "data/Demo.qtm") +QTM_FILE = pkg_resources.resource_filename("qtm_rt", "data/Demo.qtm") def create_body_index(xml_string): @@ -28,7 +28,7 @@ def body_enabled_count(xml_string): async def main(): # Connect to qtm - connection = await qtm.connect("127.0.0.1") + connection = await qtm_rt.connect("127.0.0.1") # Connection failed? if connection is None: @@ -36,7 +36,7 @@ async def main(): return # Take control of qtm, context manager will automatically release control after scope end - async with qtm.TakeControl(connection, "password"): + async with qtm_rt.TakeControl(connection, "password"): realtime = False diff --git a/qtm/__init__.py b/qtm_rt/__init__.py similarity index 94% rename from qtm/__init__.py rename to qtm_rt/__init__.py index 025aeef..dfb2712 100644 --- a/qtm/__init__.py +++ b/qtm_rt/__init__.py @@ -18,7 +18,7 @@ # pylint: disable=C0330 -LOG = logging.getLogger("qtm") +LOG = logging.getLogger("qtm_rt") LOG_LEVEL = os.getenv("QTM_LOGGING", None) LEVEL = logging.DEBUG if LOG_LEVEL == "debug" else logging.INFO diff --git a/qtm/control.py b/qtm_rt/control.py similarity index 94% rename from qtm/control.py rename to qtm_rt/control.py index 625f809..55c98d9 100644 --- a/qtm/control.py +++ b/qtm_rt/control.py @@ -3,7 +3,7 @@ from .qrt import QRTConnection -LOG = logging.getLogger("qtm") +LOG = logging.getLogger("qtm_rt") class TakeControl: diff --git a/qtm/data/Demo.qtm b/qtm_rt/data/Demo.qtm similarity index 100% rename from qtm/data/Demo.qtm rename to qtm_rt/data/Demo.qtm diff --git a/qtm/discovery.py b/qtm_rt/discovery.py similarity index 98% rename from qtm/discovery.py rename to qtm_rt/discovery.py index 45be6fc..b90fd8d 100644 --- a/qtm/discovery.py +++ b/qtm_rt/discovery.py @@ -9,7 +9,7 @@ # pylint: disable=C0103 -LOG = logging.getLogger("qtm") +LOG = logging.getLogger("qtm_rt") QRTDiscoveryP1 = struct.Struct("H") diff --git a/qtm/packet.py b/qtm_rt/packet.py similarity index 99% rename from qtm/packet.py rename to qtm_rt/packet.py index be67b52..65ee9f5 100644 --- a/qtm/packet.py +++ b/qtm_rt/packet.py @@ -267,7 +267,7 @@ class QRTPacket(object): :: - from qtm.packet import QRTComponentType + from qtm_rt.packet import QRTComponentType if QRTComponentType.Component3d in packet.components: header, markers = packet.get_3d_markers() diff --git a/qtm/protocol.py b/qtm_rt/protocol.py similarity index 96% rename from qtm/protocol.py rename to qtm_rt/protocol.py index 9f88c0e..c14c7c5 100644 --- a/qtm/protocol.py +++ b/qtm_rt/protocol.py @@ -7,14 +7,14 @@ import collections import logging -from qtm.packet import QRTPacketType -from qtm.packet import QRTPacket, QRTEvent -from qtm.packet import RTheader, RTEvent, RTCommand -from qtm.receiver import Receiver +from qtm_rt.packet import QRTPacketType +from qtm_rt.packet import QRTPacket, QRTEvent +from qtm_rt.packet import RTheader, RTEvent, RTCommand +from qtm_rt.receiver import Receiver # pylint: disable=C0330 -LOG = logging.getLogger("qtm") +LOG = logging.getLogger("qtm_rt") class QRTCommandException(Exception): diff --git a/qtm/qrt.py b/qtm_rt/qrt.py similarity index 95% rename from qtm/qrt.py rename to qtm_rt/qrt.py index a1216ff..aaaed6b 100644 --- a/qtm/qrt.py +++ b/qtm_rt/qrt.py @@ -4,12 +4,12 @@ import logging from functools import wraps -from qtm.packet import QRTPacketType, QRTPacket -from qtm.protocol import QTMProtocol, QRTCommandException +from qtm_rt.packet import QRTPacketType, QRTPacket +from qtm_rt.protocol import QTMProtocol, QRTCommandException # pylint: disable=C0330 -LOG = logging.getLogger("qtm") # pylint: disable C0103 +LOG = logging.getLogger("qtm_rt") # pylint: disable C0103 def validate_response(expected_responses): @@ -37,7 +37,7 @@ async def wrapper(*args, **kwargs): class QRTConnection(object): """Represent a connection to QTM. - Returned by :func:`~qtm.connect` when successfuly connected to QTM. + Returned by :func:`~qtm_rt.connect` when successfuly connected to QTM. """ def __init__(self, protocol: QTMProtocol, timeout): @@ -69,10 +69,10 @@ async def byte_order(self): ) async def get_state(self): - """Get the latest state change of QTM. If the :func:`~qtm.connect` on_event + """Get the latest state change of QTM. If the :func:`~qtm_rt.connect` on_event callback was set the callback will be called as well. - :rtype: A :class:`qtm.QRTEvent` + :rtype: A :class:`qtm_rt.QRTEvent` """ await self._protocol.send_command("getstate", callback=False) return await self._protocol.await_event() @@ -80,12 +80,12 @@ async def get_state(self): async def await_event(self, event=None, timeout=30): """Wait for an event from QTM. - :param event: A :class:`qtm.QRTEvent` + :param event: A :class:`qtm_rt.QRTEvent` to wait for a specific event. Otherwise wait for any event. :param timeout: Max time to wait for event. - :rtype: A :class:`qtm.QRTEvent` + :rtype: A :class:`qtm_rt.QRTEvent` """ return await self._protocol.await_event(event, timeout=timeout) @@ -134,7 +134,7 @@ async def get_current_frame(self, components=None) -> QRTPacket: '6deuler', '6deulerres', 'gazevector', 'eyetracker', 'image', 'timecode', 'skeleton', 'skeleton:global' - :rtype: A :class:`qtm.QRTPacket` containing requested components + :rtype: A :class:`qtm_rt.QRTPacket` containing requested components """ _validate_components(components) @@ -145,7 +145,7 @@ async def get_current_frame(self, components=None) -> QRTPacket: ) async def stream_frames(self, frames="allframes", components=None, on_packet=None): - """Stream measured frames from QTM until :func:`~qtm.QRTConnection.stream_frames_stop` + """Stream measured frames from QTM until :func:`~qtm_rt.QRTConnection.stream_frames_stop` is called. diff --git a/qtm/reboot.py b/qtm_rt/reboot.py similarity index 96% rename from qtm/reboot.py rename to qtm_rt/reboot.py index 079cf99..d30ba69 100644 --- a/qtm/reboot.py +++ b/qtm_rt/reboot.py @@ -3,7 +3,7 @@ import asyncio import logging -LOG = logging.getLogger("qtm") +LOG = logging.getLogger("qtm_rt") DEFAULT_DISCOVERY_PORT = 9930 diff --git a/qtm/receiver.py b/qtm_rt/receiver.py similarity index 88% rename from qtm/receiver.py rename to qtm_rt/receiver.py index 45aef03..82b6fd3 100644 --- a/qtm/receiver.py +++ b/qtm_rt/receiver.py @@ -1,10 +1,10 @@ import logging -from qtm.packet import QRTPacketType -from qtm.packet import QRTPacket, QRTEvent -from qtm.packet import RTheader, RTEvent, RTCommand +from qtm_rt.packet import QRTPacketType +from qtm_rt.packet import QRTPacket, QRTEvent +from qtm_rt.packet import RTheader, RTEvent, RTCommand -LOG = logging.getLogger("qtm") +LOG = logging.getLogger("qtm_rt") class Receiver(object): diff --git a/setup.py b/setup.py index 621d7b3..cd2d205 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,12 @@ from setuptools import setup -version = "2.1.2" +version = "3.0.0" setup( - name="qtm", + name="qtm-rt", version=version, - description="DEPRECATED", - long_description="Future versions of this package will go under the name \"qtm-rt\".", + description="QTM Python SDK", + long_description="For older versions, see \"qtm\" package.", url="https://github.com/qualisys/qualisys_python_sdk", download_url="https://github.com/qualisys/qualisys_python_sdk/tarball/{}".format( version @@ -14,8 +14,8 @@ author="Martin Gejke", author_email="support@qualisys.com", license="MIT", - packages=["qtm"], - package_data={"qtm": ["data/demo.qtm"]}, + packages=["qtm_rt"], + package_data={"qtm_rt": ["data/demo.qtm"]}, classifiers=[ "Operating System :: OS Independent", "Intended Audience :: Developers", diff --git a/test/qrtconnection_test.py b/test/qrtconnection_test.py index e739a4e..5dbf5e2 100644 --- a/test/qrtconnection_test.py +++ b/test/qrtconnection_test.py @@ -6,8 +6,8 @@ import pytest -from qtm.qrt import QRTConnection, connect -from qtm.protocol import QTMProtocol, QRTCommandException +from qtm_rt.qrt import QRTConnection, connect +from qtm_rt.protocol import QTMProtocol, QRTCommandException # pylint: disable=W0621, C0111, C0330, E1101, W0212 diff --git a/test/qtmprotocol_test.py b/test/qtmprotocol_test.py index 1f4f27d..ea9ee2f 100644 --- a/test/qtmprotocol_test.py +++ b/test/qtmprotocol_test.py @@ -6,8 +6,8 @@ import pytest -from qtm.protocol import QTMProtocol, QRTCommandException -from qtm.packet import QRTEvent, RTEvent +from qtm_rt.protocol import QTMProtocol, QRTCommandException +from qtm_rt.packet import QRTEvent, RTEvent # pylint: disable=W0621, C0111, W0212