<s> '''<STR_LIT>''' <EOL> import xmlrpclib <EOL> import socket <EOL> import json <EOL> from django . http import HttpResponse <EOL> from django . conf import settings <EOL> def xmlrpc ( request ) : <EOL> url = settings . NAGIOS_XMLRPC_URL <EOL> command = request . GET . get ( '<STR_LIT>' ) <EOL> args = request . GET . get ( '<STR_LIT:args>' ) <EOL> if args : <EOL> args = json . loads ( args ) <EOL> else : <EOL> args = [ ] <EOL> socket . setdefaulttimeout ( <NUM_LIT:10> ) <EOL> try : <EOL> server = xmlrpclib . ServerProxy ( url ) <EOL> result = getattr ( server , command ) ( * args ) <EOL> return HttpResponse ( repr ( result ) ) <EOL> except xmlrpclib . Fault , ex : <EOL> return HttpResponse ( '<STR_LIT>' % ex . faultString , status = <NUM_LIT> ) <EOL> except xmlrpclib . Error , ex : <EOL> return HttpResponse ( '<STR_LIT>' % ex , status = <NUM_LIT> ) <EOL> except socket . error , ex : <EOL> return HttpResponse ( '<STR_LIT>' % ex , status = <NUM_LIT> ) </s>
