2021-08-31 Fred Gleason <fredg@paravelsystems.com>

* Added support for [NowGroups] and [NextGroups] sections in
	PyPAD script configurations.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2021-08-31 14:20:27 -04:00
parent e30fe2b0b7
commit c672155788
22 changed files with 442 additions and 629 deletions

View File

@@ -2,7 +2,7 @@
#
# PAD processor for Rivendell
#
# (C) Copyright 2018-2020 Fred Gleason <fredg@paravelsystems.com>
# (C) Copyright 2018-2021 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
@@ -772,7 +772,9 @@ class Receiver(object):
self.__timer_callback=None
self.__timer_interval=None
self.__config_parser=None
self.__active_now_groups=[]
self.__active_next_groups=[]
def __pypad_Process(self,pad):
self.__pad_callback(pad)
@@ -850,9 +852,26 @@ class Receiver(object):
self.__config_parser.read_file(fp)
fp.close()
# Build lists of active groups
if self.__config_parser.has_section('NowGroups'):
self.__active_now_groups=self.__loadGroups('NowGroups')
if self.__config_parser.has_section('NextGroups'):
self.__active_next_groups=self.__loadGroups('NextGroups')
return self.__config_parser
def __loadGroups(self,section):
grp_list=[]
grp_num=1
line='Group'+str(grp_num)
while(self.__config_parser.has_option(section,line)):
grp_list.append(self.__config_parser.get(section,line))
grp_num=grp_num+1
line='Group'+str(grp_num)
return grp_list
def start(self,hostname,port):
"""
Connect to a Rivendell system and begin processing PAD events.
@@ -906,7 +925,9 @@ class Receiver(object):
linebytes=line.decode('utf-8','replace')
msg+=linebytes
if linebytes=='\r\n':
self.__pypad_Process(Update(json.loads(msg),self.__config_parser,rd_config))
jdata=json.loads(msg)
if (not self.__active_now_groups and not self.__active_next_groups) or (jdata['padUpdate'] is not None and jdata['padUpdate']['now'] is not None and jdata['padUpdate']['now']['groupName'] in self.__active_now_groups) or (jdata['padUpdate'] is not None and jdata['padUpdate']['next'] is not None and jdata['padUpdate']['next']['groupName'] in self.__active_next_groups):
self.__pypad_Process(Update(jdata,self.__config_parser,rd_config))
msg=""
line=bytes()
if self.__timer_interval!=None: