diff --git a/job_templates/snippet/property_parameter-definition_common.xml.em b/job_templates/snippet/property_parameter-definition_common.xml.em index b96f0a8ab..45e82038f 100644 --- a/job_templates/snippet/property_parameter-definition_common.xml.em +++ b/job_templates/snippet/property_parameter-definition_common.xml.em @@ -47,7 +47,7 @@ To use the latest released version, use an empty string. @ubuntu_distro @{ -choices = ['jammy'] +choices = ['noble', 'jammy'] choices.remove(ubuntu_distro) }@ @[for choice in choices]@ diff --git a/linux_docker_resources/Dockerfile b/linux_docker_resources/Dockerfile index 42beedd7f..0ea0410bd 100644 --- a/linux_docker_resources/Dockerfile +++ b/linux_docker_resources/Dockerfile @@ -37,7 +37,7 @@ RUN echo "deb http://repo.ros2.org/ubuntu/testing/ `lsb_release -cs` main" > /et RUN echo "Bust Cache for key update 2021-06-01" && curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key | apt-key add - # Add the OSRF repositories to the apt sources list. -RUN echo "deb http://packages.osrfoundation.org/gazebo/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-latest.list +RUN if test \( ${UBUNTU_DISTRO} != noble \); then echo "deb http://packages.osrfoundation.org/gazebo/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-latest.list; fi RUN curl --silent http://packages.osrfoundation.org/gazebo.key | apt-key add - # Install some development tools. @@ -51,8 +51,8 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ git \ libbenchmark-dev \ libbullet-dev \ - libignition-cmake2-dev \ - libignition-math6-dev \ + $(if test ${UBUNTU_DISTRO} != noble; then echo libignition-cmake2-dev; fi) \ + $(if test ${UBUNTU_DISTRO} != noble; then echo libignition-math6-dev; fi) \ liborocos-kdl-dev \ libspdlog-dev \ libsqlite3-dev \ @@ -86,14 +86,14 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ yamllint # Install LTTng-related packages starting from Iron only. -RUN if test \( ${UBUNTU_DISTRO} = jammy -a ${ROS_DISTRO} != humble \); then apt-get update && apt-get install --no-install-recommends -y \ +RUN if test \( ${ROS_DISTRO} != humble \); then apt-get update && apt-get install --no-install-recommends -y \ liblttng-ust-dev \ lttng-tools \ python3-babeltrace; fi # Iron uses python3-lttng, but then starting after Iron we switch to liblttng-ctl-dev. -RUN if test \( ${UBUNTU_DISTRO} = jammy -a ${ROS_DISTRO} = iron \); then apt-get update && apt-get install --no-install-recommends -y \ +RUN if test \( ${ROS_DISTRO} = iron \); then apt-get update && apt-get install --no-install-recommends -y \ python3-lttng; fi -RUN if test \( ${UBUNTU_DISTRO} = jammy -a ${ROS_DISTRO} = rolling \); then apt-get update && apt-get install --no-install-recommends -y \ +RUN if test \( ${ROS_DISTRO} = rolling \); then apt-get update && apt-get install --no-install-recommends -y \ liblttng-ctl-dev; fi # Install clang if build arg is true @@ -101,7 +101,8 @@ RUN if test ${COMPILE_WITH_CLANG} = true; then apt-get update && apt-get install # Install coverage build dependencies. RUN apt-get update && apt-get install --no-install-recommends -y lcov -RUN pip3 install -U lcov_cobertura_fix + +RUN pip3 install -U lcov_cobertura_fix $(if test ${UBUNTU_DISTRO} = noble; then echo --break-system-packages; fi) # Install the Connext binary from the OSRF repositories. RUN if test \( ${PLATFORM} = x86 -a ${INSTALL_CONNEXT_DEBS} = true -a ${UBUNTU_DISTRO} = jammy \); then apt-get update && RTI_NC_LICENSE_ACCEPTED=yes apt-get install -y rti-connext-dds-6.0.1; fi diff --git a/ros2_batch_job/util.py b/ros2_batch_job/util.py index 04f1380f5..f223f5654 100644 --- a/ros2_batch_job/util.py +++ b/ros2_batch_job/util.py @@ -242,11 +242,10 @@ def create_protocol(*args, **kwargs): else: return MyProtocol(cmd, exit_on_error, *args, **kwargs) - @asyncio.coroutine - def run_coroutine(future): + async def run_coroutine(future): kwargs['emulate_tty'] = True - transport, protocol = yield from async_execute_process(create_protocol, cmd, **kwargs) - returncode = yield from protocol.complete + transport, protocol = await async_execute_process(create_protocol, cmd, **kwargs) + returncode = await protocol.complete future.set_result(returncode) future = asyncio.Future() diff --git a/ros2_batch_job/vendor/osrf_pycommon/.github/workflows/ci.yaml b/ros2_batch_job/vendor/osrf_pycommon/.github/workflows/ci.yaml new file mode 100644 index 000000000..da4b6ede0 --- /dev/null +++ b/ros2_batch_job/vendor/osrf_pycommon/.github/workflows/ci.yaml @@ -0,0 +1,31 @@ +name: osrf_pycommon-ci + +on: + push: + branches: [master] + pull_request: + +jobs: + build: + strategy: + matrix: + os: [macos-latest, ubuntu-22.04, windows-latest] + python: ['3.7', '3.8', '3.9', '3.10'] + include: + - os: ubuntu-20.04 + python: '3.6' + name: osrf_pycommon tests + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{matrix.python}} + uses: actions/setup-python@v4 + with: + python-version: ${{matrix.python}} + - name: Install dependencies + run: | + python -m pip install -U -e .[test] pytest-cov + - name: Run tests + run: | + python -m pytest tests --cov diff --git a/ros2_batch_job/vendor/osrf_pycommon/.gitignore b/ros2_batch_job/vendor/osrf_pycommon/.gitignore index 3ae1d8847..037c9cd63 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/.gitignore +++ b/ros2_batch_job/vendor/osrf_pycommon/.gitignore @@ -53,3 +53,4 @@ coverage.xml docs/_build/ deb_dist +.pytest_cache diff --git a/ros2_batch_job/vendor/osrf_pycommon/.travis.yml b/ros2_batch_job/vendor/osrf_pycommon/.travis.yml deleted file mode 100644 index aceffae3e..000000000 --- a/ros2_batch_job/vendor/osrf_pycommon/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: python -python: - - "2.7" - - "3.4" -install: - - pip install coverage nose flake8 mock - - pip install git+https://github.com/PyCQA/flake8-import-order.git -script: - - if [[ $TRAVIS_PYTHON_VERSION == 3* ]]; then COVER_INCLUSIVE=--cover-inclusive; fi - - PYTHONASYNCIODEBUG=1 python setup.py nosetests -s --with-coverage $COVER_INCLUSIVE -notifications: - email: false diff --git a/ros2_batch_job/vendor/osrf_pycommon/CHANGELOG.rst b/ros2_batch_job/vendor/osrf_pycommon/CHANGELOG.rst index bd896ca55..624a44594 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/CHANGELOG.rst +++ b/ros2_batch_job/vendor/osrf_pycommon/CHANGELOG.rst @@ -1,3 +1,128 @@ +2.1.4 (2023-08-21) +------------------ +* Catch all of the spurious warnings from get_event_loop. (`#94 `_) +* Contributors: Chris Lalancette + +2.1.3 (2023-07-11) +------------------ +* Add bookworm as a python3 target (`#91 `_) +* Suppress warning for specifically handled behavior (`#87 `_) +* Update supported platforms (`#93 `_) +* Add GitHub Actions CI workflow (`#88 `_) +* Contributors: Scott K Logan, Tully Foote + +2.1.2 (2023-02-14) +------------------ +* [master] Update maintainers - 2022-11-07 (`#89 `_) +* Contributors: Audrow Nash + +2.1.1 (2022-11-07) +------------------ +* Declare test dependencies in [test] extra (`#86 `_) +* Contributors: Scott K Logan + +2.1.0 (2022-05-10) +------------------ + +2.0.2 (2022-04-08) +------------------ +* Fix an importlib_metadata warning with Python 3.10. (`#84 `_) +* Contributors: Chris Lalancette + +2.0.1 (2022-02-14) +------------------ +* Don't release 2.x / master on Debian Buster. (`#83 `_) + Debian Buster is on Python 3.7: https://packages.debian.org/buster/python3 +* Stop using mock in favor of unittest.mock. (`#74 `_) + Mock has been deprecated since Python 3.3; see + https://pypi.org/project/mock/ . The recommended replacement + is unittest.mock, which seems to be a drop-in replacement. + Co-authored-by: William Woodall +* Fix dependencies (`#81 `_) + * Remove obsolete setuptools from install_requires + Now that pkg_resources are no longer used, there is no need to depend + on setuptools at runtime. + * Fix version-conditional dependency on importlib-metadata + Use version markers to depend on importlib-metadata correctly. Explicit + conditions mean that wheels built with setup.py will either have the dep + or not depending on what Python version they're built with, rather than + what version they're installed on. +* fix whitespace and date in changelog heading +* Contributors: Chris Lalancette, Michał Górny, Steven! Ragnarök, William Woodall + +2.0.0 (2022-02-01) +------------------ +* Replace the use of ``pkg_resources`` with the more modern ``importlib-metadata``. (`#66 `_) + * Note this means that from now on you can only release on >= Ubuntu focal as that was when ``python3-importlib-metadata`` was introduced. + * Used the ``1.0.x`` branch if you need an ealier version that still uses ``pkg_resources``. + Co-authored-by: William Woodall +* Contributors: Chris Lalancette + +1.0.1 (2022-01-20) +------------------ +* Update release distributions. (`#78 `_) +* Contributors: Steven! Ragnarök + +1.0.0 (2021-01-25) +------------------ +* Added missing conflict rules in stdeb.cfg. +* Removed Python 2 support. +* Contributors: Chris Lalancette, Timon Engelke + +0.2.1 (2021-01-25) +------------------ +* Fix osrf.py_common.process_utils.get_loop() implementation (`#70 `_) +* Contributors: Michel Hidalgo + +0.2.0 (2020-12-07) +------------------ +* Python 2/3 version conflict (`#69 `_) +* remove jessie because we no longer support 3.4 (`#67 `_) +* Remove deprecated use of asyncio.coroutine decorator. (`#64 `_) +* Fix the __str_\_ method for windows terminal_color. (`#65 `_) +* Contributors: Chris Lalancette, Jochen Sprickerhof, William Woodall + +0.1.10 (2020-05-08) +------------------- +* fixed simple deprecation warnings (issue `#61 `_) (`#63 `_) +* Also run tests with Python 3.7 and 3.8 (`#60 `_) +* Remove old py2 platforms, add Suite3 option with Ubuntu Focal (`#58 `_) +* Contributors: Shane Loretz, Zahi Kakish + +0.1.9 (2019-10-10 12:55:00 -0800) +--------------------------------- +* install resource marker file for package (`#56 `_) + +0.1.8 (2019-09-17 11:30:00 -0800) +--------------------------------- +* Install package manifest. (`#55 `_) + Signed-off-by: Dirk Thomas +* Rename ansi_escape_senquences to ansi_escape_sequences keeping backwards compatibility. (`#53 `_) +* Contributors: Chris Lalancette, Dirk Thomas + +0.1.7 (2019-04-11 12:45:00 -0800) +--------------------------------- +* Use keyword arguments only for protocol_class invocations (`#52 `_) +* Contributors: Daniel Stonier + +0.1.6 (2018-11-15 12:45:00 -0800) +--------------------------------- +- Changed package.xml to use python2 or python3 dependencies as appropriate. `#50 `_ + +0.1.5 (2018-06-19 21:00:00 -0800) +--------------------------------- +- Fixed a try-catch statement to adapt to changes in asyncio's raise behavior in `asyncio.get_event_loop()`. +- Small changes, mostly related to distribution. + +0.1.4 (2017-12-08 16:00:00 -0800) +--------------------------------- +- Only small test/linter fixes and documentation typos removed. + +0.1.3 (2017-03-28 19:30:00 -0800) +--------------------------------- +- Fix to support optional arguments in verb pattern `#24 `_ + + 0.1.2 (2016-03-28 19:30:00 -0800) --------------------------------- - Started keeping a changelog. diff --git a/ros2_batch_job/vendor/osrf_pycommon/CODEOWNERS b/ros2_batch_job/vendor/osrf_pycommon/CODEOWNERS new file mode 100644 index 000000000..bbfd6e003 --- /dev/null +++ b/ros2_batch_job/vendor/osrf_pycommon/CODEOWNERS @@ -0,0 +1,2 @@ +# This file was generated by https://github.com/audrow/update-ros2-repos +* @wjwwood diff --git a/ros2_batch_job/vendor/osrf_pycommon/MANIFEST.in b/ros2_batch_job/vendor/osrf_pycommon/MANIFEST.in new file mode 100644 index 000000000..501e4f862 --- /dev/null +++ b/ros2_batch_job/vendor/osrf_pycommon/MANIFEST.in @@ -0,0 +1,6 @@ +include CHANGELOG.rst +include LICENSE +include package.xml +include README.md + +recursive-include osrf_pycommon *.py \ No newline at end of file diff --git a/ros2_batch_job/vendor/osrf_pycommon/README.md b/ros2_batch_job/vendor/osrf_pycommon/README.md index fd46c4c93..20f169593 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/README.md +++ b/ros2_batch_job/vendor/osrf_pycommon/README.md @@ -1,4 +1,11 @@ osrf_pycommon ============= -Commonly needed Python modules, used by Python software developed at OSRF +Commonly needed Python modules, used by Python software developed at OSRF. + +Branches +======== + +If you are releasing (using ``stdeb`` or on the ROS buildfarm) for any Ubuntu < ``focal``, or for any OS that doesn't have a key for ``python3-importlib-metadata``, then you need to use the ``1.0.x`` branch, or the latest ``1.`` branch, because starting with ``2.0.0``, that dependency will be required. + +If you are using Python 2, then you should use the ``python2`` branch. diff --git a/ros2_batch_job/vendor/osrf_pycommon/_config.yml b/ros2_batch_job/vendor/osrf_pycommon/_config.yml new file mode 100644 index 000000000..2f7efbeab --- /dev/null +++ b/ros2_batch_job/vendor/osrf_pycommon/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-minimal \ No newline at end of file diff --git a/ros2_batch_job/vendor/osrf_pycommon/docs/index.rst b/ros2_batch_job/vendor/osrf_pycommon/docs/index.rst index 3fc4db077..86b0ddb77 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/docs/index.rst +++ b/ros2_batch_job/vendor/osrf_pycommon/docs/index.rst @@ -5,8 +5,8 @@ Things like ansi terminal coloring, capturing colored output from programs using subprocess, or even a simple logging system which provides some nice functionality over the built-in Python logging system. The functionality provided here should be generic enough to be reused in arbitrary scenarios and should avoid bringing in dependencies which are not part of the standard Python library. -Where possible Windows and Linux/OS X should be supported, and where it cannot it should be gracefully degrading. -Code should be pure Python as well as Python 2 and Python 3 bilingual. +Where possible Windows, Linux, and macOS should be supported, and where it cannot it should be gracefully degrading. +Code should be pure Python 3. Contents: @@ -64,13 +64,13 @@ That will "uninstall" the hooks into the ``PYTHONPATH`` which point to your sour Testing ------- -In order to run the tests you will need to install `nosetests `_, `flake8 `_, and `Mock `_. +In order to run the tests you will need to install `flake8 `_. -Once you have installed those, then run ``nosetest`` in the root of the ``osrf_pycommon`` source directory: +Once you have installed those, then run ``unittest``: .. code-block:: bash - $ nosetests + $ python3 -m unittest discover -v tests Building the Documentation -------------------------- diff --git a/ros2_batch_job/vendor/osrf_pycommon/docs/process_utils.rst b/ros2_batch_job/vendor/osrf_pycommon/docs/process_utils.rst index 40b6edc1b..3ee9e8a6b 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/docs/process_utils.rst +++ b/ros2_batch_job/vendor/osrf_pycommon/docs/process_utils.rst @@ -12,14 +12,14 @@ These are the main sections of this module: Asynchronous Process Utilities ------------------------------ -There is a function and class which can be used together with your custom `Tollius `_ or `asyncio `_ run loop. +There is a function and class which can be used together with your custom `asyncio `_ run loop. The :py:func:`osrf_pycommon.process_utils.async_execute_process` function is a `coroutine `_ which allows you to run a process and get the output back bit by bit in real-time, either with stdout and stderr separated or combined. This function also allows you to emulate the terminal using a pty simply by toggling a flag in the parameters. Along side this coroutine is a `Protocol `_ class, :py:class:`osrf_pycommon.process_utils.AsyncSubprocessProtocol`, from which you can inherit in order to customize how the yielded output is handled. -Because this coroutine is built on the ``trollius``/``asyncio`` framework's subprocess functions, it is portable and should behave the same on all major OS's. (including on Windows where an IOCP implementation is used) +Because this coroutine is built on the ``asyncio`` framework's subprocess functions, it is portable and should behave the same on all major OS's. (including on Windows where an IOCP implementation is used) .. autofunction:: osrf_pycommon.process_utils.async_execute_process @@ -33,9 +33,11 @@ In addtion to these functions, there is a utility function for getting the corre Treatment of File Descriptors ----------------------------- -Unlike ``subprocess.Popen``, all of the ``process_utils`` functions behave the same way on Python versions 2.7 through 3.4, and they do not close `inheritable `. file descriptors before starting subprocesses. This is equivalent to passing ``close_fds=False`` to ``subprocess.Popen`` on all Python versions. +Like Python 3.4's ``subprocess.Popen`` (and newer versions), all of the ``process_utils`` functions do not close `inheritable ` file descriptors before starting subprocesses. +This is equivalent to passing ``close_fds=False`` to ``subprocess.Popen`` on all Python versions. -In Python 3.2, the ``subprocess.Popen`` default for the ``close_fds`` option changed from ``False`` to ``True`` so that file descriptors opened by the parent process were closed before spawning the child process. In Python 3.4, `PEP 0446 `_ additionally made it so even when ``close_fds=False`` file descriptors which are `non-inheritable `_ are still closed before spawning the subprocess. +For historical context, in Python 3.2, the ``subprocess.Popen`` default for the ``close_fds`` option changed from ``False`` to ``True`` so that file descriptors opened by the parent process were closed before spawning the child process. +In Python 3.4, `PEP 0446 `_ additionally made it so even when ``close_fds=False`` file descriptors which are `non-inheritable `_ are still closed before spawning the subprocess. If you want to be able to pass file descriptors to subprocesses in Python 3.4 or higher, you will need to make sure they are `inheritable `. @@ -47,7 +49,7 @@ For synchronous execution and output capture of subprocess, there are two functi - :py:func:`osrf_pycommon.process_utils.execute_process` - :py:func:`osrf_pycommon.process_utils.execute_process_split` -These functions are not yet using the ``trollius``/``asyncio`` framework as a back-end and therefore on Windows will not stream the data from the subprocess as it does on Unix machines. +These functions are not yet using the ``asyncio`` framework as a back-end and therefore on Windows will not stream the data from the subprocess as it does on Unix machines. Instead data will not be yielded until the subprocess is finished and all output is buffered (the normal warnings about long running programs with lots of output apply). The streaming of output does not work on Windows because on Windows the :py:func:`select.select` method only works on sockets and not file-like objects which are used with subprocess pipes. diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/cli_utils/common.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/cli_utils/common.py index 3518fd9b3..0fca9b571 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/cli_utils/common.py +++ b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/cli_utils/common.py @@ -141,7 +141,7 @@ def extract_argument_group(args, delimiting_option): extracted_args.extend(tail) break else: - # Terminator foud, put args up, but not including terminator + # Terminator found, put args up, but not including terminator # in extracted_args extracted_args.extend(tail[:next_terminator]) # And put arguments after the terminator back in trimmed_args diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/cli_utils/verb_pattern.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/cli_utils/verb_pattern.py index ab9be8775..d6b546fe0 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/cli_utils/verb_pattern.py +++ b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/cli_utils/verb_pattern.py @@ -14,9 +14,13 @@ """API for implementing commands and verbs which used the verb pattern.""" +import sys import inspect -import pkg_resources +try: + import importlib.metadata as importlib_metadata +except ModuleNotFoundError: + import importlib_metadata def call_prepare_arguments(func, parser, sysargs=None): @@ -27,7 +31,7 @@ def call_prepare_arguments(func, parser, sysargs=None): the current arguments being processed. :param func: Callable ``prepare_arguments`` function. - :type func: Callabe + :type func: Callable :param parser: parser which is always passed to the function :type parser: :py:class:`argparse.ArgumentParser` :param sysargs: arguments to optionally pass to the function, if needed @@ -41,18 +45,36 @@ def call_prepare_arguments(func, parser, sysargs=None): func_args = [parser] # If the provided function takes two arguments and args were given # also give the args to the function - arguments, _, _, defaults = inspect.getargspec(func) + + # Remove the following if condition and keep else condition once Xenial is + # dropped + if sys.version_info[0] < 3: + arguments, _, _, defaults = inspect.getargspec(func) + + else: + arguments, _, _, defaults, _, _, _ = inspect.getfullargspec(func) + if arguments[0] == 'self': del arguments[0] if defaults: arguments = arguments[:-len(defaults)] if len(arguments) not in [1, 2]: + # Remove the following if condition once Xenial is dropped + if sys.version_info[0] < 3: + raise ValueError("Given function '{0}' must have one or two " + "parameters (excluding self), but got '{1}' " + "parameters: '{2}'" + .format(func.__name__, + len(arguments), + ', '.join(inspect.getargspec(func)[0]))) + raise ValueError("Given function '{0}' must have one or two " "parameters (excluding self), but got '{1}' " "parameters: '{2}'" .format(func.__name__, len(arguments), - ', '.join(inspect.getargspec(func)[0]))) + ', '.join(inspect.getfullargspec(func)[0]))) + if len(arguments) == 2: func_args.append(sysargs or []) return func(*func_args) or parser @@ -61,7 +83,7 @@ def call_prepare_arguments(func, parser, sysargs=None): def create_subparsers(parser, cmd_name, verbs, group, sysargs, title=None): """Creates argparse subparsers for each verb which can be discovered. - Using the ``verbs`` parameter, the availble verbs are iterated through. + Using the ``verbs`` parameter, the available verbs are iterated through. For each verb a subparser is created for it using the ``parser`` parameter. The ``cmd_name`` is used to fill the title and description of the ``add_subparsers`` function call. @@ -117,7 +139,7 @@ def create_subparsers(parser, cmd_name, verbs, group, sysargs, title=None): def default_argument_preprocessor(args): - """Return unmodifed args and an empty dict for extras""" + """Return unmodified args and an empty dict for extras""" extras = {} return args, extras @@ -130,7 +152,12 @@ def list_verbs(group): :rtype: list of str """ verbs = [] - for entry_point in pkg_resources.iter_entry_points(group=group): + entry_points = importlib_metadata.entry_points() + if hasattr(entry_points, 'select'): + groups = entry_points.select(group=group) + else: + groups = entry_points.get(group, []) + for entry_point in groups: verbs.append(entry_point.name) return verbs @@ -143,7 +170,12 @@ def load_verb_description(verb_name, group): :returns: verb description :rtype: dict """ - for entry_point in pkg_resources.iter_entry_points(group=group): + entry_points = importlib_metadata.entry_points() + if hasattr(entry_points, 'select'): + groups = entry_points.select(group=group) + else: + groups = entry_points.get(group, []) + for entry_point in groups: if entry_point.name == verb_name: return entry_point.load() @@ -152,7 +184,7 @@ def split_arguments_by_verb(arguments): """Split arguments by verb. Given a list of arguments (list of strings), the verb, the pre verb - arguments, and the post verb arugments are returned. + arguments, and the post verb arguments are returned. For example: diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/async_execute_process.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/async_execute_process.py index 072c71838..07b5da90f 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/async_execute_process.py +++ b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/async_execute_process.py @@ -16,18 +16,9 @@ import sys -if sys.version_info >= (3, 4) and 'trollius' not in sys.modules: - # If using Python 3.4 or greater, asyncio is always available. - # However, if trollius has already been imported, use that. - from .async_execute_process_asyncio import async_execute_process - from .async_execute_process_asyncio import get_loop - from .async_execute_process_asyncio import asyncio -else: - # If Python is < 3.3 then a SyntaxError will occur with asyncio - # so we will use Trollius on all platforms below Python 3.4. - from .async_execute_process_trollius import async_execute_process - from .async_execute_process_trollius import get_loop - from .async_execute_process_trollius import asyncio +from .async_execute_process_asyncio import async_execute_process +from .async_execute_process_asyncio import get_loop +from .async_execute_process_asyncio import asyncio __all__ = [ 'async_execute_process', @@ -39,9 +30,7 @@ Coroutine to execute a subprocess and yield the output back asynchronously. This function is meant to be used with the Python :py:mod:`asyncio` module, -which is available via pip with Python 3.3 and built-in to Python 3.4. -On Python >= 2.6 you can use the :py:mod:`trollius` module to get the same -functionality, but without using the new ``yield from`` syntax. +which is available in Python 3.5 or greater. Here is an example of how to use this function: @@ -53,40 +42,16 @@ from osrf_pycommon.process_utils import get_loop - @asyncio.coroutine - def setup(): - transport, protocol = yield from async_execute_process( + async def setup(): + transport, protocol = await async_execute_process( AsyncSubprocessProtocol, ['ls', '/usr']) - returncode = yield from protocol.complete + returncode = await protocol.complete return returncode retcode = get_loop().run_until_complete(setup()) get_loop().close() -That same example using :py:mod:`trollius` would look like this: - -.. code-block:: python - - import trollius as asyncio - from osrf_pycommon.process_utils import async_execute_process - from osrf_pycommon.process_utils import AsyncSubprocessProtocol - from osrf_pycommon.process_utils import get_loop - - - @asyncio.coroutine - def setup(): - transport, protocol = yield asyncio.From(async_execute_process( - AsyncSubprocessProtocol, ['ls', '/usr'])) - returncode = yield asyncio.From(protocol.complete) - raise asyncio.Return(returncode) - - retcode = get_loop().run_until_complete(setup()) - get_loop().close() - -This difference is required because in Python < 3.3 the ``yield from`` syntax -is not valid. - -In both examples, the first argument is the default +Tthe first argument is the default :py:class:`AsyncSubprocessProtocol` protocol class, which simply prints output from stdout to stdout and output from stderr to stderr. @@ -96,7 +61,7 @@ def setup(): ``on_process_exited`` functions. See the documentation for the :py:class:`AsyncSubprocessProtocol` class for -more details, but here is an example which uses asyncio from Python 3.4: +more details, but here is an example which uses asyncio from Python 3.5: .. code-block:: python @@ -123,15 +88,14 @@ def on_process_exited(self, returncode): self.fh.close() - @asyncio.coroutine - def log_command_to_file(cmd, file_name): + async def log_command_to_file(cmd, file_name): def create_protocol(**kwargs): return MyProtocol(file_name, **kwargs) - transport, protocol = yield from async_execute_process( + transport, protocol = await async_execute_process( create_protocol, cmd) - returncode = yield from protocol.complete + returncode = await protocol.complete return returncode get_loop().run_until_complete( @@ -179,7 +143,7 @@ def on_process_exited(self, returncode): stdout and stderr and does nothing when the process exits. Data received by the ``on_stdout_received`` and ``on_stderr_received`` - functions is always in bytes (``str`` in Python2 and ``bytes`` in Python3). + functions is always in ``bytes``. Therefore, it may be necessary to call ``.decode()`` on the data before printing to the screen. @@ -225,11 +189,10 @@ def on_stderr_close(self, exc): from osrf_pycommon.process_utils import get_loop - @asyncio.coroutine - def setup(): - transport, protocol = yield from async_execute_process( + async def setup(): + transport, protocol = await async_execute_process( AsyncSubprocessProtocol, ['ls', '-G', '/usr']) - retcode = yield from protocol.complete + retcode = await protocol.complete print("Exited with", retcode) # This will block until the protocol.complete Future is done. diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/async_execute_process_asyncio/impl.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/async_execute_process_asyncio/impl.py index 5521cc336..1db413fd6 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/async_execute_process_asyncio/impl.py +++ b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/async_execute_process_asyncio/impl.py @@ -28,8 +28,7 @@ def get_loop(): return get_loop_impl(asyncio) -@asyncio.coroutine -def _async_execute_process_nopty( +async def _async_execute_process_nopty( protocol_class, cmd, cwd, env, shell, stderr_to_stdout=True ): @@ -39,11 +38,11 @@ def _async_execute_process_nopty( stderr = asyncio.subprocess.STDOUT # Start the subprocess if shell is True: - transport, protocol = yield from loop.subprocess_shell( + transport, protocol = await loop.subprocess_shell( protocol_class, " ".join(cmd), cwd=cwd, env=env, stderr=stderr, close_fds=False) else: - transport, protocol = yield from loop.subprocess_exec( + transport, protocol = await loop.subprocess_exec( protocol_class, *cmd, cwd=cwd, env=env, stderr=stderr, close_fds=False) return transport, protocol @@ -51,8 +50,7 @@ def _async_execute_process_nopty( if has_pty: # If pty is availabe, use them to emulate the tty - @asyncio.coroutine - def _async_execute_process_pty( + async def _async_execute_process_pty( protocol_class, cmd, cwd, env, shell, stderr_to_stdout=True ): @@ -65,15 +63,19 @@ def _async_execute_process_pty( stderr_master, stderr_slave = pty.openpty() def protocol_factory(): - return protocol_class(None, stdout_master, stderr_master) + return protocol_class( + stdin=None, + stdout=stdout_master, + stderr=stderr_master + ) # Start the subprocess if shell is True: - transport, protocol = yield from loop.subprocess_shell( + transport, protocol = await loop.subprocess_shell( protocol_factory, " ".join(cmd), cwd=cwd, env=env, stdout=stdout_slave, stderr=stderr_slave, close_fds=False) else: - transport, protocol = yield from loop.subprocess_exec( + transport, protocol = await loop.subprocess_exec( protocol_factory, *cmd, cwd=cwd, env=env, stdout=stdout_slave, stderr=stderr_slave, close_fds=False) @@ -114,10 +116,10 @@ def connection_lost(self, exc): # Also store the transport, protocol tuple for each call to # connect_read_pipe, to prevent the destruction of the protocol # class instance, otherwise no data is received. - protocol.stdout_tuple = yield from loop.connect_read_pipe( + protocol.stdout_tuple = await loop.connect_read_pipe( PtyStdoutProtocol, os.fdopen(stdout_master, 'rb', 0)) if not stderr_to_stdout: - protocol.stderr_tuple = yield from loop.connect_read_pipe( + protocol.stderr_tuple = await loop.connect_read_pipe( PtyStderrProtocol, os.fdopen(stderr_master, 'rb', 0)) # Return the protocol and transport return transport, protocol @@ -125,17 +127,16 @@ def connection_lost(self, exc): _async_execute_process_pty = _async_execute_process_nopty -@asyncio.coroutine -def async_execute_process( +async def async_execute_process( protocol_class, cmd=None, cwd=None, env=None, shell=False, emulate_tty=False, stderr_to_stdout=True ): if emulate_tty: - transport, protocol = yield from _async_execute_process_pty( + transport, protocol = await _async_execute_process_pty( protocol_class, cmd, cwd, env, shell, stderr_to_stdout) else: - transport, protocol = yield from _async_execute_process_nopty( + transport, protocol = await _async_execute_process_nopty( protocol_class, cmd, cwd, env, shell, stderr_to_stdout) return transport, protocol diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/async_execute_process_trollius.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/async_execute_process_trollius.py deleted file mode 100644 index 70bcfedda..000000000 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/async_execute_process_trollius.py +++ /dev/null @@ -1,144 +0,0 @@ -# Copyright 2014 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import sys - -# Conditionally import so that nosetest --with-coverge --cover-inclusive works. -if sys.version_info < (3, 4) or 'trollius' in sys.modules: - import trollius as asyncio - - from trollius import From - from trollius import Return - - try: - import pty - has_pty = True - except ImportError: - has_pty = False - - from .get_loop_impl import get_loop_impl - - def get_loop(): - return get_loop_impl(asyncio) - - @asyncio.coroutine - def _async_execute_process_nopty( - protocol_class, cmd, cwd, env, shell, - stderr_to_stdout=True - ): - loop = get_loop() - stderr = asyncio.subprocess.PIPE - if stderr_to_stdout is True: - stderr = asyncio.subprocess.STDOUT - # Start the subprocess - if shell is True: - transport, protocol = yield From(loop.subprocess_shell( - protocol_class, " ".join(cmd), cwd=cwd, env=env, - stderr=stderr, close_fds=False)) - else: - transport, protocol = yield From(loop.subprocess_exec( - protocol_class, *cmd, cwd=cwd, env=env, - stderr=stderr, close_fds=False)) - raise Return(transport, protocol) - - if has_pty: - # If pty is availabe, use them to emulate the tty - @asyncio.coroutine - def _async_execute_process_pty( - protocol_class, cmd, cwd, env, shell, - stderr_to_stdout=True - ): - loop = get_loop() - # Create the PTY's - stdout_master, stdout_slave = pty.openpty() - if stderr_to_stdout: - stderr_master, stderr_slave = stdout_master, stdout_slave - else: - stderr_master, stderr_slave = pty.openpty() - - def protocol_factory(): - return protocol_class(None, stdout_master, stderr_master) - - # Start the subprocess - if shell is True: - transport, protocol = yield From(loop.subprocess_shell( - protocol_factory, " ".join(cmd), cwd=cwd, env=env, - stdout=stdout_slave, stderr=stderr_slave, close_fds=False)) - else: - transport, protocol = yield From(loop.subprocess_exec( - protocol_factory, *cmd, cwd=cwd, env=env, - stdout=stdout_slave, stderr=stderr_slave, close_fds=False)) - - # Close our copies of the slaves, - # the child's copy of the slave remain open until it terminates - os.close(stdout_slave) - if not stderr_to_stdout: - os.close(stderr_slave) - - # Create Protocol classes - class PtyStdoutProtocol(asyncio.Protocol): - def connection_made(self, transport): - if hasattr(protocol, 'on_stdout_open'): - protocol.on_stdout_open() - - def data_received(self, data): - if hasattr(protocol, 'on_stdout_received'): - protocol.on_stdout_received(data) - - def connection_lost(self, exc): - if hasattr(protocol, 'on_stdout_close'): - protocol.on_stdout_close(exc) - - class PtyStderrProtocol(asyncio.Protocol): - def connection_made(self, transport): - if hasattr(protocol, 'on_stderr_open'): - protocol.on_stderr_open() - - def data_received(self, data): - if hasattr(protocol, 'on_stderr_received'): - protocol.on_stderr_received(data) - - def connection_lost(self, exc): - if hasattr(protocol, 'on_stderr_close'): - protocol.on_stderr_close(exc) - - # Add the pty's to the read loop - # Also store the transport, protocol tuple for each call to - # connect_read_pipe, to prevent the destruction of the protocol - # class instance, otherwise no data is received. - protocol.stdout_tuple = yield From(loop.connect_read_pipe( - PtyStdoutProtocol, os.fdopen(stdout_master, 'rb', 0))) - if not stderr_to_stdout: - protocol.stderr_tuple = yield From(loop.connect_read_pipe( - PtyStderrProtocol, os.fdopen(stderr_master, 'rb', 0))) - # Return the protocol and transport - raise Return(transport, protocol) - else: - _async_execute_process_pty = _async_execute_process_nopty - - @asyncio.coroutine - def async_execute_process( - protocol_class, cmd=None, cwd=None, env=None, shell=False, - emulate_tty=False, stderr_to_stdout=True - ): - if emulate_tty: - transport, protocol = yield From(_async_execute_process_pty( - protocol_class, cmd, cwd, env, shell, - stderr_to_stdout)) - else: - transport, protocol = yield From(_async_execute_process_nopty( - protocol_class, cmd, cwd, env, shell, - stderr_to_stdout)) - raise Return(transport, protocol) diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/execute_process_nopty.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/execute_process_nopty.py index 57c9a6d7c..fd22aeebc 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/execute_process_nopty.py +++ b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/execute_process_nopty.py @@ -30,7 +30,7 @@ def _process_incoming_lines(incoming, left_over): # This function takes the new data, the left over data from last time # and returns a list of complete lines (separated by sep) as well as # any sep trailing data for the next iteration - # This function takes and returns bytes only (str in Python2) + # This function takes and returns bytes only combined = (left_over + incoming) lines = combined.splitlines(True) if not lines: diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/get_loop_impl.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/get_loop_impl.py index 2ffd3d57c..a798f47c7 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/get_loop_impl.py +++ b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/get_loop_impl.py @@ -14,23 +14,49 @@ import os import threading +import warnings _thread_local = threading.local() def get_loop_impl(asyncio): - global _thread_local - if getattr(_thread_local, 'loop_has_been_setup', False): - return asyncio.get_event_loop() - # Setup this thread's loop and return it - if os.name == 'nt': - loop = asyncio.ProactorEventLoop() - asyncio.set_event_loop(loop) - else: - try: - loop = asyncio.get_event_loop() - except AssertionError: - loop = asyncio.new_event_loop() - asyncio.set_event_loop(loop) - _thread_local.loop_has_been_setup = True + # See the note in + # https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop # noqa + # In short, between Python 3.10.0 and 3.10.8, this unconditionally raises a + # DeprecationWarning. But after 3.10.8, it only raises the warning if + # ther eis no current loop set in the policy. Since we are setting a loop + # in the policy, this warning is spurious, and will go away once we get + # away from Python 3.10.6 (verified with Python 3.11.3). + with warnings.catch_warnings(): + warnings.filterwarnings( + 'ignore', + 'There is no current event loop', + DeprecationWarning) + + global _thread_local + if getattr(_thread_local, 'loop_has_been_setup', False): + return asyncio.get_event_loop() + # Setup this thread's loop and return it + if os.name == 'nt': + try: + loop = asyncio.get_event_loop() + if not isinstance(loop, asyncio.ProactorEventLoop): + # Before replacing the existing loop, explicitly + # close it to prevent an implicit close during + # garbage collection, which may or may not be a + # problem depending on the loop implementation. + loop.close() + loop = asyncio.ProactorEventLoop() + asyncio.set_event_loop(loop) + except (RuntimeError, AssertionError): + loop = asyncio.ProactorEventLoop() + asyncio.set_event_loop(loop) + else: + try: + loop = asyncio.get_event_loop() + except (RuntimeError, AssertionError): + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + _thread_local.loop_has_been_setup = True + return loop diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/impl.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/impl.py index 0deebfd8d..bff835c13 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/impl.py +++ b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/impl.py @@ -23,11 +23,6 @@ # so fallback to non pty implementation _execute_process_pty = None -try: - _basestring = basestring # Python 2 -except NameError: - _basestring = str # Python 3 - def execute_process(cmd, cwd=None, env=None, shell=False, emulate_tty=False): """Executes a command with arguments and returns output line by line. @@ -122,7 +117,7 @@ def execute_process(cmd, cwd=None, env=None, shell=False, emulate_tty=False): If you want to ensure there is no color in the output from an executed process, then use this function: - :py:func:`osrf_pycommon.terminal_color.remove_ansi_escape_senquences` + :py:func:`osrf_pycommon.terminal_color.remove_ansi_escape_sequences` Exceptions can be raised by functions called by the implementation, for example, :py:class:`subprocess.Popen` can raise an :py:exc:`OSError` @@ -226,8 +221,8 @@ def _which_backport(cmd, mode=os.F_OK | os.X_OK, path=None): # Additionally check that `file` is not a directory, as on Windows # directories pass the os.access check. def _access_check(fn, mode): - return (os.path.exists(fn) and os.access(fn, mode) and - not os.path.isdir(fn)) + return (os.path.exists(fn) and os.access(fn, mode) and not + os.path.isdir(fn)) # If we're given a path with a directory part, look it up directly rather # than referring to PATH directories. This includes checking relative diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/__init__.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/__init__.py index c6d9c248e..38ec18573 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/__init__.py +++ b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/__init__.py @@ -147,6 +147,7 @@ """ from .ansi_re import remove_ansi_escape_senquences +from .ansi_re import remove_ansi_escape_sequences from .ansi_re import split_by_ansi_escape_sequence from .impl import ansi @@ -168,6 +169,7 @@ 'print_ansi_color_win32', 'print_color', 'remove_ansi_escape_senquences', + 'remove_ansi_escape_sequences', 'sanitize', 'split_by_ansi_escape_sequence', 'test_colors', diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/ansi_re.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/ansi_re.py index 030b10c2d..fc14dcc94 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/ansi_re.py +++ b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/ansi_re.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Provides regular expresion functions for matching ansi escape sequences.""" +"""Provides regular expression functions for matching ansi escape sequences.""" import re @@ -38,9 +38,13 @@ def split_by_ansi_escape_sequence(string, include_delimiters=False): return _ansi_re.split(string) -def remove_ansi_escape_senquences(string): +def remove_ansi_escape_sequences(string): """ Removes any ansi escape sequences found in the given string and returns it. """ global _ansi_re return _ansi_re.sub('', string) + + +# Backwards compatibility +remove_ansi_escape_senquences = remove_ansi_escape_sequences diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/impl.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/impl.py index 209d64ae3..4310ee128 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/impl.py +++ b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/impl.py @@ -293,7 +293,7 @@ def sanitize(msg): as a colorization annotation and it will fail to substitute with a :py:exc:`KeyError`: ``org``. - In order to prevent this, you can first "sanatize" the string, add color + In order to prevent this, you can first "sanitize" the string, add color annotations, and then pass the whole string to :py:func:`format_color`. If you give this function the string ``'Email: {user}@{org}'``, then it diff --git a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/windows.py b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/windows.py index f0f612060..21f5e8fe7 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/windows.py +++ b/ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/terminal_color/windows.py @@ -224,7 +224,7 @@ class CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): def __str__(self): return ( - '({0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0})' + '({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10})' .format( self.dwSize.Y, self.dwSize.X, self.dwCursorPosition.Y, self.dwCursorPosition.X, diff --git a/ros2_batch_job/vendor/osrf_pycommon/package.xml b/ros2_batch_job/vendor/osrf_pycommon/package.xml index a13a99b81..c35f10a22 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/package.xml +++ b/ros2_batch_job/vendor/osrf_pycommon/package.xml @@ -1,12 +1,20 @@ - - + + osrf_pycommon - 0.1.2 + 2.1.4 Commonly needed Python modules, used by Python software developed at OSRF. - William Woodall + + William Woodall + Apache License 2.0 + William Woodall + + python3-importlib-metadata + ament_python diff --git a/ros2_batch_job/vendor/osrf_pycommon/resource/osrf_pycommon b/ros2_batch_job/vendor/osrf_pycommon/resource/osrf_pycommon new file mode 100644 index 000000000..e69de29bb diff --git a/ros2_batch_job/vendor/osrf_pycommon/setup.py b/ros2_batch_job/vendor/osrf_pycommon/setup.py index 63cfd1e9d..155dbc0cb 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/setup.py +++ b/ros2_batch_job/vendor/osrf_pycommon/setup.py @@ -1,32 +1,38 @@ -import sys - from setuptools import find_packages from setuptools import setup install_requires = [ - 'setuptools', + 'importlib-metadata;python_version<"3.8"', ] -if sys.version_info < (3, 4): - install_requires.append('trollius') package_excludes = ['tests*', 'docs*'] -if sys.version_info < (3, ): - # On non-Python3 installs, avoid installing the asyncio files - # which contain Python3 specific syntax. - package_excludes.append( - 'osrf_pycommon.process_utils.async_execute_process_asyncio' - ) packages = find_packages(exclude=package_excludes) +package_name = 'osrf_pycommon' + setup( - name='osrf_pycommon', - version='0.1.2', + name=package_name, + version='2.1.4', packages=packages, + data_files=[ + ('share/' + package_name, ['package.xml']), + ('share/ament_index/resource_index/packages', + ['resource/' + package_name]), + ], install_requires=install_requires, + extras_require={ + 'test': [ + 'flake8', + 'flake8_import_order', + 'pytest', + ], + }, + python_requires='>=3.5', + zip_safe=True, author='William Woodall', author_email='william@osrfoundation.org', maintainer='William Woodall', - maintainer_email='william@osrfoundation.org', + maintainer_email='william@openrobotics.org', url='http://osrf-pycommon.readthedocs.org/', keywords=['osrf', 'utilities'], classifiers=[ diff --git a/ros2_batch_job/vendor/osrf_pycommon/stdeb.cfg b/ros2_batch_job/vendor/osrf_pycommon/stdeb.cfg index bb63612da..e1a8554c9 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/stdeb.cfg +++ b/ros2_batch_job/vendor/osrf_pycommon/stdeb.cfg @@ -1,5 +1,6 @@ [DEFAULT] -Depends: python-setuptools, python-trollius -Depends3: python3-setuptools, python3-trollius -Suite: trusty vivid wily xenial jessie -X-Python3-Version: >= 3.2 +Depends3: python3-setuptools, python3-importlib-metadata +Conflicts3: python-osrf-pycommon +Suite3: focal jammy bullseye bookworm +X-Python3-Version: >= 3.8 +No-Python2: diff --git a/ros2_batch_job/vendor/osrf_pycommon/tests/test_code_format.py b/ros2_batch_job/vendor/osrf_pycommon/tests/test_code_format.py index 782a76b1b..2a2e25bbe 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/tests/test_code_format.py +++ b/ros2_batch_job/vendor/osrf_pycommon/tests/test_code_format.py @@ -14,11 +14,10 @@ def test_flake8(): cmd.extend(['--import-order-style=google']) except ImportError: pass + # ignore error codes from plugins this package doesn't comply with + cmd.extend(['--ignore=C,D,Q,I']) # work around for https://gitlab.com/pycqa/flake8/issues/179 cmd.extend(['--jobs', '1']) - if sys.version_info < (3, 4): - # Unless Python3, skip files with new syntax, like `yield from` - cmd.append('--exclude={0}/*async_execute_process_asyncio/impl.py'.format(source_dir)) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout, stderr = p.communicate() print(stdout) diff --git a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_cli_utils/test_verb_pattern.py b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_cli_utils/test_verb_pattern.py index 4d1d607f6..fd443da80 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_cli_utils/test_verb_pattern.py +++ b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_cli_utils/test_verb_pattern.py @@ -1,3 +1,4 @@ +import sys import unittest from osrf_pycommon.cli_utils import verb_pattern @@ -66,8 +67,16 @@ def fake_prepare_arguments(self, parser, args, extra): return parser f = Foo() - with self.assertRaisesRegexp(ValueError, 'one or two parameters'): - r = cpa(f.fake_prepare_arguments, None) + + # Remove the following if condition and keep else condition once + # Xenial is dropped + if sys.version_info[0] < 3: + with self.assertRaisesRegexp(ValueError, 'one or two parameters'): + r = cpa(f.fake_prepare_arguments, None) + + else: + with self.assertRaisesRegex(ValueError, 'one or two parameters'): + r = cpa(f.fake_prepare_arguments, None) # Try with less than needed called = False @@ -81,8 +90,16 @@ def fake_prepare_arguments(self): return 'Should not get here' f = Foo() - with self.assertRaisesRegexp(ValueError, 'one or two parameters'): - r = cpa(f.fake_prepare_arguments, None) + + # Remove the following if condition and keep else condition once + # Xenial is dropped + if sys.version_info[0] < 3: + with self.assertRaisesRegexp(ValueError, 'one or two parameters'): + r = cpa(f.fake_prepare_arguments, None) + + else: + with self.assertRaisesRegex(ValueError, 'one or two parameters'): + r = cpa(f.fake_prepare_arguments, None) # Try with additional optional argument called = False diff --git a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/impl_aep_asyncio.py b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/impl_aep_asyncio.py index 316a3fb47..a47830414 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/impl_aep_asyncio.py +++ b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/impl_aep_asyncio.py @@ -1,4 +1,3 @@ -from osrf_pycommon.process_utils import asyncio from osrf_pycommon.process_utils.async_execute_process import async_execute_process from osrf_pycommon.process_utils import get_loop @@ -7,9 +6,8 @@ loop = get_loop() -@asyncio.coroutine -def run(cmd, **kwargs): - transport, protocol = yield from async_execute_process( +async def run(cmd, **kwargs): + transport, protocol = await async_execute_process( create_protocol(), cmd, **kwargs) - retcode = yield from protocol.complete + retcode = await protocol.complete return protocol.stdout_buffer, protocol.stderr_buffer, retcode diff --git a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/impl_aep_protocol.py b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/impl_aep_protocol.py index aa2a078bd..cf11eafcf 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/impl_aep_protocol.py +++ b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/impl_aep_protocol.py @@ -3,10 +3,10 @@ def create_protocol(): class CustomProtocol(AsyncSubprocessProtocol): - def __init__(self, *args, **kwargs): + def __init__(self, **kwargs): self.stdout_buffer = b"" self.stderr_buffer = b"" - AsyncSubprocessProtocol.__init__(self, *args, **kwargs) + AsyncSubprocessProtocol.__init__(self, **kwargs) def on_stdout_received(self, data): self.stdout_buffer += data diff --git a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/impl_aep_trollius.py b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/impl_aep_trollius.py deleted file mode 100644 index 7b9cf0ee0..000000000 --- a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/impl_aep_trollius.py +++ /dev/null @@ -1,25 +0,0 @@ -from osrf_pycommon.process_utils import asyncio -from osrf_pycommon.process_utils.async_execute_process import async_execute_process -from osrf_pycommon.process_utils import get_loop - -# allow module to be importable for --cover-inclusive -try: - from osrf_pycommon.process_utils.async_execute_process_trollius import From -except ImportError: - TROLLIUS_FOUND = False -else: - TROLLIUS_FOUND = True - - from osrf_pycommon.process_utils.async_execute_process_trollius import Return - - from .impl_aep_protocol import create_protocol - - loop = get_loop() - - @asyncio.coroutine - def run(cmd, **kwargs): - transport, protocol = yield From(async_execute_process( - create_protocol(), cmd, **kwargs)) - retcode = yield asyncio.From(protocol.complete) - raise Return(protocol.stdout_buffer, protocol.stderr_buffer, - retcode) diff --git a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/test_async_execute_process.py b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/test_async_execute_process.py index 4c920e0b8..736f014d8 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/test_async_execute_process.py +++ b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_process_utils/test_async_execute_process.py @@ -3,14 +3,8 @@ import sys import unittest -if sys.version_info >= (3, 4): - from .impl_aep_asyncio import run - from .impl_aep_asyncio import loop - print("Using asyncio") -else: - from .impl_aep_trollius import run - from .impl_aep_trollius import loop - print("Using Trollius") +from .impl_aep_asyncio import run +from .impl_aep_asyncio import loop this_dir = os.path.dirname(os.path.abspath(__file__)) diff --git a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_terminal_color/test_ansi_re.py b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_terminal_color/test_ansi_re.py index 4e722cc9b..9588ba9e7 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_terminal_color/test_ansi_re.py +++ b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_terminal_color/test_ansi_re.py @@ -16,12 +16,12 @@ def test_split_by_ansi_escape_sequence(self): expected = ["", "red ", "bold red ", "normal ", "red bg"] self.assertEqual(expected, split_ansi(self.test_str, False)) - def test_remove_ansi_escape_senquences(self): - remove_ansi = ansi_re.remove_ansi_escape_senquences + def test_remove_ansi_escape_sequences(self): + remove_ansi = ansi_re.remove_ansi_escape_sequences expected = "red bold red normal red bg" self.assertEqual(expected, remove_ansi(self.test_str)) - def test_remove_ansi_escape_senquences_false_positives(self): - remove_ansi = ansi_re.remove_ansi_escape_senquences + def test_remove_ansi_escape_sequences_false_positives(self): + remove_ansi = ansi_re.remove_ansi_escape_sequences false_positive = "Should not match: \1xb[1234m \033[m \1xb[3Om" self.assertEqual(false_positive, remove_ansi(false_positive)) diff --git a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_terminal_utils.py b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_terminal_utils.py index 6590281cd..49abfba0c 100644 --- a/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_terminal_utils.py +++ b/ros2_batch_job/vendor/osrf_pycommon/tests/unit/test_terminal_utils.py @@ -1,5 +1,5 @@ -import mock import unittest +from unittest import mock from osrf_pycommon.terminal_utils import is_tty