From 6fceb27c2f24bbdaf5b56fef8127b4d19ad2d076 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Tue, 27 Aug 2019 18:44:31 -0400 Subject: [PATCH] 2019-08-26 Fred Gleason * Fixed a bug in the 'pypad_urlwrite.py' PyPAD script that caused an infinite loop. --- ChangeLog | 3 +++ apis/pypad/scripts/pypad_urlwrite.py | 38 +++++++++++++--------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d56e647..e5450a6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19012,3 +19012,6 @@ 2019-08-26 Fred Gleason * Fixed a bug in the 'pypad_udp.py' PyPAD script that caused an infinite loop. +2019-08-26 Fred Gleason + * Fixed a bug in the 'pypad_urlwrite.py' PyPAD script that caused + an infinite loop. diff --git a/apis/pypad/scripts/pypad_urlwrite.py b/apis/pypad/scripts/pypad_urlwrite.py index 30b3e845..56f6d6d1 100755 --- a/apis/pypad/scripts/pypad_urlwrite.py +++ b/apis/pypad/scripts/pypad_urlwrite.py @@ -32,27 +32,25 @@ def eprint(*args,**kwargs): def ProcessPad(update): n=1 - try: - while(True): - section='Url'+str(n) - if update.shouldBeProcessed(section): - fmtstr=update.config().get(section,'FormatString') - buf=BytesIO(update.resolvePadFields(fmtstr,int(update.config().get(section,'Encoding'))).encode('utf-8')) - curl=pycurl.Curl() - curl.setopt(curl.URL,update.resolveFilepath(update.config().get(section,'Url'),update.dateTime())) - curl.setopt(curl.USERNAME,update.config().get(section,'Username')) - curl.setopt(curl.PASSWORD,update.config().get(section,'Password')) - curl.setopt(curl.UPLOAD,True) - curl.setopt(curl.READDATA,buf) - try: - curl.perform() - except pycurl.error: - update.syslog(syslog.LOG_WARNING,'['+section+'] failed: '+curl.errstr()) - curl.close() - n=n+1 + section='Url'+str(n) + while(update.config().has_section(section)): + if update.shouldBeProcessed(section): + fmtstr=update.config().get(section,'FormatString') + buf=BytesIO(update.resolvePadFields(fmtstr,int(update.config().get(section,'Encoding'))).encode('utf-8')) + curl=pycurl.Curl() + curl.setopt(curl.URL,update.resolveFilepath(update.config().get(section,'Url'),update.dateTime())) + curl.setopt(curl.USERNAME,update.config().get(section,'Username')) + curl.setopt(curl.PASSWORD,update.config().get(section,'Password')) + curl.setopt(curl.UPLOAD,True) + curl.setopt(curl.READDATA,buf) + try: + curl.perform() + except pycurl.error: + update.syslog(syslog.LOG_WARNING,'['+section+'] failed: '+curl.errstr()) + curl.close() + n=n+1 + section='Url'+str(n) - except configparser.NoSectionError: - return # # 'Main' function