def get_from_db(self): """Getting results from database""" from umit.core.UmitDB import UmitDB # change when this module is ok db = UmitDB() self.db_data = {} for scan in db.get_scans(): #creating temporary file to store nmap xml temp_file = TemporaryFile() temp_file.write(scan.nmap_xml_output) #temp_file.seek(0) #---> really need this? try: parsed = NmapParser() parsed.set_xml_file(temp_file) parsed.parse() self.db_data[parsed.get_target()] = \ ((u'ip',parsed.get_hosts()[0].get_hostname()), (u'date', parsed.get_formated_date()), (u'nmap_command', parsed.get_nmap_command()), (u'num_open_ports', parsed.get_open_ports()), (u'ports', parsed.get_ports()), (u'profile_name', parsed.get_profile_name()), (u'stats', parsed.get_runstats()), ) # Remove temporary file reference parsed.nmap_xml_file = "" temp_file.close() except IndexError: #log the error #TODO: fix the bug with reg without ip pass del db return self.db_data