From 89d389e50427d9749a82ee9cb7d3bd8064beed08 Mon Sep 17 00:00:00 2001 From: semuadmin <28569967+semuadmin@users.noreply.github.com> Date: Fri, 6 Dec 2024 17:46:05 +0000 Subject: [PATCH] fix issue with mandatory args in config files --- .vscode/settings.json | 2 +- RELEASE_NOTES.md | 6 ++++++ pyproject.toml | 2 +- src/pyubxutils/_version.py | 2 +- src/pyubxutils/ubxbase.py | 8 ++++++-- src/pyubxutils/ubxload.py | 12 +++++++++--- src/pyubxutils/ubxsave.py | 6 +++++- src/pyubxutils/ubxsetrate.py | 5 ++++- 8 files changed, 33 insertions(+), 10 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 28dda2d..6a348ed 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,5 @@ "python.defaultInterpreterPath": "python3", "modulename": "${workspaceFolderBasename}", "distname": "${workspaceFolderBasename}", - "moduleversion": "1.0.1" + "moduleversion": "1.0.2" } \ No newline at end of file diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 84428cc..0e42a3c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,11 @@ # pyubxutils Release Notes +### RELEASE 1.0.2 + +FIXES: + +1. Fix typo in ubxbase config. + ### RELEASE 1.0.1 ENHANCEMENTS: diff --git a/pyproject.toml b/pyproject.toml index e43cede..e77018e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "pyubxutils" authors = [{ name = "semuadmin", email = "semuadmin@semuconsulting.com" }] maintainers = [{ name = "semuadmin", email = "semuadmin@semuconsulting.com" }] description = "UBX Protocol Command Line Utilities" -version = "1.0.1" +version = "1.0.2" license = { file = "LICENSE" } readme = "README.md" requires-python = ">=3.9" diff --git a/src/pyubxutils/_version.py b/src/pyubxutils/_version.py index ee3accc..9b3b41d 100644 --- a/src/pyubxutils/_version.py +++ b/src/pyubxutils/_version.py @@ -8,4 +8,4 @@ :license: BSD 3-Clause """ -__version__ = "1.0.1" +__version__ = "1.0.2" diff --git a/src/pyubxutils/ubxbase.py b/src/pyubxutils/ubxbase.py index c895877..0243645 100644 --- a/src/pyubxutils/ubxbase.py +++ b/src/pyubxutils/ubxbase.py @@ -37,6 +37,7 @@ from serial import Serial from pyubxutils._version import __version__ as VERSION +from pyubxutils.exceptions import ParameterError from pyubxutils.globals import EPILOG, VERBOSITY_HIGH from pyubxutils.helpers import h2sphp, ll2sphp, progbar, set_common_args @@ -391,7 +392,7 @@ def fixedpos_in_range(value): ap = ArgumentParser(epilog=EPILOG, formatter_class=ArgumentDefaultsHelpFormatter) ap.add_argument("-V", "--version", action="version", version="%(prog)s " + VERSION) - ap.add_argument("-P", "--port", required=True, help="Serial port") + ap.add_argument("-P", "--port", required=False, help="Serial port") ap.add_argument( "--baudrate", required=False, @@ -464,7 +465,10 @@ def fixedpos_in_range(value): default=WAITTIME, ) - kwargs = set_common_args("ubxload", ap, logdefault=VERBOSITY_HIGH) + kwargs = set_common_args("ubxbase", ap, logdefault=VERBOSITY_HIGH) + + if kwargs.get("port", None) is None: + raise ParameterError("Serial port must be specified") with Serial( kwargs.get("port"), kwargs.pop("baudrate"), timeout=kwargs.pop("timeout") diff --git a/src/pyubxutils/ubxload.py b/src/pyubxutils/ubxload.py index d453e70..67678f4 100644 --- a/src/pyubxutils/ubxload.py +++ b/src/pyubxutils/ubxload.py @@ -21,7 +21,7 @@ # pylint: disable=invalid-name -from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser +from argparse import ArgumentDefaultsHelpFormatter, ArgumentError, ArgumentParser from datetime import datetime, timedelta from logging import getLogger from math import ceil @@ -40,6 +40,7 @@ from serial import Serial from pyubxutils._version import __version__ as VERSION +from pyubxutils.exceptions import ParameterError from pyubxutils.globals import EPILOG, VERBOSITY_HIGH from pyubxutils.helpers import progbar, set_common_args @@ -218,8 +219,8 @@ def main(): ap = ArgumentParser(epilog=EPILOG, formatter_class=ArgumentDefaultsHelpFormatter) ap.add_argument("-V", "--version", action="version", version="%(prog)s " + VERSION) - ap.add_argument("-I", "--infile", required=True, help="Input file") - ap.add_argument("-P", "--port", required=True, help="Serial port") + ap.add_argument("-I", "--infile", required=False, help="Input file") + ap.add_argument("-P", "--port", required=False, help="Serial port") ap.add_argument( "--baudrate", required=False, @@ -245,6 +246,11 @@ def main(): kwargs = set_common_args("ubxload", ap, logdefault=VERBOSITY_HIGH) + if kwargs.get("port", None) is None: + raise ParameterError("Serial port must be specified") + if kwargs.get("infile", None) is None: + raise ParameterError("Input file must be specified") + with Serial( kwargs.pop("port"), kwargs.pop("baudrate"), timeout=kwargs.pop("timeout") ) as serial_stream: diff --git a/src/pyubxutils/ubxsave.py b/src/pyubxutils/ubxsave.py index a001663..bac8371 100644 --- a/src/pyubxutils/ubxsave.py +++ b/src/pyubxutils/ubxsave.py @@ -51,6 +51,7 @@ from serial import Serial from pyubxutils._version import __version__ as VERSION +from pyubxutils.exceptions import ParameterError from pyubxutils.globals import EPILOG, VERBOSITY_HIGH from pyubxutils.helpers import progbar, set_common_args @@ -272,7 +273,7 @@ def main(): ap = ArgumentParser(epilog=EPILOG, formatter_class=ArgumentDefaultsHelpFormatter) ap.add_argument("-V", "--version", action="version", version="%(prog)s " + VERSION) - ap.add_argument("-P", "--port", required=True, help="Serial port") + ap.add_argument("-P", "--port", required=False, help="Serial port") ap.add_argument( "-O", "--outfile", @@ -305,6 +306,9 @@ def main(): kwargs = set_common_args("ubxsave", ap, logdefault=VERBOSITY_HIGH) + if kwargs.get("port", None) is None: + raise ParameterError("Serial port must be specified") + with open(kwargs.pop("outfile"), "wb") as outfile: with Serial( kwargs.pop("port"), kwargs.pop("baudrate"), timeout=kwargs.pop("timeout") diff --git a/src/pyubxutils/ubxsetrate.py b/src/pyubxutils/ubxsetrate.py index 03f5eef..9154d1c 100644 --- a/src/pyubxutils/ubxsetrate.py +++ b/src/pyubxutils/ubxsetrate.py @@ -179,7 +179,7 @@ def main(): ap = ArgumentParser(epilog=EPILOG, formatter_class=ArgumentDefaultsHelpFormatter) ap.add_argument("-V", "--version", action="version", version="%(prog)s " + VERSION) - ap.add_argument("-P", "--port", required=True, help="Serial port") + ap.add_argument("-P", "--port", required=False, help="Serial port") ap.add_argument( "--baudrate", required=False, @@ -216,6 +216,9 @@ def main(): kwargs = set_common_args("ubxsetrate", ap, logdefault=VERBOSITY_HIGH) + if kwargs.get("port", None) is None: + raise ParameterError("Serial port must be specified") + try: usr = UBXSetRate(**kwargs) usr.apply()