def output_json(svc_msg, service_types):
"""
Writes output results to a file
"""
global DATA2
outfname = 'device-scanner.json'
DATA2 = DATA2 + [{'serverid': svc_msg.getServerId(),
'devicename': svc_msg.getDeviceName(),
'devicedescription': svc_msg.getDeviceDescription(),
'hostname': svc_msg.getHostname(),
'portnumber': svc_msg.getPortNumber(),
'urlprefix': svc_msg.getUrlPrefix(),
'servicetypes': service_types,
}]
try:
with open(outfname, 'w') as outfile:
json.dump(DATA2, outfile)
except Exception:
print("You need to configure the webserver path" +
" if you want to output json")
评论列表
文章目录