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

* Changed the PyPAD namespace from 'PyPAD' to 'pypad'.
	* Changed the installation location of PyPAD scripts from
	'@libdir@/rivendell/PyPAD/' to '@libdir@/rivendell/pypad/'.
This commit is contained in:
Fred Gleason
2019-01-08 15:27:44 -05:00
parent 31596cbaca
commit 087f3b811b
46 changed files with 425 additions and 425 deletions

View File

@@ -0,0 +1,40 @@
## automake.am
##
## Automake.am for Rivendell pypad/tests
##
## (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 as
## published by the Free Software Foundation; either version 2 of
## the License, or (at your option) any later version.
##
## 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.
##
## Use automake to process this into a Makefile.in
EXTRA_DIST = filepath_test.py\
now_and_next.py\
pad_test.py
CLEANFILES = *~\
*.idb\
*ilk\
*.obj\
*.pdb\
*.qm\
moc_*
MAINTAINERCLEANFILES = *~\
*.tar.gz\
aclocal.m4\
configure\
Makefile.in\
moc_*

View File

@@ -0,0 +1,78 @@
#!%PYTHON_BANGPATH%
# filepath_test.py
#
# pypad regression test script for Rivendell
#
# Exercise every filepath wildcard in 'pypad.Update::resolveFilepath()'
#
# (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 pypad
def ProcessPad(update):
print()
print('DateTime: '+update.dateTime().isoformat(' '))
print()
print('Abbreviated weekday name [%a | %$a | %^a]: '+update.resolveFilepath('%a | %$a | %^a',update.dateTime()))
print('Full weekday name [%A | %$A | %^A]: '+update.resolveFilepath('%A | %$A | %^A',update.dateTime()))
print('Abbreviated month name [%b | %$b | %^b]: '+update.resolveFilepath('%b | %$b | %^b',update.dateTime()))
print('Full month name [%B | %$B | %^B]: '+update.resolveFilepath('%B | %$B | %^B',update.dateTime()))
print('Century [%C | %$C | %^C]: '+update.resolveFilepath('%C | %$C | %^C',update.dateTime()))
print('Day of the month, zero padded [01 - 31] [%d | %$d | %^d]: '+update.resolveFilepath('%d | %$d | %^d',update.dateTime()))
print('Date (mm-dd-yy) [%D | %$D | %^D]: '+update.resolveFilepath('%D | %$D | %^D',update.dateTime()))
print('Day of the month, space padded [ 1 - 31] [%e | %$e | %^e]: '+update.resolveFilepath('%e | %$e | %^e',update.dateTime()))
print('Day of the month, unpadded [ 1 - 31] [%E | %$E | %^E]: '+update.resolveFilepath('%E | %$E | %^E',update.dateTime()))
print('Date (yyyy-mm-dd) [%F | %$F | %^F]: '+update.resolveFilepath('%F | %$F | %^F',update.dateTime()))
print('Two digit year [%g | %$g | %^g]: '+update.resolveFilepath('%g | %$g | %^g',update.dateTime()))
print('Four digit year [%G | %$G | %^G]: '+update.resolveFilepath('%G | %$G | %^G',update.dateTime()))
print('Abbreviated month name [%h | %$h | %^h]: '+update.resolveFilepath('%h | %$h | %^h',update.dateTime()))
print('Hour, 24 hour, zero padded [00 - 23] [%H | %$H | %^H]: '+update.resolveFilepath('%H | %$H | %^H',update.dateTime()))
print('Hour, 12 hour, space padded [00 - 23] [%i | %$i | %^i]: '+update.resolveFilepath('%i | %$i | %^i',update.dateTime()))
print('Hour, 12 hour, zero padded [00 - 23] [%I | %$I | %^I]: '+update.resolveFilepath('%I | %$I | %^I',update.dateTime()))
print('Day of year, zero padded [%j | %$j | %^j]: '+update.resolveFilepath('%j | %$j | %^j',update.dateTime()))
print('Hour, 12 hour, unpadded [00 - 23] [%J | %$J | %^J]: '+update.resolveFilepath('%J | %$J | %^J',update.dateTime()))
print('Hour, 24 hour, space padded [%k | %$k | %^k]: '+update.resolveFilepath('%k | %$k | %^k',update.dateTime()))
print('Month, zero padded (01 - 12) [%m | %$m | %^m]: '+update.resolveFilepath('%m | %$m | %^m',update.dateTime()))
print('Minute, zero padded (00 - 59) [%M | %$M | %^M]: '+update.resolveFilepath('%M | %$M | %^M',update.dateTime()))
print('AM/PM string [%p | %$p | %^p]: '+update.resolveFilepath('%p | %$p | %^p',update.dateTime()))
print('Rivendell host name [%r | %$r | %^r]: '+update.resolveFilepath('%r | %$r | %^r',update.dateTime()))
print('Rivendell short host name [%R | %$R | %^R]: '+update.resolveFilepath('%R | %$R | %^R',update.dateTime()))
print('Rivendell service name [%s | %$s | %^s]: '+update.resolveFilepath('%s | %$s | %^s',update.dateTime()))
print('Seconds, zero padded (SS) [%S | %$S | %^S]: '+update.resolveFilepath('%S | %$S | %^S',update.dateTime()))
print('Day of the week, numeric, 1=Monday, 7=Sunday [%u | %$u | %^u]: '+update.resolveFilepath('%u | %$u | %^u',update.dateTime()))
print('Week number, as per ISO 8601 [00 - 23] [%V | %$V | %^V]: '+update.resolveFilepath('%V | %$V | %^V',update.dateTime()))
print('Two digit year [%y | %$y | %^y]: '+update.resolveFilepath('%y | %$y | %^y',update.dateTime()))
print('Four digit year [00 - 23] [%Y | %$Y | %^Y]: '+update.resolveFilepath('%Y | %$Y | %^Y',update.dateTime()))
print("Literal '%' [%%]: "+update.resolveFilepath('%%',update.dateTime()))
#
# Create an instance of 'pypad.Receiver'
#
rcvr=pypad.Receiver()
#
# Tell it to use the callback
#
rcvr.setCallback(ProcessPad)
#
# Start the receiver, giving it the hostname or IP address and TCP port of
# the target Rivendell system. Once started, all further processing can only
# be done in the callback method!
#
rcvr.start('localhost',pypad.PAD_TCP_PORT)

