repeaterbook: Move to cached/proxied service

This moves CHIRP to use a proxy for repeaterbook at chirpmyradio.com
to reduce load on the repeaterbook API and improve performance for
our users.

Also, don't run the network tests in CI as they're less important
now and also their failing probably has nothing to do with the patch
being submitted.
This commit is contained in:
Dan Smith 2026-03-04 19:09:29 -08:00 committed by Dan Smith
parent dc94198394
commit 2cd274dae9
4 changed files with 18 additions and 16 deletions

View file

@ -8,6 +8,9 @@ inputs:
required: false
type: string
default: '3'
tox_args:
required: false
type: string
runs:
using: "composite"
@ -22,4 +25,4 @@ runs:
shell: bash
run: |
git fetch origin $GITHUB_BASE_REF || true
tox -e ${{ inputs.tox_target }}
tox -e ${{ inputs.tox_target }} -- ${{ inputs.tox_args }}

View file

@ -23,6 +23,7 @@ jobs:
uses: ./.github/actions/py3-tox
with:
tox_target: unit
tox_args: -k "not network"
- name: Archive results
uses: actions/upload-artifact@v4
with:

View file

@ -2,6 +2,7 @@ import datetime
import glob
import json
import logging
import lzma
import math
import os
@ -115,18 +116,8 @@ class RepeaterBook(base.NetworkResultRadio):
LOG.debug('RepeaterBook database %s too old: %s',
fn, modified_dt)
params = {'country': country,
'stype': service}
if country in NA_COUNTRIES:
export = 'export.php'
else:
export = 'exportROW.php'
if country in STATES:
params['state'] = state
r = requests.get('https://www.repeaterbook.com/api/%s' % export,
r = requests.get('https://data.chirpmyradio.com/rb/%s.xz' % fn,
headers=base.HEADERS,
params=params,
stream=True)
if r.status_code != 200:
if modified:
@ -141,8 +132,10 @@ class RepeaterBook(base.NetworkResultRadio):
probable_end = 3 << 20
counter = 0
data = b''
decomp = lzma.LZMADecompressor(format=lzma.FORMAT_XZ)
with open(tmp, 'wb') as f:
for chunk in r.iter_content(chunk_size=chunk_size):
chunk = decomp.decompress(chunk)
f.write(chunk)
data += chunk
counter += len(chunk)

View file

@ -1,5 +1,6 @@
import datetime
import json
import lzma
import os
import shutil
import tempfile
@ -184,11 +185,13 @@ class TestRepeaterbook(unittest.TestCase):
status.send_fail.assert_called()
def test_get_data_no_results(self):
comp = lzma.LZMACompressor(format=lzma.FORMAT_XZ)
fake_data = comp.compress(json.dumps({'count': 0}).encode())
fake_data += comp.flush()
rb = repeaterbook.RepeaterBook()
with mock.patch('requests.get') as mock_get:
mock_get.return_value.status_code = 200
mock_get.return_value.iter_content.return_value = [json.dumps(
{'count': 0}).encode()]
mock_get.return_value.iter_content.return_value = [fake_data]
status = mock.MagicMock()
r = rb.get_data(status, 'US', 'OR', '')
self.assertIsNone(r)
@ -202,11 +205,13 @@ class TestRepeaterbook(unittest.TestCase):
files = os.listdir(self.tempdir)
# Make sure we started with no data files
self.assertEqual(0, len(files))
comp = lzma.LZMACompressor(format=lzma.FORMAT_XZ)
fake_data = comp.compress(json.dumps({'count': 1}).encode())
fake_data += comp.flush()
rb = repeaterbook.RepeaterBook()
with mock.patch('requests.get') as mock_get:
mock_get.return_value.status_code = 200
mock_get.return_value.iter_content.return_value = [json.dumps(
{'count': 1}).encode()]
mock_get.return_value.iter_content.return_value = [fake_data]
status = mock.MagicMock()
r = rb.get_data(status, 'US', 'OR', '')
self.assertIsNotNone(r)