2019-01-06 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in 'PyPAD.Receiver' that threw an exception when
	processing a PAD update with no active timer.
	* Added a 'pypad_spottrap.py' PyPAD script.
	* Removed the 'rlm_spottrap' RLM.
	* Removed the 'rlm_test' RLM.
This commit is contained in:
Fred Gleason
2019-01-06 10:00:13 -05:00
parent 5b240c0814
commit 1e3b1a6e0b
9 changed files with 208 additions and 613 deletions

View File

@@ -855,7 +855,8 @@ class Receiver(object):
self.__PyPAD_Process(Update(json.loads(msg),self.__config_parser))
msg=""
line=bytes()
timeout=(deadline-datetime.datetime.now()).total_seconds()
if self.__timer_interval!=None:
timeout=(deadline-datetime.datetime.now()).total_seconds()
def SigHandler(signo,stack):

View File

@@ -36,6 +36,8 @@ install-exec-am:
cp pypad_serial.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_serial.exemplar
../../../helpers/install_python.sh pypad_spinitron.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.py
cp pypad_spinitron.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.exemplar
../../../helpers/install_python.sh pypad_spottrap.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spottrap.py
cp pypad_spottrap.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spottrap.exemplar
../../../helpers/install_python.sh pypad_udp.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.py
cp pypad_udp.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.exemplar
../../../helpers/install_python.sh pypad_urlwrite.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_urlwrite.py
@@ -62,6 +64,8 @@ uninstall-local:
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_serial.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spinitron.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spottrap.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_spottrap.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.exemplar
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_udp.py
rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_urlwrite.exemplar
@@ -85,6 +89,8 @@ EXTRA_DIST = pypad_ando.exemplar\
pypad_live365.py\
pypad_spinitron.exemplar\
pypad_spinitron.py\
pypad_spottrap.exemplar\
pypad_spottrap.py\
pypad_udp.exemplar\
pypad_udp.py\
pypad_urlwrite.exemplar\

View File

@@ -0,0 +1,123 @@
; This is the configuration for the 'pypad_spottrap.script' script for
; Rivendell, which can be used to output Now & Next data to one or more
; remote UDP ports on the basis of Group and Length.
;
; Module configuration consists of a list of rules, each of which consists
; in turn with a set of filter parameters and actions. Each PAD update is
; compared against the filter parameters of each rule. If the filter matches,
; then the rule actions are performed.
;
; Rule Header
;
; One section per rule is configured, starting with 'Rule1' and
; working up consecutively
[Rule1]
; FILTER PARAMETERS
;
; Group Name
;
; The name of the Rivendell group to match.
GroupName=BEDS
; Minimum Length
;
; The minimum length, in milliseconds. A PAD update with a Length of less
; than this value will not be matched.
MinimumLength=0
; Maximum Length
; The maximum length, in milliseconds. A PAD update with a Length of more
; than this value will not be matched.
MaximumLength=10000000
; ACTION PARAMETERS
;
; IP Address
;
; The IP address of the remote UDP port, in dotted-quad notation.
IpAddress=192.168.10.30
; UDP Port
;
; The UDP port number of the remote UDP port, in the range 0 - 65,535.
UdpPort=5859
; Format String. The string to be output each time RDAirPlay changes
; play state, including any wildcards as placeholders for metadata values.
;
; The list of available wildcards can be found in the 'metadata_wildcards.txt'
; file in the Rivendell documentation directory.
;
FormatString=DX 1 %h!
; Default Format String. Similar to the 'FormatString=' parameter described
; above, but this string is output when the rule *doesn't* match. All of
; the wildcards described in the 'FormatString=' section apply here as well.
DefaultFormatString=DX 1 0!
; Log Selection
;
; Set the status for each log to 'Yes', 'No' or 'Onair' to indicate whether
; state changes on that log should be output on this udp port. If set
; to 'Onair', then output will be generated only if RDAirPlay's OnAir flag
; is active.
MasterLog=Yes
Aux1Log=Yes
Aux2Log=Yes
VLog101=No
VLog102=No
VLog103=No
VLog104=No
VLog105=No
VLog106=No
VLog107=No
VLog108=No
VLog109=No
VLog110=No
VLog111=No
VLog112=No
VLog113=No
VLog114=No
VLog115=No
VLog116=No
VLog117=No
VLog118=No
VLog119=No
VLog120=No
; Additional Rules can be configured by adding new sections...
;[Rule2]
;GroupName=TEST
;MinimumLength=0
;MaximumLength=1000000
;FormatString=Artist: %a%r
;DefaultFormatString=Artist: %a%r
;IpAddress=192.168.10.30
;UdpPort=6789
;MasterLog=Yes
;Aux1Log=No
;Aux2Log=Onair
;VLog101=No
;VLog102=No
;VLog103=No
;VLog104=No
;VLog105=No
;VLog106=No
;VLog107=No
;VLog108=No
;VLog109=No
;VLog110=No
;VLog111=No
;VLog112=No
;VLog113=No
;VLog114=No
;VLog115=No
;VLog116=No
;VLog117=No
;VLog118=No
;VLog119=No
;VLog120=No

View File

@@ -0,0 +1,71 @@
#!%PYTHON_BANGPATH%
# pypad_spottrap.py
#
# Output Now & Next data on the basis of Group and Length.
#
# (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
import sys
import socket
import configparser
import PyPAD
last_updates={}
def eprint(*args,**kwargs):
print(*args,file=sys.stderr,**kwargs)
def ProcessPad(update):
try:
last_updates[update.machine()]
except KeyError:
last_updates[update.machine()]=None
n=1
while(True):
section='Rule'+str(n)
try:
if update.shouldBeProcessed(section) and update.hasPadType(PyPAD.TYPE_NOW) and (last_updates[update.machine()] != update.startDateTimeString(PyPAD.TYPE_NOW)):
last_updates[update.machine()]=update.startDateTimeString(PyPAD.TYPE_NOW)
length=update.padField(PyPAD.TYPE_NOW,PyPAD.FIELD_LENGTH)
if update.padField(PyPAD.TYPE_NOW,PyPAD.FIELD_GROUP_NAME)==update.config().get(section,'GroupName') and length>=int(update.config().get(section,'MinimumLength')) and length<=int(update.config().get(section,'MaximumLength')):
msg=update.resolvePadFields(update.config().get(section,'FormatString'),PyPAD.ESCAPE_NONE)
else:
msg=update.resolvePadFields(update.config().get(section,'DefaultFormatString'),PyPAD.ESCAPE_NONE)
send_sock.sendto(msg.encode('utf-8'),
(update.config().get(section,'IpAddress'),int(update.config().get(section,'UdpPort'))))
n=n+1
except configparser.NoSectionError:
return
#
# 'Main' function
#
# Create Send Socket
#
send_sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
rcvr=PyPAD.Receiver()
try:
rcvr.setConfigFile(sys.argv[3])
except IndexError:
eprint('pypad_spottrap.py: you must specify a configuration file')
sys.exit(1)
rcvr.setCallback(ProcessPad)
rcvr.start(sys.argv[1],int(sys.argv[2]))