From 1ae0bc95079c0434a8f82856c6c698c27cfa9f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ted=20Sj=C3=B6blom?= <36690474+TedSjoblom@users.noreply.github.com> Date: Thu, 20 Oct 2022 10:02:39 +0200 Subject: [PATCH] Container image --- .github/workflows/ci-checks.yml | 5 ----- .github/workflows/release.yml | 4 ++-- main.py | 25 +++++++++++-------------- test.py | 13 ------------- 4 files changed, 13 insertions(+), 34 deletions(-) delete mode 100644 test.py diff --git a/.github/workflows/ci-checks.yml b/.github/workflows/ci-checks.yml index 5133e97..2c16a6c 100644 --- a/.github/workflows/ci-checks.yml +++ b/.github/workflows/ci-checks.yml @@ -25,11 +25,6 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements_dev.txt - - name: Generate brefv code - run: | - mkdir brefv - datamodel-codegen --input brefv-spec/envelope.json --input-file-type jsonschema --output brefv/envelope.py - datamodel-codegen --input brefv-spec/messages --input-file-type jsonschema --reuse-model --output brefv/messages - name: Run black run: | black --check main.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5fdf78d..36ec17f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,8 +29,8 @@ jobs: file: Dockerfile push: true tags: | - ghcr.io/mo-rise/crowsnest-connector-lidar-ouster:latest - ghcr.io/mo-rise/crowsnest-connector-lidar-ouster:${{ github.event.release.tag_name }} + ghcr.io/mo-rise/crowsnest-connector-udp-nmea:latest + ghcr.io/mo-rise/crowsnest-connector-udp-nmea:${{ github.event.release.tag_name }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file diff --git a/main.py b/main.py index 7a2020f..0c78db2 100644 --- a/main.py +++ b/main.py @@ -33,7 +33,7 @@ # Setup logger -LOG_LEVEL = env.log_level("LOG_LEVEL", logging.INFO) +LOG_LEVEL = env.log_level("LOG_LEVEL", logging.WARNING) logging.basicConfig(level=LOG_LEVEL) logging.captureWarnings(True) warnings.filterwarnings("once") @@ -107,31 +107,28 @@ def pars_nmea(nmea_msg_bytes): for nmea_str in nmea_list: nmea_str = "$" + nmea_str.split("$")[-1] - LOGGER.info(nmea_str) try: nmea_type_msg = nmea_str.split(",")[0].replace("$", "") - LOGGER.info(nmea_type_msg) if nmea_type_msg == "PASHR": PASHR_items = nmea_str.split(",") - + for idx, item in enumerate(PASHR_items): try: PASHR_items[idx] = float(PASHR_items[idx]) except: - pass + pass PASHR = { - "heading": PASHR_items[2], - "roll": PASHR_items[4], - "pitch": PASHR_items[5], - "roll_accuracy": PASHR_items[7], - "heading_accuracy": PASHR_items[9], - } + "heading": PASHR_items[2], + "roll": PASHR_items[4], + "pitch": PASHR_items[5], + "roll_accuracy": PASHR_items[7], + "heading_accuracy": PASHR_items[9], + } nmea_parameters.update(PASHR) - msg = pynmea2.parse(nmea_str) if msg.sentence_type == "GGA": @@ -188,8 +185,8 @@ def pars_nmea(nmea_msg_bytes): nmea_parameters.update(GST) except Exception as e: - LOGGER.info(e) - pass + LOGGER.error(e) + LOGGER.info(nmea_parameters) return nmea_parameters diff --git a/test.py b/test.py deleted file mode 100644 index 28cacd2..0000000 --- a/test.py +++ /dev/null @@ -1,13 +0,0 @@ -from datetime import datetime -import pytz - -d = "2022-10-20" -t = "06:48:29.010000" - -datetime_str = d +" "+ t - -print(datetime_str) -datetime_object = datetime.strptime(datetime_str, "%Y-%m-%d %H:%M:%S.%f") -datetime_object = pytz.utc.localize(datetime_object) - -print(datetime_object) \ No newline at end of file