View File

@@ -0,0 +1,69 @@
#!%PYTHON_BANGPATH%
# now_and_next.py
#
# Barebones example pypad script for Rivendell
#
# (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.
#
#
# To see the full documentation of these classes, enter the following at
# a python interactive prompt:
#
# import pypad
# help(pypad)
#
import pypad
#
# First, we create a callback method, that will be called every time a
# log machine updates its PAD. An instance of 'pypad.Update' that contains
# the PAD information is supplied as the single argument.
#
def ProcessPad(update):
print()
if update.hasPadType(pypad.TYPE_NOW):
msg='%03d:' % update.machine()
msg+='%04d ' % update.padField(pypad.TYPE_NOW,pypad.FIELD_LINE_NUMBER)
msg+='NOW: '+update.resolvePadFields('%a - %t',pypad.ESCAPE_NONE)
print(msg)
else:
print("%03d:xxxx NOW: [none]" % update.machine())
if update.hasPadType(pypad.TYPE_NEXT):
msg='%03d:' % update.machine()
msg+='%04d ' % update.padField(pypad.TYPE_NEXT,pypad.FIELD_LINE_NUMBER)
msg+='NEXT: '+update.resolvePadFields('%A - %T',pypad.ESCAPE_NONE)
print(msg)
else:
print("%03d:xxxx NEXT: [none]" % update.machine())
#
# Create an instance of 'pypadReceiver'
#
rcvr=pypad.Receiver()
#
# Tell it to use the callback
#
rcvr.setCallback(ProcessPad)
#
# Start the receiver, giving it the hostname or IP address and TCP port of
# the target Rivendell system. Once started, all further processing can only
# be done in the callback method!
#
rcvr.start('localhost',pypad.PAD_TCP_PORT)

151
apis/pypad/tests/pad_test.py Executable file
View File

