mirror of
				https://github.com/ElvishArtisan/rivendell.git
				synced 2025-10-30 17:23:53 +01:00 
			
		
		
		
	2018-12-17 Fred Gleason <fredg@paravelsystems.com>
* Renamed the RD_RLM2_CLIENT_TCP_PORT define to RD_PAD_CLIENT_TCP_PORT. * Renamed the RD_RLM_SOURCE_UNIX_ADDRESS define to RD_PAD_SOURCE_UNIX_ADDRESS. * Added a RD_PYPAD_SCRIPT_DIR define. * Added an 'RDNotification::PypadType' value to the 'RDNotification::Type' enumeration. * Added 'PypadOwner=' and 'PypadGroup=' directives to the '[Identity]' section of rd.conf(5). * Added an rdpadengined(8) service. * Added a 'PYPAD_INSTANCES.IS_RUNNING' field to the database. * Added a 'PYPAD_INSTANCES.EXIT_CODE' field to the database. * Added a 'PYPAD_INSTANCES.ERROR_TEXT' field to the database. * Incremented the database version to 304.
This commit is contained in:
		
							
								
								
									
										54
									
								
								apis/PyPAD/scripts/Makefile.am
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								apis/PyPAD/scripts/Makefile.am
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | ||||
| ## automake.am | ||||
| ## | ||||
| ## Automake.am for Rivendell PyPAD/examples | ||||
| ## | ||||
| ##   (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 | ||||
|  | ||||
| install-exec-am:	 | ||||
| 	mkdir -p $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD | ||||
| 	../../../helpers/install_python.sh pypad_filewrite.py $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_filewrite.py | ||||
| 	cp pypad_filewrite.exemplar $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_filewrite.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 | ||||
|  | ||||
| uninstall-local:	 | ||||
| 	rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_filewrite.exemplar | ||||
| 	rm -f $(DESTDIR)$(prefix)/@RD_LIB_PATH@/rivendell/PyPAD/pypad_filewrite.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 | ||||
|  | ||||
| EXTRA_DIST = pypad_filewrite.exemplar\ | ||||
|              pypad_filewrite.py\ | ||||
|              pypad_udp.exemplar\ | ||||
|              pypad_udp.py | ||||
|  | ||||
| CLEANFILES = *~\ | ||||
|              *.idb\ | ||||
|              *ilk\ | ||||
|              *.obj\ | ||||
|              *.pdb\ | ||||
|              *.qm\ | ||||
|              moc_* | ||||
|  | ||||
| MAINTAINERCLEANFILES = *~\ | ||||
|                        *.tar.gz\ | ||||
|                        aclocal.m4\ | ||||
|                        configure\ | ||||
|                        Makefile.in\ | ||||
|                        moc_* | ||||
							
								
								
									
										101
									
								
								apis/PyPAD/scripts/pypad_filewrite.exemplar
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								apis/PyPAD/scripts/pypad_filewrite.exemplar
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,101 @@ | ||||
| ; This is the sample configuration for the 'pypad_filewrite.py' PyPAD script | ||||
| ; for Rivendell, which can be used to write one or more files on the local  | ||||
| ; system using Now & Next data. | ||||
| ; | ||||
|  | ||||
| ; Section Header | ||||
| ; | ||||
| ; One section per file to be written should be configured, starting with  | ||||
| ; 'File1' and working up consecutively | ||||
| [File1] | ||||
|  | ||||
| ; Filename | ||||
| ; | ||||
| ; The full path to the file to be written.  The filename may contain filepath | ||||
| ; wildcards as defined in Appendix C of the Rivendell Operations and | ||||
| ; Administration Guide.  The user running RDAirPlay must have write | ||||
| ; permissions for this location. | ||||
| Filename=/tmp/rlm_filewrite.txt | ||||
|  | ||||
| ; Append Mode | ||||
| ; | ||||
| ; If set to '0', the file will be completely overwritten with the contents | ||||
| ; of each PAD update.  If set to '1', each update will be appended to the | ||||
| ; existing contents of the file. | ||||
| Append=0 | ||||
|  | ||||
| ; 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=NOW: %d(ddd MMM d hh:mm:ss yyyy): %t - %a\nNEXT: %D(ddd MMM d hh:mm:ss yyyy): %T - %A\n | ||||
|  | ||||
| ; Encoding.  Defines the set of escapes to be applied to the PAD fields. | ||||
| ; The following options are available: | ||||
| ; | ||||
| ;  0 - Perform no character escaping. | ||||
| ;  1 - "XML" escaping: Escape reserved characters as per XML-v1.0 | ||||
| ;  2 - "Web" escaping: Escape reserved characters as per RFC 2396 Section 2.4 | ||||
| Encoding=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.  If set to 'Onair', then | ||||
| ; output will be generated only if RDAirPlays 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 files can be written by adding new sections... | ||||
| ; | ||||
| ;[File2] | ||||
| ;Filename=/home/rd/foo2.txt | ||||
| ;Append=1 | ||||
| ;FormatString=%t by %a\r\n | ||||
| ;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 | ||||
							
								
								
									
										58
									
								
								apis/PyPAD/scripts/pypad_filewrite.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										58
									
								
								apis/PyPAD/scripts/pypad_filewrite.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| #!%PYTHON_BANGPATH% | ||||
