mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-26 01:15:13 +02:00
2019-08-11 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in the 'pypad.update.shouldBeProcessed()' method that caused log selection directives to be ignored. * Refactored the 'pypad_icecast2.py' script to work properly with the fixed 'pypad.update.shouldBeProcessed()' method. * Refactored the 'pypad_shoutcast2.py' script to work properly with the fixed 'pypad.update.shouldBeProcessed()' method.
This commit is contained in:
parent
987090c46f
commit
56feb08896
@ -18918,3 +18918,10 @@
|
||||
2019-08-09 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Refactored 'RDClock' to store events on the heap rather than
|
||||
on the stack.
|
||||
2019-08-11 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Fixed a bug in the 'pypad.update.shouldBeProcessed()' method
|
||||
that caused log selection directives to be ignored.
|
||||
* Refactored the 'pypad_icecast2.py' script to work properly with
|
||||
the fixed 'pypad.update.shouldBeProcessed()' method.
|
||||
* Refactored the 'pypad_shoutcast2.py' script to work properly with
|
||||
the fixed 'pypad.update.shouldBeProcessed()' method.
|
||||
|
@ -84,7 +84,6 @@ PAD_TCP_PORT=34289
|
||||
class Update(object):
|
||||
def __init__(self,pad_data,config,rd_config):
|
||||
self.__fields=pad_data
|
||||
#print('PAD: '+str(self.__fields))
|
||||
self.__config=config
|
||||
self.__rd_config=rd_config
|
||||
|
||||
@ -726,17 +725,20 @@ class Update(object):
|
||||
section - The '[<section>]' of the INI configuration from which
|
||||
to take the parameters.
|
||||
"""
|
||||
result=True
|
||||
try:
|
||||
if self.__config.get(section,'ProcessNullUpdates')=='0':
|
||||
return True
|
||||
result=result and True
|
||||
if self.__config.get(section,'ProcessNullUpdates')=='1':
|
||||
return self.hasPadType(pypad.TYPE_NOW)
|
||||
result=result and self.hasPadType(pypad.TYPE_NOW)
|
||||
if self.__config.get(section,'ProcessNullUpdates')=='2':
|
||||
return self.hasPadType(pypad.TYPE_NEXT)
|
||||
result=result and self.hasPadType(pypad.TYPE_NEXT)
|
||||
if self.__config.get(section,'ProcessNullUpdates')=='3':
|
||||
return self.hasPadType(pypad.TYPE_NOW) and self.hasPadType(pypad.TYPE_NEXT)
|
||||
result=result and self.hasPadType(pypad.TYPE_NOW) and self.hasPadType(pypad.TYPE_NEXT)
|
||||
except configparser.NoOptionError:
|
||||
return True
|
||||
result=result and True
|
||||
except configparser.NoSectionError:
|
||||
result=result and True
|
||||
|
||||
log_dict={1: 'MasterLog',2: 'Aux1Log',3: 'Aux2Log',
|
||||
101: 'VLog101',102: 'VLog102',103: 'VLog103',104: 'VLog104',
|
||||
@ -744,12 +746,21 @@ class Update(object):
|
||||
109: 'VLog109',110: 'VLog110',111: 'VLog111',112: 'VLog112',
|
||||
113: 'VLog113',114: 'VLog114',115: 'VLog115',116: 'VLog116',
|
||||
117: 'VLog117',118: 'VLog118',119: 'VLog119',120: 'VLog120'}
|
||||
if self.__config.get(section,log_dict[self.machine()]).lower()=='yes':
|
||||
return True
|
||||
if self.__config.get(section,log_dict[self.machine()]).lower()=='no':
|
||||
return False
|
||||
if self.__config.get(section,log_dict[self.machine()]).lower()=='onair':
|
||||
return self.onairFlag()
|
||||
try:
|
||||
#print('machine(): '+str(self.machine()))
|
||||
if self.__config.get(section,log_dict[self.machine()]).lower()=='yes':
|
||||
result=result and True
|
||||
if self.__config.get(section,log_dict[self.machine()]).lower()=='no':
|
||||
result=result and False
|
||||
if self.__config.get(section,log_dict[self.machine()]).lower()=='onair':
|
||||
result=result and self.onairFlag()
|
||||
except configparser.NoOptionError:
|
||||
result=result and False
|
||||
except configparser.NoSectionError:
|
||||
result=result and False
|
||||
#print('result: '+str(result))
|
||||
return result
|
||||
|
||||
|
||||
def syslog(self,priority,msg):
|
||||
"""
|
||||
|
@ -34,25 +34,37 @@ def ProcessPad(update):
|
||||
if update.hasPadType(pypad.TYPE_NOW):
|
||||
n=1
|
||||
while(True):
|
||||
#
|
||||
# First, get all of our configuration values
|
||||
#
|
||||
section='Icecast'+str(n)
|
||||
try:
|
||||
values={}
|
||||
values['mount']=update.config().get(section,'Mountpoint')
|
||||
values['song']=update.resolvePadFields(update.config().get(section,'FormatString'),pypad.ESCAPE_NONE)
|
||||
values['mode']='updinfo'
|
||||
update.syslog(syslog.LOG_INFO,'Updating '+update.config().get(section,'Hostname')+': song='+values['song'])
|
||||
url="http://%s:%s/admin/metadata" % (update.config().get(section,'Hostname'),update.config().get(section,'Tcpport'))
|
||||
try:
|
||||
response=requests.get(url,auth=HTTPBasicAuth(update.config().get(section,'Username'),update.config().get(section,'Password')),params=values)
|
||||
response.raise_for_status()
|
||||
except requests.exceptions.RequestException as e:
|
||||
update.syslog(syslog.LOG_WARNING,str(e))
|
||||
n=n+1
|
||||
hostname=update.config().get(section,'Hostname')
|
||||
tcpport=update.config().get(section,'Tcpport')
|
||||
username=update.config().get(section,'Username')
|
||||
password=update.config().get(section,'Password')
|
||||
url="http://%s:%s/admin/metadata" % (hostname,tcpport)
|
||||
except configparser.NoSectionError:
|
||||
if(n==1):
|
||||
update.syslog(syslog.LOG_WARNING,'No icecast config found')
|
||||
return
|
||||
|
||||
#
|
||||
# Now, send the update
|
||||
#
|
||||
if update.shouldBeProcessed(section):
|
||||
try:
|
||||
response=requests.get(url,auth=HTTPBasicAuth(username,password),params=values)
|
||||
response.raise_for_status()
|
||||
update.syslog(syslog.LOG_INFO,'Updating '+hostname+': song='+values['song'])
|
||||
except requests.exceptions.RequestException as e:
|
||||
update.syslog(syslog.LOG_WARNING,str(e))
|
||||
n=n+1
|
||||
|
||||
#
|
||||
# Program Name
|
||||
#
|
||||
|
@ -27,23 +27,18 @@ import pycurl
|
||||
import pypad
|
||||
from io import BytesIO
|
||||
|
||||
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
|
||||
try:
|
||||
if update.hasPadType(pypad.TYPE_NOW):
|
||||
n=1
|
||||
while(True):
|
||||
#
|
||||
# First, get all of our configuration values
|
||||
#
|
||||
section='Shoutcast'+str(n)
|
||||
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)
|
||||
try:
|
||||
song=update.resolvePadFields(update.config().get(section,'FormatString'),pypad.ESCAPE_URL)
|
||||
url='http://'+update.config().get(section,'Hostname')+':'+str(update.config().get(section,'Tcpport'))+'/admin.cgi?pass='+update.escape(update.config().get(section,'Password'),pypad.ESCAPE_URL)+'&mode=updinfo&song='+song
|
||||
curl=pycurl.Curl()
|
||||
@ -55,6 +50,13 @@ def ProcessPad(update):
|
||||
#
|
||||
headers.append('User-Agent: '+'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2')
|
||||
curl.setopt(curl.HTTPHEADER,headers);
|
||||
except configparser.NoSectionError:
|
||||
return
|
||||
|
||||
#
|
||||
# Now, send the update
|
||||
#
|
||||
if update.shouldBeProcessed(section):
|
||||
try:
|
||||
curl.perform()
|
||||
code=curl.getinfo(pycurl.RESPONSE_CODE)
|
||||
@ -65,8 +67,6 @@ def ProcessPad(update):
|
||||
curl.close()
|
||||
n=n+1
|
||||
|
||||
except configparser.NoSectionError:
|
||||
return
|
||||
|
||||
#
|
||||
# 'Main' function
|
||||
|
Loading…
x
Reference in New Issue
Block a user