diff --git a/README.md b/README.md index 175b998..48bbdf0 100644 --- a/README.md +++ b/README.md @@ -28,21 +28,22 @@ def fdm_callback(fdm_data, event_pipe): return fdm_data # return the whole structure """ -Start FlightGear with `--native-fdm=socket,out,30,,5501,udp --native-fdm=socket,in,30,,5502,udp` +Start FlightGear with `--native-fdm=socket,out,30,localhost,5501,udp --native-fdm=socket,in,30,localhost,5502,udp` (you probably also want `--fdm=null` and `--max-fps=30` to stop the simulation fighting with these external commands) """ -fdm_conn = FDMConnection(fdm_version=24) # May need to change version from 24 -fdm_event_pipe = fdm_conn.connect_rx('localhost', 5501, fdm_callback) -fdm_conn.connect_tx('localhost', 5502) -fdm_conn.start() # Start the FDM RX/TX loop - -phi_rad_parent = 0.0 -while True: - phi_rad_parent += 0.1 - # could also do `fdm_conn.event_pipe.parent_send` so you just need to pass around `fdm_conn` - fdm_event_pipe.parent_send((phi_rad_parent,)) # send tuple - time.sleep(0.5) +if __name__ == '__main__': # NOTE: This is REQUIRED on Windows! + fdm_conn = FDMConnection(fdm_version=24) # May need to change version from 24 + fdm_event_pipe = fdm_conn.connect_rx('localhost', 5501, fdm_callback) + fdm_conn.connect_tx('localhost', 5502) + fdm_conn.start() # Start the FDM RX/TX loop + + phi_rad_parent = 0.0 + while True: + phi_rad_parent += 0.1 + # could also do `fdm_conn.event_pipe.parent_send` so you just need to pass around `fdm_conn` + fdm_event_pipe.parent_send((phi_rad_parent,)) # send tuple + time.sleep(0.5) ``` Supported interfaces: diff --git a/docs/source/conf.py b/docs/source/conf.py index fe6eda9..cf371a2 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -33,7 +33,7 @@ from typing import Any, Tuple, Optional, Callable from pprint import pformat from construct import (Struct, FormatField, Subconstruct, Array, Enum, Const, Padded, Pass, Transformed, Flag, Renamed, - BitsInteger) + BitsInteger, Bytes) from importlib import import_module from docutils import nodes from docutils.parsers.rst import Directive @@ -116,7 +116,15 @@ def represent_object(o: Any, ident_level: int = 0, context_str: Optional[str] = else: pp_str = f'{type(o).__name__}{special_str}' elif isinstance(o, BitsInteger): - pp_str = 'Bits' + if o.length == 1: + pp_str = 'Bit' + else: + pp_str = f'{o.length} Bits' + elif isinstance(o, Bytes): + if o.length == 1: + pp_str = 'Byte' + else: + pp_str = f'{o.length} Bytes' elif isinstance(o, Pass.__class__): pp_str = '' # Pass is a do-nothing. No information to represent elif isinstance(o, Flag.__class__): diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst index 2ff5c8f..2d2afc8 100644 --- a/docs/source/quickstart.rst +++ b/docs/source/quickstart.rst @@ -7,7 +7,7 @@ Quick-Start #. If you're using the FDM interface: - * ``--fdm=null --max-fps=30 --native-fdm=socket,out,30,,5501,udp --native-fdm=socket,in,30,,5502,udp`` + * ``--fdm=null --max-fps=30 --native-fdm=socket,out,30,localhost,5501,udp --native-fdm=socket,in,30,localhost,5502,udp`` * the ``30`` in the arguments must match, so that the IO and the framerate are the same diff --git a/examples/simple_ctrls.py b/examples/simple_ctrls.py index fb1fa56..6afea6f 100755 --- a/examples/simple_ctrls.py +++ b/examples/simple_ctrls.py @@ -27,17 +27,18 @@ def ctrls_callback(ctrls_data, event_pipe): return ctrls_data # return the whole structure """ -Start FlightGear with `--native-ctrls=socket,out,30,,5503,udp --native-ctrls=socket,in,30,,5504,udp` +Start FlightGear with `--native-ctrls=socket,out,30,localhost,5503,udp --native-ctrls=socket,in,30,localhost,5504,udp` """ -ctrls_conn = CtrlsConnection(ctrls_version=27) -ctrls_event_pipe = ctrls_conn.connect_rx('localhost', 5503, ctrls_callback) -ctrls_conn.connect_tx('localhost', 5504) -ctrls_conn.start() # Start the Ctrls RX/TX loop +if __name__ == '__main__': # NOTE: This is REQUIRED on Windows! + ctrls_conn = CtrlsConnection(ctrls_version=27) + ctrls_event_pipe = ctrls_conn.connect_rx('localhost', 5503, ctrls_callback) + ctrls_conn.connect_tx('localhost', 5504) + ctrls_conn.start() # Start the Ctrls RX/TX loop -gear_down_parent = True -time.sleep(2) -while True: - # could also do `ctrls_conn.event_pipe.parent_send` so you just need to pass around `ctrls_conn` - ctrls_event_pipe.parent_send((gear_down_parent,)) # send tuple - gear_down_parent = not gear_down_parent # Flip gear state - time.sleep(10) + gear_down_parent = True + time.sleep(2) + while True: + # could also do `ctrls_conn.event_pipe.parent_send` so you just need to pass around `ctrls_conn` + ctrls_event_pipe.parent_send((gear_down_parent,)) # send tuple + gear_down_parent = not gear_down_parent # Flip gear state + time.sleep(10) diff --git a/examples/simple_fdm.py b/examples/simple_fdm.py index bd4a695..4cdcd6f 100755 --- a/examples/simple_fdm.py +++ b/examples/simple_fdm.py @@ -14,18 +14,19 @@ def fdm_callback(fdm_data, event_pipe): return fdm_data # return the whole structure """ -Start FlightGear with `--native-fdm=socket,out,30,,5501,udp --native-fdm=socket,in,30,,5502,udp` +Start FlightGear with `--native-fdm=socket,out,30,localhost,5501,udp --native-fdm=socket,in,30,localhost,5502,udp` (you probably also want `--fdm=null` and `--max-fps=30` to stop the simulation fighting with these external commands) """ -fdm_conn = FDMConnection(fdm_version=24) # May need to change version from 24 -fdm_event_pipe = fdm_conn.connect_rx('localhost', 5501, fdm_callback) -fdm_conn.connect_tx('localhost', 5502) -fdm_conn.start() # Start the FDM RX/TX loop +if __name__ == '__main__': # NOTE: This is REQUIRED on Windows! + fdm_conn = FDMConnection(fdm_version=24) # May need to change version from 24 + fdm_event_pipe = fdm_conn.connect_rx('localhost', 5501, fdm_callback) + fdm_conn.connect_tx('localhost', 5502) + fdm_conn.start() # Start the FDM RX/TX loop -phi_rad_parent = 0.0 -while True: - phi_rad_parent += 0.1 - # could also do `fdm_conn.event_pipe.parent_send` so you just need to pass around `fdm_conn` - fdm_event_pipe.parent_send((phi_rad_parent,)) # send tuple - time.sleep(0.5) + phi_rad_parent = 0.0 + while True: + phi_rad_parent += 0.1 + # could also do `fdm_conn.event_pipe.parent_send` so you just need to pass around `fdm_conn` + fdm_event_pipe.parent_send((phi_rad_parent,)) # send tuple + time.sleep(0.5) diff --git a/flightgear_python/ctrls_v27.py b/flightgear_python/ctrls_v27.py index aa5423c..88c531f 100644 --- a/flightgear_python/ctrls_v27.py +++ b/flightgear_python/ctrls_v27.py @@ -4,7 +4,7 @@ See https://github.com/FlightGear/flightgear/blob/619226e9d069d2a3e8ebf8658fb5441ca8a2c233/src/Network/net_ctrls.hxx """ -from construct import Array, Enum, Const, Bytes, Int32ub, Float64b, BitStruct, Flag, BitsInteger +from construct import Array, Enum, Const, Bytes, Int32ub, Float64b, BitStruct, Bit, BitsInteger RESERVED_SPACE = 25 #: Constant value from define @@ -81,9 +81,9 @@ 'speedup': Int32ub, # integer speedup multiplier 'freeze': BitStruct( # Default is big-endian other=BitsInteger((Int32ub.sizeof() * 8) - 3), # Rest of uint32 minus the 3 flags - fuel=Flag, - position=Flag, - master=Flag, + fuel=Bit, + position=Bit, + master=Bit, ), '_reserved': Bytes(Int32ub.length * RESERVED_SPACE), } diff --git a/flightgear_python/fg_if.py b/flightgear_python/fg_if.py index 8d6e8a4..be65ba6 100755 --- a/flightgear_python/fg_if.py +++ b/flightgear_python/fg_if.py @@ -5,7 +5,7 @@ import socket import sys import re -import multiprocessing as mp +import multiprocess as mp from typing import Callable, Optional, Tuple, Any, Dict, Union, ByteString from construct import ConstError, Struct, Container @@ -48,7 +48,7 @@ def connect_rx(self, fg_host: str, fg_port: int, rx_cb: rx_callback_type) -> Eve :param fg_host: IP address of FG (usually localhost) :param fg_port: Port of the output socket (i.e. the ``5501`` from\ - ``--native-fdm=socket,out,30,,5501,udp``) + ``--native-fdm=socket,out,30,localhost,5501,udp``) :param rx_cb: Callback function, called whenever we receive data from FG.\ Function signature should follow :attr:`rx_callback_type` :return: ``EventPipe`` so that data can be passed from the parent process\ @@ -72,7 +72,7 @@ def connect_tx(self, fg_host: str, fg_port: int): :param fg_host: IP address of FG (usually localhost) :param fg_port: Port of the input socket (i.e. the ``5502`` from\ - ``--native-fdm=socket,in,,,5502,udp``) + ``--native-fdm=socket,in,30,localhost,5502,udp``) """ self.fg_tx_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.fg_tx_addr = (fg_host, fg_port) diff --git a/flightgear_python/general_util.py b/flightgear_python/general_util.py index 464f7b9..ae4a979 100644 --- a/flightgear_python/general_util.py +++ b/flightgear_python/general_util.py @@ -1,7 +1,7 @@ """ non-FlightGear-specific utility functionality """ -import multiprocessing as mp +import multiprocess as mp from typing import Any, Union, ByteString diff --git a/poetry.lock b/poetry.lock index be43325..b60e653 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,10 +1,10 @@ [[package]] name = "alabaster" -version = "0.7.12" +version = "0.7.13" description = "A configurable sidebar-enabled Sphinx theme" category = "dev" optional = false -python-versions = "*" +python-versions = ">=3.6" [[package]] name = "atomicwrites" @@ -16,17 +16,19 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "attrs" -version = "22.1.0" +version = "22.2.0" description = "Classes Without Boilerplate" category = "dev" optional = false -python-versions = ">=3.5" +python-versions = ">=3.6" [package.extras] -dev = ["cloudpickle", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "mypy (>=0.900,!=0.940)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "sphinx", "sphinx-notfound-page", "zope.interface"] -docs = ["furo", "sphinx", "sphinx-notfound-page", "zope.interface"] -tests = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "zope.interface"] -tests_no_zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins"] +cov = ["attrs", "coverage-enable-subprocess", "coverage[toml] (>=5.3)"] +dev = ["attrs"] +docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope.interface"] +tests = ["attrs", "zope.interface"] +tests-no-zope = ["cloudpickle", "hypothesis", "mypy (>=0.971,<0.990)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist"] +tests_no_zope = ["cloudpickle", "hypothesis", "mypy (>=0.971,<0.990)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist"] [[package]] name = "babel" @@ -41,7 +43,7 @@ pytz = ">=2015.7" [[package]] name = "certifi" -version = "2022.9.24" +version = "2022.12.7" description = "Python package for providing Mozilla's CA Bundle." category = "dev" optional = false @@ -91,9 +93,20 @@ tomli = {version = "*", optional = true, markers = "extra == \"toml\""} [package.extras] toml = ["tomli"] +[[package]] +name = "dill" +version = "0.3.4" +description = "serialize all of python" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*" + +[package.extras] +graph = ["objgraph (>=1.7.2)"] + [[package]] name = "docutils" -version = "0.17.1" +version = "0.16" description = "Docutils -- Python Documentation Utilities" category = "dev" optional = false @@ -198,12 +211,23 @@ python-versions = ">=3.6" [[package]] name = "mistune" -version = "2.0.4" +version = "2.0.5" description = "A sane Markdown parser with useful plugins and renderers" category = "dev" optional = false python-versions = "*" +[[package]] +name = "multiprocess" +version = "0.70.12.2" +description = "better multiprocessing and multithreading in python" +category = "main" +optional = false +python-versions = "*" + +[package.dependencies] +dill = ">=0.3.4" + [[package]] name = "numpy" version = "1.19.5" @@ -248,7 +272,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "pygments" -version = "2.13.0" +version = "2.14.0" description = "Pygments is a syntax highlighting package written in Python." category = "dev" optional = false @@ -321,7 +345,7 @@ dev = ["pre-commit", "pytest-asyncio", "tox"] [[package]] name = "pytz" -version = "2022.6" +version = "2022.7.1" description = "World timezone definitions, modern and historical" category = "dev" optional = false @@ -416,18 +440,18 @@ pygments = ">=2.8" [[package]] name = "sphinx-rtd-theme" -version = "1.1.1" +version = "0.5.2" description = "Read the Docs theme for Sphinx" category = "dev" optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" +python-versions = "*" [package.dependencies] -docutils = "<0.18" -sphinx = ">=1.6,<6" +docutils = "<0.17" +sphinx = "*" [package.extras] -dev = ["bump2version", "sphinxcontrib-httpdomain", "transifex-client", "wheel"] +dev = ["bump2version", "sphinxcontrib-httpdomain", "transifex-client"] [[package]] name = "sphinxcontrib-applehelp" @@ -518,7 +542,7 @@ python-versions = ">=3.6" [[package]] name = "urllib3" -version = "1.26.13" +version = "1.26.15" description = "HTTP library with thread-safe connection pooling, file post, and more." category = "dev" optional = false @@ -544,27 +568,27 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=4.6)", "pytest-black ( [metadata] lock-version = "1.1" python-versions = "^3.6" -content-hash = "1e1bb2d639e0b8eee780417cde54ee144f5eccb747e53d0cc03ee197c3193af6" +content-hash = "64774d280c8ce4bd69235be1b11b95da5928a9f6738a8015963d686a1f6f5829" [metadata.files] alabaster = [ - {file = "alabaster-0.7.12-py2.py3-none-any.whl", hash = "sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359"}, - {file = "alabaster-0.7.12.tar.gz", hash = "sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02"}, + {file = "alabaster-0.7.13-py3-none-any.whl", hash = "sha256:1ee19aca801bbabb5ba3f5f258e4422dfa86f82f3e9cefb0859b283cdd7f62a3"}, + {file = "alabaster-0.7.13.tar.gz", hash = "sha256:a27a4a084d5e690e16e01e03ad2b2e552c61a65469419b907243193de1a84ae2"}, ] atomicwrites = [ {file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"}, ] attrs = [ - {file = "attrs-22.1.0-py2.py3-none-any.whl", hash = "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c"}, - {file = "attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"}, + {file = "attrs-22.2.0-py3-none-any.whl", hash = "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836"}, + {file = "attrs-22.2.0.tar.gz", hash = "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99"}, ] babel = [ {file = "Babel-2.11.0-py3-none-any.whl", hash = "sha256:1ad3eca1c885218f6dce2ab67291178944f810a10a9b5f3cb8382a5a232b64fe"}, {file = "Babel-2.11.0.tar.gz", hash = "sha256:5ef4b3226b0180dedded4229651c8b0e1a3a6a2837d45a073272f313e4cf97f6"}, ] certifi = [ - {file = "certifi-2022.9.24-py3-none-any.whl", hash = "sha256:90c1a32f1d68f940488354e36370f6cca89f0f106db09518524c88d6ed83f382"}, - {file = "certifi-2022.9.24.tar.gz", hash = "sha256:0d9c601124e5a6ba9712dbc60d9c53c21e34f5f641fe83002317394311bdce14"}, + {file = "certifi-2022.12.7-py3-none-any.whl", hash = "sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"}, + {file = "certifi-2022.12.7.tar.gz", hash = "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3"}, ] charset-normalizer = [ {file = "charset-normalizer-2.0.12.tar.gz", hash = "sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597"}, @@ -626,9 +650,13 @@ coverage = [ {file = "coverage-6.2-pp36.pp37.pp38-none-any.whl", hash = "sha256:5829192582c0ec8ca4a2532407bc14c2f338d9878a10442f5d03804a95fac9de"}, {file = "coverage-6.2.tar.gz", hash = "sha256:e2cad8093172b7d1595b4ad66f24270808658e11acf43a8f95b41276162eb5b8"}, ] +dill = [ + {file = "dill-0.3.4-py2.py3-none-any.whl", hash = "sha256:7e40e4a70304fd9ceab3535d36e58791d9c4a776b38ec7f7ec9afc8d3dca4d4f"}, + {file = "dill-0.3.4.zip", hash = "sha256:9f9734205146b2b353ab3fec9af0070237b6ddae78452af83d2fca84d739e675"}, +] docutils = [ - {file = "docutils-0.17.1-py2.py3-none-any.whl", hash = "sha256:cf316c8370a737a022b72b56874f6602acf974a37a9fba42ec2876387549fc61"}, - {file = "docutils-0.17.1.tar.gz", hash = "sha256:686577d2e4c32380bb50cbb22f575ed742d58168cee37e99117a854bcd88f125"}, + {file = "docutils-0.16-py2.py3-none-any.whl", hash = "sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af"}, + {file = "docutils-0.16.tar.gz", hash = "sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc"}, ] gitdb = [ {file = "gitdb-4.0.9-py3-none-any.whl", hash = "sha256:8033ad4e853066ba6ca92050b9df2f89301b8fc8bf7e9324d412a63f8bf1a8fd"}, @@ -750,8 +778,23 @@ markupsafe = [ {file = "MarkupSafe-2.0.1.tar.gz", hash = "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a"}, ] mistune = [ - {file = "mistune-2.0.4-py2.py3-none-any.whl", hash = "sha256:182cc5ee6f8ed1b807de6b7bb50155df7b66495412836b9a74c8fbdfc75fe36d"}, - {file = "mistune-2.0.4.tar.gz", hash = "sha256:9ee0a66053e2267aba772c71e06891fa8f1af6d4b01d5e84e267b4570d4d9808"}, + {file = "mistune-2.0.5-py2.py3-none-any.whl", hash = "sha256:bad7f5d431886fcbaf5f758118ecff70d31f75231b34024a1341120340a65ce8"}, + {file = "mistune-2.0.5.tar.gz", hash = "sha256:0246113cb2492db875c6be56974a7c893333bf26cd92891c85f63151cee09d34"}, +] +multiprocess = [ + {file = "multiprocess-0.70.12.2-cp27-cp27m-macosx_10_12_x86_64.whl", hash = "sha256:35d41e410ca2a32977a483ae1f40f86b193b45cecf85567c2fae402fb8bf172e"}, + {file = "multiprocess-0.70.12.2-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:9a02237eae21975155c816883479f72e239d16823a6bc063173d59acec9bcf41"}, + {file = "multiprocess-0.70.12.2-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:f12a939cd2f01d0a900e7ef2aaee3c351a49fd2297d7f760b537af22727561b8"}, + {file = "multiprocess-0.70.12.2-cp27-cp27m-win32.whl", hash = "sha256:be3ad3eaf204abc646d85e70e41244f66d88200628a0ab867c8fc206b97cedbf"}, + {file = "multiprocess-0.70.12.2-cp27-cp27m-win_amd64.whl", hash = "sha256:c85ffc38c50c5a4f32f3f3c1a284725b7b5040188f254eba6e572c53d3da525b"}, + {file = "multiprocess-0.70.12.2-pp27-none-any.whl", hash = "sha256:a9f58945edb234591684c0a181b744a3231643814ef3a8f47cea9a2073b4b2bb"}, + {file = "multiprocess-0.70.12.2-pp36-none-any.whl", hash = "sha256:0e0a5ae4bd84e4c22baddf824d3b8168214f8c1cce51e2cb080421cb1f7b04d1"}, + {file = "multiprocess-0.70.12.2-pp37-none-any.whl", hash = "sha256:916a314a1e0f3454033d59672ba6181fa45948ab1091d68cdd479258576e7b27"}, + {file = "multiprocess-0.70.12.2-py36-none-any.whl", hash = "sha256:b3f866f7d9c7acc1a9cb1b6063a29f5cb140ff545b35b71fd4bfdac6f19d75fa"}, + {file = "multiprocess-0.70.12.2-py37-none-any.whl", hash = "sha256:6aa67e805e50b6e9dfc56dd0f0c85ac3409e6791d4ec5405c5f9bc0a47d745a4"}, + {file = "multiprocess-0.70.12.2-py38-none-any.whl", hash = "sha256:85941e650c277af44fc82e3e97faacb920e5ce3615238b540cbad4012d6f60e9"}, + {file = "multiprocess-0.70.12.2-py39-none-any.whl", hash = "sha256:6f812a1d3f198b7cacd63983f60e2dc1338bd4450893f90c435067b5a3127e6f"}, + {file = "multiprocess-0.70.12.2.zip", hash = "sha256:206bb9b97b73f87fec1ed15a19f8762950256aa84225450abc7150d02855a083"}, ] numpy = [ {file = "numpy-1.19.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:cc6bd4fd593cb261332568485e20a0712883cf631f6f5e8e86a52caa8b2b50ff"}, @@ -802,8 +845,8 @@ py = [ {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] pygments = [ - {file = "Pygments-2.13.0-py3-none-any.whl", hash = "sha256:f643f331ab57ba3c9d89212ee4a2dabc6e94f117cf4eefde99a0574720d14c42"}, - {file = "Pygments-2.13.0.tar.gz", hash = "sha256:56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1"}, + {file = "Pygments-2.14.0-py3-none-any.whl", hash = "sha256:fa7bd7bd2771287c0de303af8bfdfc731f51bd2c6a47ab69d117138893b82717"}, + {file = "Pygments-2.14.0.tar.gz", hash = "sha256:b3ed06a9e8ac9a9aae5a6f5dbe78a8a58655d17b43b93c078f094ddc476ae297"}, ] pyparsing = [ {file = "pyparsing-3.0.7-py3-none-any.whl", hash = "sha256:a6c06a88f252e6c322f65faf8f418b16213b51bdfaece0524c1c1bc30c63c484"}, @@ -822,8 +865,8 @@ pytest-mock = [ {file = "pytest_mock-3.6.1-py3-none-any.whl", hash = "sha256:30c2f2cc9759e76eee674b81ea28c9f0b94f8f0445a1b87762cadf774f0df7e3"}, ] pytz = [ - {file = "pytz-2022.6-py2.py3-none-any.whl", hash = "sha256:222439474e9c98fced559f1709d89e6c9cbf8d79c794ff3eb9f8800064291427"}, - {file = "pytz-2022.6.tar.gz", hash = "sha256:e89512406b793ca39f5971bc999cc538ce125c0e51c27941bef4568b460095e2"}, + {file = "pytz-2022.7.1-py2.py3-none-any.whl", hash = "sha256:78f4f37d8198e0627c5f1143240bb0206b8691d8d7ac6d78fee88b78733f8c4a"}, + {file = "pytz-2022.7.1.tar.gz", hash = "sha256:01a0681c4b9684a28304615eba55d1ab31ae00bf68ec157ec3708a8182dbbcd0"}, ] requests = [ {file = "requests-2.27.1-py2.py3-none-any.whl", hash = "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"}, @@ -849,8 +892,8 @@ sphinx-mdinclude = [ {file = "sphinx_mdinclude-0.5.3.tar.gz", hash = "sha256:2998e3d18b3022c9983d1b72191fe37e25ffccd54165cbe3acb22cceedd91af4"}, ] sphinx-rtd-theme = [ - {file = "sphinx_rtd_theme-1.1.1-py2.py3-none-any.whl", hash = "sha256:31faa07d3e97c8955637fc3f1423a5ab2c44b74b8cc558a51498c202ce5cbda7"}, - {file = "sphinx_rtd_theme-1.1.1.tar.gz", hash = "sha256:6146c845f1e1947b3c3dd4432c28998a1693ccc742b4f9ad7c63129f0757c103"}, + {file = "sphinx_rtd_theme-0.5.2-py2.py3-none-any.whl", hash = "sha256:4a05bdbe8b1446d77a01e20a23ebc6777c74f43237035e76be89699308987d6f"}, + {file = "sphinx_rtd_theme-0.5.2.tar.gz", hash = "sha256:32bd3b5d13dc8186d7a42fc816a23d32e83a4827d7d9882948e7b837c232da5a"}, ] sphinxcontrib-applehelp = [ {file = "sphinxcontrib-applehelp-1.0.2.tar.gz", hash = "sha256:a072735ec80e7675e3f432fcae8610ecf509c5f1869d17e2eecff44389cdbc58"}, @@ -885,8 +928,8 @@ typing-extensions = [ {file = "typing_extensions-4.1.1.tar.gz", hash = "sha256:1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42"}, ] urllib3 = [ - {file = "urllib3-1.26.13-py2.py3-none-any.whl", hash = "sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc"}, - {file = "urllib3-1.26.13.tar.gz", hash = "sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8"}, + {file = "urllib3-1.26.15-py2.py3-none-any.whl", hash = "sha256:aa751d169e23c7479ce47a0cb0da579e3ede798f994f5816a74e4f4500dcea42"}, + {file = "urllib3-1.26.15.tar.gz", hash = "sha256:8a388717b9476f934a21484e8c8e61875ab60644d29b9b39e11e4b9dc1c6b305"}, ] zipp = [ {file = "zipp-3.6.0-py3-none-any.whl", hash = "sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc"}, diff --git a/pyproject.toml b/pyproject.toml index 63d17cf..856000c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,11 +13,13 @@ license = "MIT" [tool.poetry.dependencies] python = "^3.6" construct = "^2.10" +# Following are pegged at the latest version that supports Python 3.6 +multiprocess = "==0.70.12.2" [tool.poetry.dev-dependencies] sphinx = "^5.1.1" sphinx_mdinclude = "^0.5.2" -sphinx-rtd-theme = "^1.0.0" +sphinx-rtd-theme = "^0.5.2" # Can't `poetry update` with 1.0.0? sh = "^1.14.3" pytest-cov = "^3.0.0" # Following are pegged at the latest version that supports Python 3.6 diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 9127303..923971b 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -10,7 +10,7 @@ fi if [ "$1" = 'clean' ]; then pip3 install -U pip pip3 install -U poetry - poetry update + poetry update -vvv fi poetry build poetry install diff --git a/tests/test_pickling.py b/tests/test_pickling.py new file mode 100644 index 0000000..b884b92 --- /dev/null +++ b/tests/test_pickling.py @@ -0,0 +1,30 @@ +""" +We don't care about pickling per-say, but multiprocess uses the dill library +to spin up new processes. This only seems to be a problem on Windows, but we need +to support the weird way Windows implements fork(). +""" +import dill + +from flightgear_python.fg_if import FDMConnection, CtrlsConnection +from testing_common import supported_fdm_versions, supported_ctrls_versions + +import pytest +from _pytest.outcomes import Failed + + +@pytest.mark.parametrize('fdm_version', supported_fdm_versions) +def test_pickle_fdm(fdm_version): + fdm_c = FDMConnection(fdm_version) + try: + dill.dumps(fdm_c.fg_net_struct) + except dill.PicklingError as e: + raise Failed(f'Failed to pickle FDM fg_net_struct: {e}') from None + + +@pytest.mark.parametrize('ctrls_version', supported_ctrls_versions) +def test_pickle_ctrls(ctrls_version): + ctrls_c = CtrlsConnection(ctrls_version) + try: + dill.dumps(ctrls_c.fg_net_struct) + except dill.PicklingError as e: + raise Failed(f'Failed to pickle Ctrls fg_net_struct: {e}') from None diff --git a/tests/testing_common.py b/tests/testing_common.py index 379064a..eb94c75 100644 --- a/tests/testing_common.py +++ b/tests/testing_common.py @@ -3,6 +3,7 @@ supported_fdm_versions = [24, 25, ] +supported_ctrls_versions = [27, ] project_dir = os.path.abspath(os.path.dirname(__file__))