|  | ||||
| # pypad_filewrite.py | ||||
| # | ||||
| # Write PAD updates to files | ||||
| # | ||||
| #   (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 configparser | ||||
| import PyPAD | ||||
|  | ||||
| def eprint(*args,**kwargs): | ||||
|     print(*args,file=sys.stderr,**kwargs) | ||||
|  | ||||
| def ProcessPad(update): | ||||
|     n=1 | ||||
|     try: | ||||
|         while(True): | ||||
|             section='File'+str(n) | ||||
|             if update.shouldBeProcessed(section): | ||||
|                 fmtstr=update.config().get(section,'FormatString') | ||||
|                 mode='w' | ||||
|                 if update.config().get(section,'Append')=='1': | ||||
|                     mode='a' | ||||
|                 f=open(update.resolveFilepath(update.config().get(section,'Filename'),update.dateTime()),mode) | ||||
|                 f.write(update.resolvePadFields(fmtstr,int(update.config().get(section,'Encoding')))) | ||||
|                 f.close() | ||||
|             n=n+1 | ||||
|  | ||||
|     except configparser.NoSectionError: | ||||
|         return | ||||
|  | ||||
| # | ||||
| # 'Main' function | ||||
| # | ||||
| rcvr=PyPAD.Receiver() | ||||
| try: | ||||
|     rcvr.setConfigFile(sys.argv[3]) | ||||
| except IndexError: | ||||
|     eprint('pypad_filewrite.py: you must specify a configuration file') | ||||
|     sys.exit(1) | ||||
| rcvr.setCallback(ProcessPad) | ||||
| rcvr.start(sys.argv[1],int(sys.argv[2])) | ||||
							
								
								
									
										105
									
								
								apis/PyPAD/scripts/pypad_udp.exemplar
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								apis/PyPAD/scripts/pypad_udp.exemplar
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,105 @@ | ||||
| ; This is the sample configuration for the 'pypad_udp.py' PyPAD script for  | ||||
| ; Rivendell, which can be used to output Now & Next data to one or more | ||||
| ; remote UDP ports. | ||||
|  | ||||
| ; Section Header | ||||
| ; | ||||
| ; One section per remote UDP port is configured, starting with 'Udp1' and  | ||||
| ; working up consecutively | ||||
| [Udp1] | ||||
|  | ||||
| ; IP Address | ||||
| ; | ||||
| ; The IP address of the remote UDP port, in dotted-quad notation. | ||||
| IpAddress=127.0.0.1 | ||||
|  | ||||
| ; UDP Port | ||||
| ; | ||||
| ; The UDP port number of the remote UDP port, in the range 0 - 65,535. | ||||
| UdpPort=1234 | ||||
|  | ||||
| ; 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=NOW: %d(ddd MMM d hh:mm:ss yyyy): %t - %a\nNEXT: %D(ddd MMM d hh:mm:ss yyyy): %T - %A\n | ||||
|  | ||||
| ; Encoding.  Defines the set of escapes to be applied to the PAD fields. | ||||
| ; The following options are available: | ||||
| ; | ||||
| ;  0 - Perform no character escaping. | ||||
| ;  1 - "XML" escaping: Escape reserved characters as per XML-v1.0 | ||||
| ;  2 - "Web" escaping: Escape reserved characters as per RFC 2396 Section 2.4 | ||||
| Encoding=0 | ||||
|  | ||||
| ; Null Update Handling.  Defines how 'null' updates --i.e. those with a cart | ||||
| ; number of '0' -- should be handled. | ||||
| ; | ||||
| ;  0 - Process all updates regardless of cart values. | ||||
| ;  1 - Process update only if the 'now' cart is not null. | ||||
| ;  2 - Process update only if the 'next' cart is not null. | ||||
| ;  3 - Process update only if both the 'now' and 'next' carts are not null. | ||||
| ProcessNullUpdates=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 RDAirPlays 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 UDP destinations can be configured by adding new sections... | ||||
| ;[Udp2] | ||||
| ;FormatString=Artist: %a%r | ||||
| ;IpAddress=192.168.10.22 | ||||
| ;UdpPort=6789 | ||||
| ;ProcessNullUpdates=0 | ||||
| ;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 | ||||
							
								
								
									
										58
									
								
								apis/PyPAD/scripts/pypad_udp.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										58
									
								
								apis/PyPAD/scripts/pypad_udp.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| #!%PYTHON_BANGPATH% | ||||
|  | ||||
| # pypad_udp.py | ||||
| # | ||||
| # Send PAD updates via UDP | ||||
| # | ||||
| #   (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 | ||||
|  | ||||
| def eprint(*args,**kwargs): | ||||
|     print(*args,file=sys.stderr,**kwargs) | ||||
|  | ||||
| def ProcessPad(update): | ||||
|     n=1 | ||||
|     while(True): | ||||
|         section='Udp'+str(n) | ||||
|         try: | ||||
|             if update.shouldBeProcessed(section): | ||||
|                 fmtstr=update.config().get(section,'FormatString') | ||||
|                 send_sock.sendto(update.resolvePadFields(fmtstr,int(update.config().get(section,'Encoding'))).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_udp.py: you must specify a configuration file') | ||||
|     sys.exit(1) | ||||
| rcvr.setCallback(ProcessPad) | ||||
| rcvr.start(sys.argv[1],int(sys.argv[2])) | ||||
		Reference in New Issue
	
	Block a user