Skip to content

dzcb 0.3 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ Create / edit codeplug source files under [`/input`](/input).
If multiple subdirectories exist under `/input`, then multiple
codeplugs will be generated.

The [`default`](./input/default) directory contains the example codeplug
input files along with 2 scripts:

* [`generate.sh`](./input/default/generate.sh) builds the codeplug with a
standard bash shell command.
* [`generate.py`](./input/default/generate.py) builds the same codeplug
using python code.

Derivative codeplugs don't need to include both scripts. Use the format
that is most familiar. While the sample scripts show identical functionality,
the python code could be extended to hack at the generation process itself.

### See [dzcb README.md](https://github.com/mycodeplug/dzcb#dzcb) for more information on input files and formats.

## Generating
Expand All @@ -51,14 +63,20 @@ for step-by-step instructions.
* Copy templates from
[default-tyt-md380](https://github.com/mycodeplug/dzcb/blob/main/codeplug/default-tyt-md380)
for monoband variants.
* [`example-d878uv.conf`](./input/default/example-d878uv.conf):
set your Radio ID and Radio Name
* See README and templates in
[dmrconfig](https://github.com/mycodeplug/dzcb/blob/main/src/dzcb/data/dmrconfig)
for more information and other radio types.
* [`k7abd`](./input/default/k7abd): manually defined zones in
K7ABD anytone-config-builder format. See N7EKB's
[`cps-import-builder` reference data files](https://github.com/n7ekb/cps-import-builder/tree/main/reference_data_files/N7EKB_shared_files)
for more examples.
* [`order.json`](./input/default/order.json): preferred zone order,
zone exclusion, preferred talkgroup order
* [`order.csv`](./input/default/order.csv): preferred zone, contact, channel order
* [`exclude.csv`](./input/default/exclude.csv): zone, contact, channel exclude
* [`replacements.csv`](./input/default/replacements.csv): object name replacements (regex)
* [`scanlists.json`](./input/default/scanlists.json): additional scanlists
* [`generate.sh`](./input/default/generate.sh): options passed to `dzcb` (whether
* [`generate.py`](./input/default/generate.py): options passed to `dzcb` (whether
to include PNWDigital, SeattleDMR, default files, etc)
* [`prox.csv`](./input/default/prox.csv): customize points of
interest, distances, and desired bands
Expand All @@ -71,11 +89,21 @@ for step-by-step instructions.

#### Requirements

* linux or macOS (windows not yet supported)
* python 3.5+ (python 3.8 recommended)
* linux, macOS, windows
* python 3.6+ (python 3.8 recommended)
* [tox](https://tox.readthedocs.io/en/latest/)

#### Build

To output to a specific directory, set the `OUTPUT` environment variable.

```
pip install tox
tox
```

To run the `generate.sh` shell scripts

```
tox -e shell
```
25 changes: 25 additions & 0 deletions input/default/example-d878uv.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# mycodeplug/example-codeplug generated $ISODATE
# by dzcb (https://github.com/mycodeplug/dzcb)
#
# !dzcb.ranges: 136-174,400-480
Radio: Anytone AT-D878UV

# Table of text messages.
# 1) Message number: 1-100
# 2) Text: up to 200 characters
#
Message Text
1 Hello
2 Thank you
3 73
4 QTH?
5 Test message

# Unique DMR ID and name of this radio.
ID: 12345678
Name: AA1AA

# Text displayed when the radio powers up.
Intro Line 1: $DATE
Intro Line 2: PNWDigital
2 changes: 1 addition & 1 deletion input/default/example-md-uv380.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
"GroupCallHangTime": "3000",
"GroupCallMatch": "On",
"IntroScreen": "Character String",
"IntroScreenLine1": "2021/01/01",
"IntroScreenLine1": "$DATE",
"IntroScreenLine2": "PNWDigital",
"KeypadTones": "Off",
"LoneWorkerReminderTime": "10",
Expand Down
22 changes: 22 additions & 0 deletions input/default/exclude.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Channels,Contacts,Zones
"MM/Peter 430","Kitsap CARC",
"MM/Wes 430","Wash ARES",
"Coeur d'Alene","Idaho ARES 2",
"Lewiston ID","SoCal 2",
"Poteros/Goat Mtn","Utah 2",
"Prineville/Town",,
"Saint Maries ID",,
"Sultan/Haystack",,
"BC:Whisler/Black",,
"BC:NewWstmnstr",,
"BC:Vancouver/Sey",,
"BC:Squamish",,
"BC:W.Vancvr/Ambl",,
"Tulalip/Tulalip",,
"Gresham/Hospital",,
"BM Port Townsend",,
"CC Port Angeles",,
"CC Sequim",,
"Sequim KC7EQO",,
"BM Ferndale",,
"BM Scappoose",,
30 changes: 30 additions & 0 deletions input/default/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3

# This generates the same codeplug as generate.sh
# using python code.

from pathlib import Path
import os

from dzcb.recipe import CodeplugRecipe

cp_dir = Path(__file__).parent
output = Path(os.environ.get("OUTPUT") or (cp_dir / ".." / ".." / "OUTPUT"))

CodeplugRecipe(
source_pnwdigital=True,
source_seattledmr=True,
source_default_k7abd=True,
source_k7abd=[(cp_dir / "k7abd")],
source_repeaterbook_proximity=cp_dir / "prox.csv",
repeaterbook_states=["washington", "oregon"],
repeaterbook_name_format='{Callsign} {Nearest City} {Landmark}',
scanlists_json=cp_dir / "scanlists.json",
exclude=cp_dir / "exclude.csv",
order=cp_dir / "order.csv",
replacements=cp_dir / "replacements.csv",
output_anytone=True,
output_dmrconfig=[(cp_dir / "example-d878uv.conf")],
output_farnsworth=[(cp_dir / "example-md-uv380.json")],
output_gb3gf=True
).generate(output / cp_dir.name)
19 changes: 14 additions & 5 deletions input/default/generate.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
#!/usr/bin/env bash

# This generates the same codeplug as generate.py
# using bash scripting. Linux or macOS only.

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
OUTPUT=${OUTPUT:-$DIR/../../OUTPUT}
python -m dzcb \
--pnwdigital \
--seattledmr \
--default-k7abd \
--repeaterbook-state washington oregon \
--repeaterbook-proximity-csv "$DIR/prox.csv" \
--k7abd $DIR/k7abd \
--farnsworth-template-json "$DIR/example-md-uv380.json" \
--repeaterbook-proximity-csv "$DIR/prox.csv" \
--repeaterbook-state washington oregon \
--repeaterbook-name-format '{Callsign} {Nearest City} {Landmark}' \
--scanlists-json "$DIR/scanlists.json" \
--order-json "$DIR/order.json" \
$OUTPUT/$(basename "$DIR")
--exclude "$DIR/exclude.csv" \
--order "$DIR/order.csv" \
--replacements "$DIR/replacements.csv" \
--anytone \
--dmrconfig "$DIR/example-d878uv.conf" \
--farnsworth-template-json "$DIR/example-md-uv380.json" \
--gb3gf \
-- "$OUTPUT/$(basename "$DIR")"
6 changes: 3 additions & 3 deletions input/default/k7abd/Digital-Repeaters__Hotspot.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Zone Name,Comment,Power,RX Freq,TX Freq,Color Code,CNJHam,Colorado Mega,CO Skyhub,Illinois-Link,Olympic P,Oregon 1,Oregon TAC,PNW Rgnl,Quadnet Array,Reddit,TAC 310-2,TAC 311-2,TAC 312-2,Texas,Washington 1,Worldwide
DPHS Static;DHS,Static Tgs,Low,430.4375,439.4375,1,-,-,-,-,2,1,2,2,-,2,-,-,-,-,1,-
DPHS Wide;DHW,Dynamic Tgs,Low,430.4375,439.4375,1,2,2,2,2,-,-,-,-,2,2,2,2,2,2,-,2
Zone Name,Comment,Power,RX Freq,TX Freq,Color Code,CNJHam,Colorado Mega,CO Skyhub,Illinois-Link,Olympic P,Oregon 1,Oregon TAC,PNW Rgnl,Quadnet Array,Reddit,Parrot BM,TAC 310-2,TAC 311-2,TAC 312-2,Texas,Washington 1,Worldwide
DPHS Static;DHS,Static Tgs,Low,430.4375,439.4375,1,-,-,-,-,2,1,2,2,-,2,2,-,-,-,-,1,-
DPHS Wide;DHW,Dynamic Tgs,Low,430.4375,439.4375,1,2,2,2,2,-,-,-,-,2,2,2,2,2,2,2,-,2
7 changes: 7 additions & 0 deletions input/default/k7abd/Digital-Repeaters__Washington.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Zone Name,Comment,Power,RX Freq,TX Freq,Color Code,California,Emcom US,Kitsap CARC,Olympic P,Oregon 1,Oregon TAC,PNW Rgnl,TAC 310,TAC 311,TAC 312,TG 2,TG 9,Washington 1,Wash ARES
BM Port Townsend;BPT,W7JCR,High,443.825,448.825,1,2,2,1,1,2,1,1,1,1,1,1,1,2,1
CC Port Angeles;CPA,W7FW,High,442.125,447.125,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1
CC Sequim;CSQ,K6MBY,High,440.75,445.75,1,1,1,2,1,1,1,1,1,1,1,1,1,2,1
Sequim KC7EQO;SQK,KC7EQO,High,442.1,447.1,1,1,1,2,1,1,1,1,1,1,1,1,1,2,1
BM Ferndale;BFD,W7ECG,High,440.7375,445.7375,1,-,1,-,-,1,-,2,1,1,1,1,1,1,1
BM Scappoose;BSC,AA7BG,High,441.8625,446.8625,1,-,2,-,-,1,2,2,1,1,1,1,2,1,-
1 change: 1 addition & 0 deletions input/default/k7abd/Talkgroups__Hotspot.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Oregon TAC,31410
PNW Rgnl,31771
Quadnet Array,31012
Reddit,98003
Parrot BM,9990P
TAC 310-2,310
TAC 311-2,311
TAC 312-2,312
Expand Down
16 changes: 16 additions & 0 deletions input/default/k7abd/Talkgroups__Washington.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
California,3106
Emcom US,9911
Kitsap CARC,311429
Local 1,3181
Olympic P,31531
Oregon 1,3141
Oregon TAC,31410
PNW Rgnl,31771
TAC 310,310
TAC 311,311
TAC 312,312
TG 2,2
TG 9,9
Washington 1,3153
Wash ARES,31538
Simplex 99,99
11 changes: 11 additions & 0 deletions input/default/order.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
zones,contacts,channels
PNWDigital,Oregon 1,Rainier Hill
Hotspot,Washington 1,DPHS Static
Local,Washington 2,DPHS Wide
SeattleDMR,Cascades 1,
Longview WA VHF 35mi,Local 1,
Longview WA UHF 35mi,Local 2,
Simplex A VHF,Parrot 1,
Simplex A UHF,,
Simplex D VHF,,
Simplex D UHF,,
42 changes: 0 additions & 42 deletions input/default/order.json

This file was deleted.

3 changes: 3 additions & 0 deletions input/default/replacements.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Channels_pattern,Channels_repl,Zones_pattern,Zones_repl,Contacts_pattern,Contacts_repl,
Oregon,OR,Longview/Rainier,Rainier Hill,,,
Washington,WA,,,,,
21 changes: 11 additions & 10 deletions input/default/scanlists.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
"Longview/Rainier",
"DPHS Static",
"DPHS Wide",
"Oregon 1 LVR",
"Washington 2 LVR",
"W7DG Longview 1",
"OR 1 LVR",
"WA 2 LVR",
"W7DG Longview1",
"W7DG Longview Co",
"N7EI Deer Island",
"W7BU Astoria Ni1",
"W7BU Astoria Wi1",
"K7RPT Astoria W1",
"KJ7IY Timber ",
"WA7UHD Chehalis ",
"W7DG Longview ",
"W7BU Astoria Nic",
"W7BU Astoria Wic",
"K7RPT Astoria Wi",
"KJ7IY Timber",
"WA7UHD Chehalis",
"W7DG Longview",
"N3EG Longview Co",
"AB7F Longview ",
"AB7F Longview",
"W7OTV Colton Goa",
"SP U01 441.000",
"SP U02 446.5",
Expand Down
13 changes: 13 additions & 0 deletions input/generate_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python3

# execute all generate.py files in subdirectories of this
# scripts directory

from pathlib import Path
import subprocess
import sys

cp_dir = Path(__file__).parent

for genpy in cp_dir.glob("**/generate.py"):
subprocess.check_call([sys.executable, genpy])
17 changes: 17 additions & 0 deletions input/generate_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# execute all generate.sh files in subdirectories of this
# scripts directory (posix-like only)

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

if find --version 2>/dev/null | grep "GNU findutils" > /dev/null; then
FIND_OPTS="-executable"
else
FIND_OPTS="-perm +111"
fi

find $DIR \
-name "generate.sh" \
$FIND_OPTS -print0 | \
xargs -0 -n 1 bash
22 changes: 8 additions & 14 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@
minversion = 3.7.0
skipsdist = true
allowlist_external = /usr/bin/env
envlist = py3-{linux,mac}
envlist = py3

[testenv]
platform =
linux: linux
mac: darwin
passenv = OUTPUT
setenv =
!mac: FIND_OPTS = -executable
mac: FIND_OPTS = -perm '+111'
deps =
dzcb~=0.2.0
dzcb~=0.3.0
commands =
/usr/bin/env bash -c " \
find {toxinidir}/input \
-name "generate.sh" \
{env:FIND_OPTS} -print0 | \
xargs -0 -n 1 bash \
"
python {toxinidir}/input/generate_all.py

[testenv:shell]
platform = linux|darwin
commands =
{toxinidir}/input/generate_all.sh