Code

New function write_xml
[nagixsc.git] / nagixsc_live2xml.py
index 3e2729f12cafcbf1111a50263054f8cf9c798477..4702f95207361b548af9b0e1d3801d5ba97cd6ef 100755 (executable)
@@ -53,23 +53,5 @@ checks = livestatus2dict(s_opts, options.host, options.service)
 xmldoc = xml_from_dict(checks, options.encoding)
 
 # Output
-if options.outfile.startswith('http'):
-       (headers, body) = encode_multipart(xmldoc, options.httpuser, options.httppasswd)
-
-       try:
-               response = urllib2.urlopen(urllib2.Request(options.outfile, body, headers)).read()
-       except urllib2.HTTPError, error:
-               print error
-               sys.exit(6)
-       except urllib2.URLError, error:
-               print error.reason[1]
-               sys.exit(7)
-
-       print response
-
-elif options.outfile == '-':
-       xmldoc.saveFormatFile('-', format=1)
-
-else:
-       xmldoc.saveFile(options.outfile)
+write_xml(xmldoc, options.outfile, options.httpuser, options.httppasswd)