From f14fe1f7890246752107af5f20fdd689c43cd589 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 22 Feb 2025 22:22:58 -0500 Subject: [PATCH 01/15] Move the action configs to correct dir --- {.github => .gitea}/workflows/build.yml | 0 {.github => .gitea}/workflows/lint.yml | 0 {.github => .gitea}/workflows/test.yml | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {.github => .gitea}/workflows/build.yml (100%) rename {.github => .gitea}/workflows/lint.yml (100%) rename {.github => .gitea}/workflows/test.yml (100%) diff --git a/.github/workflows/build.yml b/.gitea/workflows/build.yml similarity index 100% rename from .github/workflows/build.yml rename to .gitea/workflows/build.yml diff --git a/.github/workflows/lint.yml b/.gitea/workflows/lint.yml similarity index 100% rename from .github/workflows/lint.yml rename to .gitea/workflows/lint.yml diff --git a/.github/workflows/test.yml b/.gitea/workflows/test.yml similarity index 100% rename from .github/workflows/test.yml rename to .gitea/workflows/test.yml From 7c9b9ba446c77a59e041e8e492330c9225e33c8d Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 22 Feb 2025 22:25:34 -0500 Subject: [PATCH 02/15] Use 'yaml' instead of 'yml' --- .gitea/workflows/{build.yml => build.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .gitea/workflows/{build.yml => build.yaml} (100%) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yaml similarity index 100% rename from .gitea/workflows/build.yml rename to .gitea/workflows/build.yaml From 597c73f45e76973545fe8d0b3b87b5c14749433e Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 22 Feb 2025 22:26:17 -0500 Subject: [PATCH 03/15] Update yaml on something that will run on PR --- .gitea/workflows/{lint.yml => lint.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .gitea/workflows/{lint.yml => lint.yaml} (100%) diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yaml similarity index 100% rename from .gitea/workflows/lint.yml rename to .gitea/workflows/lint.yaml From 57e93eaa81d232b077420939c3d007d508f8fec3 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 22 Feb 2025 22:31:39 -0500 Subject: [PATCH 04/15] Fix actions - Fix branch names - Update PRs to run on any branch --- .gitea/workflows/{build.yaml => build.yml} | 2 +- .gitea/workflows/{lint.yaml => lint.yml} | 4 ++-- .gitea/workflows/test.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename .gitea/workflows/{build.yaml => build.yml} (99%) rename .gitea/workflows/{lint.yaml => lint.yml} (94%) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yml similarity index 99% rename from .gitea/workflows/build.yaml rename to .gitea/workflows/build.yml index 06c82d3..7f501c0 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yml @@ -3,7 +3,7 @@ name: release-tag on: push: branches: - - main + - master jobs: release-image: diff --git a/.gitea/workflows/lint.yaml b/.gitea/workflows/lint.yml similarity index 94% rename from .gitea/workflows/lint.yaml rename to .gitea/workflows/lint.yml index 5b3102d..3201a61 100644 --- a/.gitea/workflows/lint.yaml +++ b/.gitea/workflows/lint.yml @@ -3,10 +3,10 @@ name: Lint on: push: branches: - - main + - master pull_request: branches: - - main + - "*" jobs: lint: diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index e453ff6..84109a2 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -3,10 +3,10 @@ name: Test on: push: branches: - - main + - master pull_request: branches: - - main + - "*" jobs: test: From 3c99d057084a68c9fee304653b748fcb77ffe8b6 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 22 Feb 2025 22:40:19 -0500 Subject: [PATCH 05/15] Bumb versions in linting --- .gitea/workflows/lint.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index 3201a61..51ac532 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -13,12 +13,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: - python-version: 3.x + python-version: '3.13' - name: Install dependencies run: | From 1de9e9ce1de11c550de2180d231291fe0ab5d0dd Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 22 Feb 2025 22:43:07 -0500 Subject: [PATCH 06/15] remove test for another time --- .gitea/workflows/test.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .gitea/workflows/test.yml diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml deleted file mode 100644 index 84109a2..0000000 --- a/.gitea/workflows/test.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Test - -on: - push: - branches: - - master - pull_request: - branches: - - "*" - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pytest - - - name: Run tests - run: | - pytest \ No newline at end of file From 8f0df2e3e1c5bc37affbe7aae2357aacbd5b75aa Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 22 Feb 2025 22:51:01 -0500 Subject: [PATCH 07/15] Linting --- app/NoiseGatev2.py | 28 ++++++++++++++-------------- app/bot.py | 11 ++++++----- app/get_devices.py | 2 +- app/op25_controller.py | 16 ++++++++-------- app/pulse.py | 2 +- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app/NoiseGatev2.py b/app/NoiseGatev2.py index 158937e..454d343 100644 --- a/app/NoiseGatev2.py +++ b/app/NoiseGatev2.py @@ -30,15 +30,15 @@ class AudioStream: if _input: self.paInstance_kwargs['input_device_index'] = _input_device_index else: - LOGGER.warning(f"[AudioStream.__init__]:\tInput was not enabled." - f" Reinitialize with '_input=True'") + LOGGER.warning("[AudioStream.__init__]:\tInput was not enabled." + " Reinitialize with '_input=True'") if _output_device_index: if _output: self.paInstance_kwargs['output_device_index'] = _output_device_index else: - LOGGER.warning(f"[AudioStream.__init__]:\tOutput was not enabled." - f" Reinitialize with '_output=True'") + LOGGER.warning("[AudioStream.__init__]:\tOutput was not enabled." + " Reinitialize with '_output=True'") if _init_on_startup: # Init PyAudio instance @@ -59,15 +59,15 @@ class AudioStream: if self.paInstance_kwargs['input']: self.paInstance_kwargs['input_device_index'] = _new_input_device_index else: - LOGGER.warning(f"[AudioStream.init_stream]:\tInput was not enabled when initialized." - f" Reinitialize with '_input=True'") + LOGGER.warning("[AudioStream.init_stream]:\tInput was not enabled when initialized." + " Reinitialize with '_input=True'") if _new_output_device_index: if self.paInstance_kwargs['output']: self.paInstance_kwargs['output_device_index'] = _new_output_device_index else: - LOGGER.warning(f"[AudioStream.init_stream]:\tOutput was not enabled when initialized." - f" Reinitialize with '_output=True'") + LOGGER.warning("[AudioStream.init_stream]:\tOutput was not enabled when initialized." + " Reinitialize with '_output=True'") self.close_if_open() @@ -80,7 +80,7 @@ class AudioStream: if self.stream.is_active(): self.stream.stop_stream() self.stream.close() - LOGGER.debug(f"[ReopenStream.close_if_open]:\t Stream was open; It was closed.") + LOGGER.debug("[ReopenStream.close_if_open]:\t Stream was open; It was closed.") def list_devices(self, _display_input_devices: bool = True, _display_output_devices: bool = True): LOGGER.info('Getting a list of the devices connected') @@ -126,7 +126,7 @@ class NoiseGate(AudioStream): def run(self) -> None: global voice_connection # Start the audio stream - LOGGER.debug(f"Starting stream") + LOGGER.debug("Starting stream") self.stream.start_stream() # Start the stream to discord self.core() @@ -139,15 +139,15 @@ class NoiseGate(AudioStream): time.sleep(.2) if not voice_connection.is_playing(): - LOGGER.debug(f"Playing stream to discord") + LOGGER.debug("Playing stream to discord") voice_connection.play(self.NGStream, after=self.core) async def close(self): - LOGGER.debug(f"Closing") + LOGGER.debug("Closing") await voice_connection.disconnect() if self.stream.is_active: self.stream.stop_stream() - LOGGER.debug(f"Stopping stream") + LOGGER.debug("Stopping stream") # noinspection PyUnresolvedReferences @@ -155,7 +155,7 @@ class NoiseGateStream(discord.AudioSource): def __init__(self, _stream): super(NoiseGateStream, self).__init__() self.stream = _stream # The actual audio stream object - self.NG_fadeout = 240/20 # Fadeout value used to hold the noisegate after de-triggering + self.NG_fadeout = 240 / 20 # Fadeout value used to hold the noisegate after de-triggering self.NG_fadeout_count = 0 # A count set when the noisegate is triggered and was de-triggered self.process_set_count = 0 # Counts how many processes have been made diff --git a/app/bot.py b/app/bot.py index f355b73..e0ab21e 100644 --- a/app/bot.py +++ b/app/bot.py @@ -88,10 +88,10 @@ class DiscordBotManager: voice_client = await channel.connect() streamHandler = NoiseGate( - _input_device_index=device_id, - _voice_connection=voice_client, - _noise_gate_threshold=ng_threshold) - # Start the audio stream + _input_device_index=device_id, + _voice_connection=voice_client, + _noise_gate_threshold=ng_threshold) + # Start the audio stream streamHandler.run() self.voice_clients[guild_id] = voice_client print(f"Joined guild {guild_id} voice channel {channel_id}.") @@ -108,6 +108,7 @@ class DiscordBotManager: del self.voice_clients[guild_id] print(f"Left guild {guild_id} voice channel.") + # Initialize Discord Bot Manager bot_manager = DiscordBotManager() @@ -154,4 +155,4 @@ async def get_status(): app.include_router(op25_controller.router, prefix="/op25") -app.include_router(pulse.router, prefix="/pulse") \ No newline at end of file +app.include_router(pulse.router, prefix="/pulse") diff --git a/app/get_devices.py b/app/get_devices.py index 44964f5..5a1de3d 100644 --- a/app/get_devices.py +++ b/app/get_devices.py @@ -8,4 +8,4 @@ for inputDevice in list_of_devices['Input']: print("----- OUTPUT DEVICES -----") for outputDevice in list_of_devices['Output']: - print(f"{outputDevice}\t-\t{list_of_devices['Output'][outputDevice]}") \ No newline at end of file + print(f"{outputDevice}\t-\t{list_of_devices['Output'][outputDevice]}") diff --git a/app/op25_controller.py b/app/op25_controller.py index 092b877..188de66 100644 --- a/app/op25_controller.py +++ b/app/op25_controller.py @@ -1,4 +1,4 @@ -from fastapi import FastAPI, HTTPException, APIRouter +from fastapi import HTTPException, APIRouter from pydantic import BaseModel from enum import Enum import subprocess @@ -6,7 +6,7 @@ import os import signal import json import csv -from typing import List, Optional, Union +from typing import List, Optional router = APIRouter() @@ -87,7 +87,7 @@ class ChannelConfig(BaseModel): symbol_rate: Optional[int] = 4800 blacklist: Optional[str] = "" whitelist: Optional[str] = "" - + class DeviceConfig(BaseModel): args: Optional[str] = "rtl" gains: Optional[str] = "lna:39" @@ -170,7 +170,7 @@ async def generate_config(generator: ConfigGenerator): "audio": audio.dict(), "terminal": terminal.dict() } - + elif generator.type == DecodeMode.ANALOG: generator = generator.config channels = [ChannelConfig( @@ -190,11 +190,11 @@ async def generate_config(generator: ConfigGenerator): else: raise HTTPException(status_code=400, detail="Invalid configuration type. Must be 'p25' or 'nbfm'.") - + with open('/configs/active.cfg.json', 'w') as f: json.dump(del_none_in_dict(config_dict), f, indent=2) - return {"message": f"Config exported to '/configs/active.cfg.json'"} + return {"message": "Config exported to '/configs/active.cfg.json'"} except Exception as e: raise HTTPException(status_code=500, detail=str(e)) @@ -222,7 +222,7 @@ def save_whitelist(talkgroup_tags: List[int]) -> None: writer = csv.writer(file, delimiter='\t', lineterminator='\n') # Write rows for tag in talkgroup_tags: - writer.writerow([tag]) + writer.writerow([tag]) def del_none_in_dict(d): """ @@ -239,4 +239,4 @@ def del_none_in_dict(d): elif isinstance(value, list): for iterative_value in value: del_none_in_dict(iterative_value) - return d # For convenience \ No newline at end of file + return d # For convenience diff --git a/app/pulse.py b/app/pulse.py index 76529a6..17c1dd1 100644 --- a/app/pulse.py +++ b/app/pulse.py @@ -11,4 +11,4 @@ async def get_status(): return {"status": "running" if pulse_process else "stopped"} -# subprocess.Popen(os.path.join(OP25_PATH, OP25_SCRIPT), shell=True, preexec_fn=os.setsid, cwd=OP25_PATH) \ No newline at end of file +# subprocess.Popen(os.path.join(OP25_PATH, OP25_SCRIPT), shell=True, preexec_fn=os.setsid, cwd=OP25_PATH) From 3dbbdaeec29543e35fb14d70e2fbd8ed9bcda380 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 23 Feb 2025 12:20:06 -0500 Subject: [PATCH 08/15] Update dockerfile - Bump ubuntu version - Switch to apt from apt-get - Add extra install for apt-transport-https --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index eec30ef..0799e1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,13 @@ ## OP25 Core Container -FROM ubuntu:22.04 +FROM ubuntu:24.04 # Set environment variables ENV DEBIAN_FRONTEND=noninteractive # Install system dependencies -RUN apt-get update && \ - apt-get install -y git \ +RUN apt update && \ + apt install -y apt-transport-https && \ + apt install -y git \ curl \ python3 \ python3-pip \ From af6c9fb76394773f7e69d52c6837419d1a4dfa60 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 23 Feb 2025 12:24:45 -0500 Subject: [PATCH 09/15] Undo version bump --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0799e1b..df2eb4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ## OP25 Core Container -FROM ubuntu:24.04 +FROM ubuntu:22.04 # Set environment variables ENV DEBIAN_FRONTEND=noninteractive From c872a2701728cb5f22ce0e065bbffc15e7339760 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 23 Feb 2025 13:47:36 -0500 Subject: [PATCH 10/15] Update build workfloow --- .gitea/workflows/build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 7f501c0..7c0cd59 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -11,9 +11,7 @@ jobs: container: image: catthehacker/ubuntu:act-latest env: - DOCKER_ORG: teacup DOCKER_LATEST: nightly - RUNNER_TOOL_CACHE: /toolcache steps: - name: Checkout uses: actions/checkout@v4 @@ -43,13 +41,14 @@ jobs: echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile platforms: | linux/amd64 - linux/arm64 + linux/arm64 + linux/arm/v7 push: true tags: | # replace it with your local IP and tags git.vpn.cusano.net/${{ vars.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }} From f20b6cc0ed3bbf4efac96dc5b4bdb5a7d94748da Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 23 Feb 2025 15:27:38 -0500 Subject: [PATCH 11/15] Add validation and remove armv7 (for testing)( --- .gitea/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 7c0cd59..48616d0 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -40,6 +40,11 @@ jobs: echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT + - name: Validate build configuration + uses: docker/build-push-action@v6 + with: + call: check + - name: Build and push uses: docker/build-push-action@v6 with: @@ -48,7 +53,6 @@ jobs: platforms: | linux/amd64 linux/arm64 - linux/arm/v7 push: true tags: | # replace it with your local IP and tags git.vpn.cusano.net/${{ vars.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }} From 78432c07a03d3d81e33e7081e419840456c187be Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 23 Feb 2025 16:06:11 -0500 Subject: [PATCH 12/15] Remove arm64 for testing --- .gitea/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 48616d0..116fad9 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -52,7 +52,6 @@ jobs: file: ./Dockerfile platforms: | linux/amd64 - linux/arm64 push: true tags: | # replace it with your local IP and tags git.vpn.cusano.net/${{ vars.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }} From 3ded857456bf08cd28a4273e2bd88ffe362c11b7 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 23 Feb 2025 16:36:30 -0500 Subject: [PATCH 13/15] testing just arm64 build --- .gitea/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 116fad9..ffc8601 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -51,7 +51,7 @@ jobs: context: . file: ./Dockerfile platforms: | - linux/amd64 + linux/arm64 push: true tags: | # replace it with your local IP and tags git.vpn.cusano.net/${{ vars.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }} From d41ed60ee60efceb2ca6cf890f79cd6203bcad5b Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 23 Feb 2025 17:42:26 -0500 Subject: [PATCH 14/15] Update dockerfile to speed up debugging --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index df2eb4b..8e7c883 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,8 @@ ENV DEBIAN_FRONTEND=noninteractive # Install system dependencies RUN apt update && \ - apt install -y apt-transport-https && \ - apt install -y git \ + apt-get install -y --no-install-recommends libc-bin apt-transport-https && \ + apt install -y --no-install-recommends git \ curl \ python3 \ python3-pip \ From acb72eff03a55b2d0a40a4c26bba5d83949bd1f3 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 23 Feb 2025 20:33:36 -0500 Subject: [PATCH 15/15] Reset build step and disabled for now --- .gitea/workflows/{build.yml => build.yml.bak} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename .gitea/workflows/{build.yml => build.yml.bak} (87%) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml.bak similarity index 87% rename from .gitea/workflows/build.yml rename to .gitea/workflows/build.yml.bak index ffc8601..b4d5e6a 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml.bak @@ -12,6 +12,7 @@ jobs: image: catthehacker/ubuntu:act-latest env: DOCKER_LATEST: nightly + CONTAINER_NAME: drb-client-discord-bot steps: - name: Checkout uses: actions/checkout@v4 @@ -51,8 +52,8 @@ jobs: context: . file: ./Dockerfile platforms: | - linux/arm64 + linux/amd64 push: true tags: | # replace it with your local IP and tags - git.vpn.cusano.net/${{ vars.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }} - git.vpn.cusano.net/${{ vars.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ env.DOCKER_LATEST }} \ No newline at end of file + git.vpn.cusano.net/${{ vars.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}/${{ env.CONTAINER_NAME }}:${{ steps.meta.outputs.REPO_VERSION }} + git.vpn.cusano.net/${{ vars.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}/${{ env.CONTAINER_NAME }}:${{ env.DOCKER_LATEST }} \ No newline at end of file