@@ -0,0 +1,151 @@
#!%PYTHON_BANGPATH%
# pad_test.py
#
# pypad regression test script for Rivendell
#
# Exercise every PAD accessor method of 'pypad.Update' for each update.
#
# (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 pypad
def ProcessPad(update):
print
print('*** Log %03d Update ***********************************************' % update.machine())
print('** HEADER INFO **')
print(' dateTime(): '+update.dateTime().isoformat(' '))
print(' hostName(): '+update.hostName())
print(' shortHostName(): '+update.shortHostName())
print(' machine(): %d' % update.machine())
print( ' mode(): '+update.mode())
print(' onairFlag(): '+str(update.onairFlag()))
print
if update.hasLog():
print('** LOG INFO **')
print(' logName(): '+update.logName())
print()
else:
print('**NO LOG INFO PRESENT**')
print()
if update.hasService():
print('** SERVICE INFO **')
print(' serviceName(): '+update.serviceName())
print('serviceDescription(): '+update.serviceDescription())
print('serviceProgramCode(): '+update.serviceProgramCode())
print()
else:
print('** NO SERVICE INFO PRESENT **')
print()
if update.hasPadType(pypad.TYPE_NOW):
print('** NOW PLAYING INFO **')
try:
print(' startDateTime(): '+update.startDateTime(pypad.TYPE_NOW).isoformat(' '))
except AttributeError:
print(' startDateTime(): None')
print(' lineNumber(): '+str(update.padField(pypad.TYPE_NOW,pypad.FIELD_LINE_NUMBER))+'/'+update.resolvePadFields('%z',pypad.ESCAPE_NONE))
print(' lineId(): '+str(update.padField(pypad.TYPE_NOW,pypad.FIELD_LINE_ID))+'/'+update.resolvePadFields('%x',pypad.ESCAPE_NONE))
print(' cartType(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_CART_TYPE))
print(' cartNumber(): %u / ' % update.padField(pypad.TYPE_NOW,pypad.FIELD_CART_NUMBER)+update.resolvePadFields("%n",pypad.ESCAPE_NONE))
print(' cutNumber(): %u / ' % update.padField(pypad.TYPE_NOW,pypad.FIELD_CUT_NUMBER)+update.resolvePadFields("%j",pypad.ESCAPE_NONE))
print(' length(): %u / ' % update.padField(pypad.TYPE_NOW,pypad.FIELD_LENGTH)+update.resolvePadFields("%h",pypad.ESCAPE_NONE))
try:
print(' year(): %u / ' % update.padField(pypad.TYPE_NOW,pypad.FIELD_YEAR)+update.resolvePadFields("%y",pypad.ESCAPE_NONE))
except TypeError:
print(' year(): None / '+update.resolvePadFields("%Y",pypad.ESCAPE_NONE))
print(' groupName(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_GROUP_NAME)+' / '+update.resolvePadFields('%g',pypad.ESCAPE_NONE))
print(' title(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_TITLE)+' / '+update.resolvePadFields('%t',pypad.ESCAPE_NONE))
print(' artist(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_ARTIST)+' / '+update.resolvePadFields('%a',pypad.ESCAPE_NONE))
print(' publisher(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_PUBLISHER)+' / '+update.resolvePadFields('%p',pypad.ESCAPE_NONE))
print(' composer(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_COMPOSER)+' / '+update.resolvePadFields('%m',pypad.ESCAPE_NONE))
print(' album(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_ALBUM)+' / '+update.resolvePadFields('%l',pypad.ESCAPE_NONE))
print(' label(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_LABEL)+' / '+update.resolvePadFields('%b',pypad.ESCAPE_NONE))
print(' client(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_CLIENT)+' / '+update.resolvePadFields('%c',pypad.ESCAPE_NONE))
print(' agency(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_AGENCY)+' / '+update.resolvePadFields('%e',pypad.ESCAPE_NONE))
print(' conductor(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_CONDUCTOR)+' / '+update.resolvePadFields('%r',pypad.ESCAPE_NONE))
print(' userDefined(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_USER_DEFINED)+' / '+update.resolvePadFields('%u',pypad.ESCAPE_NONE))
print(' songId(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_SONG_ID)+' / '+update.resolvePadFields('%s',pypad.ESCAPE_NONE))
print(' outcue(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_OUTCUE)+' / '+update.resolvePadFields('%o',pypad.ESCAPE_NONE))
print(' description(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_DESCRIPTION)+' / '+update.resolvePadFields('%i',pypad.ESCAPE_NONE))
print(' externalEventId(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_EXTERNAL_EVENT_ID))
print(' externalData(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_EXTERNAL_DATA))
print(' externalAnncType(): '+update.padField(pypad.TYPE_NOW,pypad.FIELD_EXTERNAL_EVENT_ID))
print()
else:
print('** NO NOW PLAYING INFO **')
print()
if update.hasPadType(pypad.TYPE_NEXT):
print('** NEXT PLAYING INFO **')
try:
print(' startDateTime(): '+update.startDateTime(pypad.TYPE_NEXT).isoformat(' '))
except AttributeError:
print(' startDateTime(): None')
print(' lineNumber(): '+str(update.padField(pypad.TYPE_NEXT,pypad.FIELD_LINE_NUMBER))+'/'+update.resolvePadFields('%Z',pypad.ESCAPE_NONE))
print(' lineId(): '+str(update.padField(pypad.TYPE_NEXT,pypad.FIELD_LINE_ID))+'/'+update.resolvePadFields('%X',pypad.ESCAPE_NONE))
print(' cartType(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_CART_TYPE))
print(' cartNumber(): %u / ' % update.padField(pypad.TYPE_NEXT,pypad.FIELD_CART_NUMBER)+update.resolvePadFields("%N",pypad.ESCAPE_NONE))
print(' cutNumber(): %u / ' % update.padField(pypad.TYPE_NEXT,pypad.FIELD_CUT_NUMBER)+update.resolvePadFields("%J",pypad.ESCAPE_NONE))
print(' length(): %u / ' % update.padField(pypad.TYPE_NEXT,pypad.FIELD_LENGTH)+update.resolvePadFields("%H",pypad.ESCAPE_NONE))
try:
print(' year(): %u / ' % update.padField(pypad.TYPE_NEXT,pypad.FIELD_YEAR)+update.resolvePadFields("%Y",pypad.ESCAPE_NONE))
except TypeError:
print(' year(): None / '+update.resolvePadFields("%Y",pypad.ESCAPE_NONE))
print(' groupName(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_GROUP_NAME)+' / '+update.resolvePadFields('%G',pypad.ESCAPE_NONE))
print(' title(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_TITLE)+' / '+update.resolvePadFields('%T',pypad.ESCAPE_NONE))
print(' artist(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_ARTIST)+' / '+update.resolvePadFields('%A',pypad.ESCAPE_NONE))
print(' publisher(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_PUBLISHER)+' / '+update.resolvePadFields('%P',pypad.ESCAPE_NONE))
print(' composer(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_COMPOSER)+' / '+update.resolvePadFields('%M',pypad.ESCAPE_NONE))
print(' album(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_ALBUM)+' / '+update.resolvePadFields('%L',pypad.ESCAPE_NONE))
print(' label(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_LABEL)+' / '+update.resolvePadFields('%B',pypad.ESCAPE_NONE))
print(' client(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_CLIENT)+' / '+update.resolvePadFields('%C',pypad.ESCAPE_NONE))
print(' agency(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_AGENCY)+' / '+update.resolvePadFields('%E',pypad.ESCAPE_NONE))
print(' conductor(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_CONDUCTOR)+' / '+update.resolvePadFields('%R',pypad.ESCAPE_NONE))
print(' userDefined(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_USER_DEFINED)+' / '+update.resolvePadFields('%U',pypad.ESCAPE_NONE))
print(' songId(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_SONG_ID)+' / '+update.resolvePadFields('%S',pypad.ESCAPE_NONE))
print(' outcue(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_OUTCUE)+' / '+update.resolvePadFields('%O',pypad.ESCAPE_NONE))
print(' description(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_DESCRIPTION)+' / '+update.resolvePadFields('%I',pypad.ESCAPE_NONE))
print(' externalEventId(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_EXTERNAL_EVENT_ID))
print(' externalData(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_EXTERNAL_DATA))
print(' externalAnncType(): '+update.padField(pypad.TYPE_NEXT,pypad.FIELD_EXTERNAL_EVENT_ID))
print()
else:
print('** NO NEXT PLAYING INFO **')
print()
print ('******************************************************************')
#
# Create an instance of 'pypad.Receiver'
#
rcvr=pypad.Receiver()
#
# Tell it to use the callback
#
rcvr.setCallback(ProcessPad)
#
# Start the receiver, giving it the hostname or IP address and TCP port of
# the target Rivendell system. Once started, all further processing can only
# be done in the callback method!
#
rcvr.start('localhost',pypad.PAD_TCP_PORT)