Skip to content

Commit

Permalink
change prints to loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Jan 24, 2025
1 parent 691e905 commit 831b6ff
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions wsdiscovery/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from .actions import *
from xml.dom import minidom

import logging

logger = logging.getLogger(__name__)

def createSOAPMessage(env):
"serialize SOAP envelopes into XML strings"
Expand All @@ -27,17 +30,17 @@ def parseSOAPMessage(data, ipAddr):
"deserialize XML message strings into SOAP envelope objects"
try:
dom = minidom.parseString(data)
except Exception:
#print('Failed to parse message from %s\n"%s": %s' % (ipAddr, data, ex), file=sys.stderr)
except Exception as ex:
logger.debug('Failed to parse message from %s\n"%s": %s', ipAddr, data, ex)
return None

if dom.getElementsByTagNameNS(NS_SOAPENV, "Fault"):
#print('Fault received from %s %s:' % (ipAddr, data), file=sys.stderr)
logger.debug('Fault received from %s: "%s"', ipAddr, data)
return None

actions = dom.getElementsByTagNameNS(NS_ADDRESSING, "Action")
if len(actions) == 0:
#print('No action received from %s %s' % (ipAddr, data), file=sys.stderr)
logger.warning('No action received from %s: "%s"', ipAddr, data)
return None

soapAction = actions[0].firstChild.data.strip()
Expand Down

0 comments on commit 831b6ff

Please sign in to comment.