From d3e3e708f1bf2fb8927bab337ee1e8a52cd6efd6 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Tue, 27 Aug 2019 17:56:25 -0400 Subject: [PATCH] 2019-08-26 Fred Gleason * Fixed a bug in the 'pypad_live365.py' PyPAD script that caused an infinite loop. --- ChangeLog | 3 ++ apis/pypad/scripts/pypad_live365.py | 52 ++++++++++++++--------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index d56f3858..94e1aa62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18994,3 +18994,6 @@ 2019-08-26 Fred Gleason * Fixed a bug in the 'pypad_liqcomp.py' PyPAD script that caused an infinite loop. +2019-08-26 Fred Gleason + * Fixed a bug in the 'pypad_live365.py' PyPAD script that caused + an infinite loop. diff --git a/apis/pypad/scripts/pypad_live365.py b/apis/pypad/scripts/pypad_live365.py index c154a26e..e3c0781d 100755 --- a/apis/pypad/scripts/pypad_live365.py +++ b/apis/pypad/scripts/pypad_live365.py @@ -32,34 +32,32 @@ def eprint(*args,**kwargs): def ProcessPad(update): n=1 - try: - while(True): - section='Station'+str(n) - if update.shouldBeProcessed(section) and update.hasPadType(pypad.TYPE_NOW): - member=update.escape(update.config().get(section,'MemberName'),pypad.ESCAPE_URL) - password=update.escape(update.config().get(section,'Password'),pypad.ESCAPE_URL) - title=update.resolvePadFields(update.config().get(section,'TitleString'),pypad.ESCAPE_URL) - artist=update.resolvePadFields(update.config().get(section,'ArtistString'),pypad.ESCAPE_URL) - album=update.resolvePadFields(update.config().get(section,'AlbumString'),pypad.ESCAPE_URL) - seconds=str(update.padField(pypad.TYPE_NOW,pypad.FIELD_LENGTH)//1000) - buf=BytesIO() - curl=pycurl.Curl() - url='http://www.live365.com/cgi-bin/add_song.cgi?member_name='+member+'&password='+password+'&version=2&filename=Rivendell&seconds='+seconds+'&title='+title+'&artist='+artist+'&album='+album - curl.setopt(curl.URL,url) - curl.setopt(curl.WRITEDATA,buf) - curl.setopt(curl.FOLLOWLOCATION,True) - try: - curl.perform() - code=curl.getinfo(pycurl.RESPONSE_CODE) - if (code<200) or (code>=300): - update.syslog(syslog.LOG_WARNING,'['+section+'] returned response code '+str(code)) - except pycurl.error: - update.syslog(syslog.LOG_WARNING,'['+section+'] failed: '+curl.errstr()) - curl.close() - n=n+1 + section='Station'+str(n) + while(True): + if update.shouldBeProcessed(section) and update.hasPadType(pypad.TYPE_NOW): + member=update.escape(update.config().get(section,'MemberName'),pypad.ESCAPE_URL) + password=update.escape(update.config().get(section,'Password'),pypad.ESCAPE_URL) + title=update.resolvePadFields(update.config().get(section,'TitleString'),pypad.ESCAPE_URL) + artist=update.resolvePadFields(update.config().get(section,'ArtistString'),pypad.ESCAPE_URL) + album=update.resolvePadFields(update.config().get(section,'AlbumString'),pypad.ESCAPE_URL) + seconds=str(update.padField(pypad.TYPE_NOW,pypad.FIELD_LENGTH)//1000) + buf=BytesIO() + curl=pycurl.Curl() + url='http://www.live365.com/cgi-bin/add_song.cgi?member_name='+member+'&password='+password+'&version=2&filename=Rivendell&seconds='+seconds+'&title='+title+'&artist='+artist+'&album='+album + curl.setopt(curl.URL,url) + curl.setopt(curl.WRITEDATA,buf) + curl.setopt(curl.FOLLOWLOCATION,True) + try: + curl.perform() + code=curl.getinfo(pycurl.RESPONSE_CODE) + if (code<200) or (code>=300): + update.syslog(syslog.LOG_WARNING,'['+section+'] returned response code '+str(code)) + except pycurl.error: + update.syslog(syslog.LOG_WARNING,'['+section+'] failed: '+curl.errstr()) + curl.close() + n=n+1 + section='Station'+str(n) - except configparser.NoSectionError: - return # # 'Main' function