X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=nagixsc%2F__init__.py;h=2a93b864f6315de3a0c7bbc53a506d861962c831;hb=8ed4dffad9f52651aae67f226fbf01017330f1ea;hp=8f886ac5a9e46c8a75ddc2a2c449204199aabdc2;hpb=d0782e47659a7f7bb91c28dc5c52f010b2bd004c;p=nagixsc.git diff --git a/nagixsc/__init__.py b/nagixsc/__init__.py index 8f886ac..2a93b86 100644 --- a/nagixsc/__init__.py +++ b/nagixsc/__init__.py @@ -195,7 +195,6 @@ def dict2out_passive(checks, xmltimestamp, opt_pipe, opt_verb=0): timestamp = check['timestamp'] else: timestamp = xmltimestamp - count_services += 1 if check['service_description'] == None or check['service_description'] == '': # Host check @@ -289,23 +288,29 @@ def read_xml_from_string(content): def write_xml(xmldoc, outfile, httpuser=None, httppasswd=None): if outfile.startswith('http'): (headers, body) = encode_multipart(xmldoc, httpuser, httppasswd) - - try: - response = urllib2.urlopen(urllib2.Request(outfile, body, headers)).read() - except urllib2.HTTPError, error: - print error - sys.exit(11) - except urllib2.URLError, error: - print error.reason[1] - sys.exit(12) - - print response + response = urllib2.urlopen(urllib2.Request(outfile, body, headers)).read() + return response elif outfile == '-': xmldoc.saveFormatFile('-', format=1) + return None else: xmldoc.saveFile(outfile) + return None + + +def write_xml_or_die(xmldoc, outfile, httpuser=None, httppasswd=None): + try: + response = write_xml(xmldoc, outfile, httpuser=None, httppasswd=None) + except urllib2.HTTPError, error: + print error + sys.exit(11) + except urllib2.URLError, error: + print error.reason[1] + sys.exit(12) + + return response ##############################################################################