2019-08-26 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in the 'pypad_urlwrite.py' PyPAD script that caused
	an infinite loop.
This commit is contained in:
Fred Gleason 2019-08-27 18:44:31 -04:00
parent 22b9679783
commit 6fceb27c2f
2 changed files with 21 additions and 20 deletions

View File

@ -19012,3 +19012,6 @@
2019-08-26 Fred Gleason <fredg@paravelsystems.com> 2019-08-26 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in the 'pypad_udp.py' PyPAD script that caused * Fixed a bug in the 'pypad_udp.py' PyPAD script that caused
an infinite loop. an infinite loop.
2019-08-26 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in the 'pypad_urlwrite.py' PyPAD script that caused
an infinite loop.

View File

@ -32,27 +32,25 @@ def eprint(*args,**kwargs):
def ProcessPad(update): def ProcessPad(update):
n=1 n=1
try: section='Url'+str(n)
while(True): while(update.config().has_section(section)):
section='Url'+str(n) if update.shouldBeProcessed(section):
if update.shouldBeProcessed(section): fmtstr=update.config().get(section,'FormatString')
fmtstr=update.config().get(section,'FormatString') buf=BytesIO(update.resolvePadFields(fmtstr,int(update.config().get(section,'Encoding'))).encode('utf-8'))
buf=BytesIO(update.resolvePadFields(fmtstr,int(update.config().get(section,'Encoding'))).encode('utf-8')) curl=pycurl.Curl()
curl=pycurl.Curl() curl.setopt(curl.URL,update.resolveFilepath(update.config().get(section,'Url'),update.dateTime()))
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.USERNAME,update.config().get(section,'Username')) curl.setopt(curl.PASSWORD,update.config().get(section,'Password'))
curl.setopt(curl.PASSWORD,update.config().get(section,'Password')) curl.setopt(curl.UPLOAD,True)
curl.setopt(curl.UPLOAD,True) curl.setopt(curl.READDATA,buf)
curl.setopt(curl.READDATA,buf) try:
try: curl.perform()
curl.perform() except pycurl.error:
except pycurl.error: update.syslog(syslog.LOG_WARNING,'['+section+'] failed: '+curl.errstr())
update.syslog(syslog.LOG_WARNING,'['+section+'] failed: '+curl.errstr()) curl.close()
curl.close() n=n+1
n=n+1 section='Url'+str(n)
except configparser.NoSectionError:
return
# #
# 'Main' function # 'Main' function