Skip to content

Commit

Permalink
Add Python plugin support (#347)
Browse files Browse the repository at this point in the history
Some functions can be overridden by contest specific plugin methods.

---------

Co-authored-by: Victor Denisov <[email protected]>
Co-authored-by: Thomas Beierlein <[email protected]>
Co-authored-by: Thomas Beierlein <[email protected]>
Co-authored-by: Jonathan Bastien-Filiatrault <[email protected]>
  • Loading branch information
5 people authored Mar 8, 2023
1 parent 1be77a0 commit 6c9c89e
Show file tree
Hide file tree
Showing 70 changed files with 1,492 additions and 640 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci-build-ubuntu-20.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI build for Ubuntu 20

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-20.04
timeout-minutes: 3
env:
TERM: xterm
AM_COLOR_TESTS: always

steps:
- uses: actions/checkout@v3
- name: Show OS info
run: cat /etc/os-release
- name: Install dependencies
run: |
sudo apt-get -qq update
sudo apt-get install -y libhamlib-dev libxmlrpc-core-c3-dev libcmocka-dev
- name: Autoreconf and basic make
run: autoreconf -i && ./configure && make -j2
- name: Configure with xmlrpc
run: make clean && ./configure --enable-fldigi-xmlrpc && make -j2
- name: Run tests
run: make check; rc=$?; cat test/run_*.log; exit $rc
6 changes: 4 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ jobs:
AM_COLOR_TESTS: always

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Show OS info
run: cat /etc/os-release
- name: Install dependencies
run: |
sudo apt-get -qq update
sudo apt-get install -y libhamlib-dev libxmlrpc-core-c3-dev libcmocka-dev
sudo apt-get install -y libhamlib-dev libxmlrpc-core-c3-dev libcmocka-dev python3-dev
- name: Autoreconf and basic make
run: autoreconf -i && ./configure && make -j2
- name: Configure with xmlrpc
run: make clean && ./configure --enable-fldigi-xmlrpc && make -j2
- name: Configure with xmlrpc and Python plugin
run: make clean && ./configure --enable-fldigi-xmlrpc --enable-python-plugin && make -j2
- name: Run tests
run: make check; rc=$?; cat test/run_*.log; exit $rc
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ AS_IF([test "x$wantpythonplugin" = xtrue], [
dnl Look for Python
AC_MSG_RESULT([yes])
AM_PATH_PYTHON([3.0])
AM_PATH_PYTHON([3.9])
python_main_ver=`$PYTHON -c "import sys; print(sys.version.split('.')[[0]])"`
python_sub_ver=`$PYTHON -c "import sys; print(sys.version.split('.')[[1]])"`
Expand Down
63 changes: 63 additions & 0 deletions rules/cqp/cqp_ca
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
########################
# Provided by: Victor Denisov N6DVS
# Last Verified: 2022-10-16
########################
#
CONTEST=California_QSO_Party
CONTEST_MODE
LOGFILE=cqp.log
CABRILLO=UNIVERSAL
CWPOINTS=3
SSBPOINTS=2
SERIAL+SECTION
MULT_LIST=cqp_mults
SECTION_MULT_ONCE
NO_RST
LEADING_ZEROS_SERIAL=OFF
#
##################################
# #
# Messages F1= to F12= #
# Message CQ_TU_MSG= #
# Message S&P_TU_MSG= #
# #
# % = call #
# @ = hiscall #
# # = serial #
# [ = RST #
# + = increase cw speed #
# - = decrease cw speed #
# #
##################################
#
F1=cq cqp %
F2=@ DE %
F3=@ # trin
F4=TU
F5=@
F6=%
F7=@ SRI QSO B4 GL
F8=AGN
F9= ?
F10= QRZ?
F11= PSE K
F12=cq cqp %
#
CQ_TU_MSG=TU %
S&P_TU_MSG=TU # trin
#
#ALT_0=
ALT_1=QTH TRIN TRIN
ALT_2=QTH?
ALT_3=NR # #
ALT_4=NR?
#ALT_5=
#ALT_6=
#ALT_7=
#ALT_8=
#ALT_9=
#
#SEND_DE
#
CABRILLO-QSO-FORMAT=CQP
####### END #####################
76 changes: 76 additions & 0 deletions rules/cqp/cqp_ca_mults
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This mult file is suitable for a California station.
# Mults are states and counties are aliases for California.
# If you operate outside of California your mults will be California counties.
#########################
## California Counties ##
#########################
CA:ALAM,ALPI,AMAD,BUTT,CALA,COLU,CCOS,DELN,ELDO,FRES,GLEN,HUMB,IMPE,INYO,KERN,KING,LAKE,LASS,LANG,MADE,MARN,MARP,MEND,MERC,MODO,MONO,MONT,NAPA,NEVA,ORAN,PLAC,PLUM,RIVE,SACR,SBEN,SBER,SDIE,SFRA,SJOA,SLUI,SMAT,SBAR,SCLA,SCRU,SHAS,SIER,SISK,SOLA,SONO,STAN,SUTT,TEHA,TRIN,TULA,TUOL,VENT,YOLO,YUBA
###################
## United States ##
###################
AL
AK
AZ
AR
CO
CT
DE
FL
GA
HI
ID
IL
IN
IA
KS
KY
LA
ME
MD
MA
MI
MN
MS
MO
MT
NE
NV
NH
NJ
NM
NY
NC
ND
OH
OK
OR
PA
RI
SC
SD
TN
TX
UT
VT
VA
WA
WV
WI
WY
############
## Canada ##
############
MR:NB,NL,NS,PE
# Maritimes (NB, NL, NS, PE)
QC
ON
MB
SK
AB
BC
NT:NU,YT
# Northern Territories (NT, NU, YT)
########
## DX ##
########
# All other locations
61 changes: 61 additions & 0 deletions rules/hadx/hadx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
##########################
# HA-DX contest #
##########################
# https://ha-dx.com/en/contest-rules
#

LOGFILE=hadx.log
CONTEST_MODE

CABRILLO-CONTEST= HA-DX
CABRILLO-CATEGORY-BAND= (SOSB, SOAB, SO3BAND, YOUTH6H, MS)
CABRILLO-CATEGORY-MODE= (CW, SSB, MIXED)
CABRILLO-CATEGORY-TRANSMITTER= (ONE, MULTI)

CABRILLO-CATEGORY-STATION=-
CABRILLO-CATEGORY-OVERLAY=-
CABRILLO-CATEGORY-TIME=-
CABRILLO-LOCATION=-
CABRILLO-OFFTIME=-

#================================
# Select one of following blocks:
#--------------------------------
#
# non-HA stations send serial number
#
CABRILLO-EXCHANGE=#
F3=@ ++5NN-- #
S&P_TU_MSG=TU ++5NN-- #
MY_COUNTRY_POINTS=2
#--------------------------------
#
# magyar állomások megyét adnak
#
##CABRILLO-EXCHANGE=XX
##F3=@ ++5NN-- XX
##S&P_TU_MSG=TU ++5NN-- XX
##MY_COUNTRY_POINTS=10
#================================

INITIAL_EXCHANGE=hadx.txt
RECALL_MULTS

# Scoring:
# Contact with a Hungarian station: 10 points
# Contact with a station on your continent: 2 points
# Contact with a station on another continent: 5 points
#
COUNTRY_LIST_POINTS=10
COUNTRYLIST=HA

MY_CONTINENT_POINTS=2
DX_POINTS=5

# Multipliers:
# worked DXCC + WAE list countries (exception HA) and Hungarian counties
# per band, regardless of mode.
# (handled by hadx.py)

GENERIC_MULT=BAND

22 changes: 22 additions & 0 deletions rules/hadx/hadx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
HA-DX contest
https://ha-dx.com/en/contest-rules
"""

HA_COUNTIES = ['BN', 'BA', 'BE', 'BO', 'CS', 'FE', 'GY', 'HB', 'HE',
'SZ', 'KO', 'NG', 'PE', 'SO', 'SA', 'TO', 'VA', 'VE', 'ZA', 'BP']

def check_exchange(qso):
dxcc = tlf.get_dxcc(qso.call)

if dxcc.main_prefix == 'HA':
exchange = qso.exchange.strip()
if exchange in HA_COUNTIES:
mult = f'HA/{exchange}'
else:
mult = '' # invalid county
else:
mult = dxcc.main_prefix

return {'mult1_value': mult}

32 changes: 32 additions & 0 deletions rules/mwc/mwc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# OK1WC Memorial (MWC)
# https://memorial-ok1wc.cz/index.php?page=rules2l

CONTEST=mwc
LOGFILE=mwc.log

CONTEST_MODE
SERIAL_EXCHANGE

# scoring
ONE_POINT

# mults handled by mwc.py
GENERIC_MULT = BAND


CABRILLO-CONTEST=MWC
CABRILLO-CATEGORY-MODE=CW
CABRILLO-CATEGORY-BAND=(80M,40M,ALL)
CABRILLO-CATEGORY-POWER=(LOW,QRP)

# fixed Cabrillo fields
CABRILLO-CATEGORY-OPERATOR=SINGLE-OP
CABRILLO-CATEGORY-TRANSMITTER=ONE
CABRILLO-OPERATORS=-
CABRILLO-CATEGORY-STATION=-
CABRILLO-CATEGORY-TIME=-
CABRILLO-CATEGORY-OVERLAY=-
CABRILLO-OFFTIME=-
CABRILLO-LOCATION=-
CABRILLO-CLUB=-

19 changes: 19 additions & 0 deletions rules/mwc/mwc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
OK1WC Memorial (MWC)
https://memorial-ok1wc.cz/index.php?page=rules2l
"""

import re

# match trailing call modifier (e.g. /8, /P, /MM, /QRP, etc.)
MODIFIER_PATTERN = re.compile('/(\d|[A-Z]+)$')

def check_exchange(qso):
call = MODIFIER_PATTERN.sub('', qso.call) # remove modifier
if len(call) > 1:
mult = call[-1] # last character of the call
else:
mult = ''

return {'mult1_value': mult}

1 change: 0 additions & 1 deletion rules/tesla.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
import tlf

# e.g. 023 KN03
XCHG_PATTERN = re.compile('\d+\s*(\w{2}\d{2})')
Expand Down
4 changes: 4 additions & 0 deletions share/cabrillo.fmt
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ QSO=FREQ,5;MODE,2;DATE,10;TIME,4;MYCALL,13;RST_S,3;EXC_S,9;HISCALL,13;RST_R,3;EX
# space and slash are both separators
EXCHANGE-SEPARATOR=\s/
QSO=FREQ,5;MODE,2;DATE,10;TIME,4;MYCALL,13;RST_S,3;EXC_S,9;HISCALL,13;RST_R,3;EXC1,4;EXC2,4;EXC3,4

# Califonia QSO Party
[CQP]
QSO=FREQ,5;MODE,2;DATE,10;TIME,4;MYCALL,13;EXC_S,14;HISCALL,13;EXCH,14
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tlf_SOURCES = \
logit.c logview.c \
main.c makelogline.c messagechange.c muf.c \
nicebox.c note.c netkeyer.c\
paccdx.c parse_logcfg.c plugin.c prevqso.c printcall.c \
paccdx.c parse_logcfg.c plugin.c printcall.c \
qrb.c qsonr_to_str.c qtc_log.c qtcwin.c qtcutil.c readcabrillo.c \
readcalls.c readqtccalls.c readctydata.c recall_exchange.c rules.c \
rtty.c \
Expand Down Expand Up @@ -60,7 +60,7 @@ noinst_HEADERS = \
log_to_disk.h logit.h logview.h \
makelogline.h messagechange.h muf.h \
nicebox.h note.h netkeyer.h\
paccdx.h parse_logcfg.h plugin.h prevqso.h printcall.h \
paccdx.h parse_logcfg.h plugin.h printcall.h \
qrb.h qsonr_to_str.h qtc_log.h qtcvars.h qtcwin.h qtcutil.h \
readcalls.h readqtccalls.h readctydata.h recall_exchange.h \
rules.h readcabrillo.h rtty.h \
Expand Down
4 changes: 2 additions & 2 deletions src/addmult.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void add_mult_line(char *line) {
int init_and_load_multipliers(void) {

FILE *cfp;
char s_inputbuffer[186] = "";
char s_inputbuffer[2000] = "";
char *mults_location;

if (mults_possible) {
Expand Down Expand Up @@ -364,7 +364,7 @@ int init_and_load_multipliers(void) {
return 0; // couldn't open file
}

while (fgets(s_inputbuffer, 85, cfp) != NULL) {
while (fgets(s_inputbuffer, sizeof(s_inputbuffer), cfp) != NULL) {

/* strip leading and trailing whitespace */
g_strstrip(s_inputbuffer);
Expand Down
2 changes: 1 addition & 1 deletion src/addpfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool pfx_is_new_on(char *prefix, int bandindex) {


int add_pfx(char *pxstr, unsigned int bandindex) {
extern int pfxmultab;
extern bool pfxmultab;
int q = 0, found = 0, bandfound = 0;

prefixes_worked[nr_of_px].pfx[0] = '\0';
Expand Down
Loading

0 comments on commit 6c9c89e

Please sign in to comment.