def write_stats_verbose(self): """ give a bit more info than write_stats """ self.msgstatstxt.delete(1.0, tkinter.END) self.shiptypestxt.delete(1.0, tkinter.END) self.flagstxt.delete(1.0, tkinter.END) stats = self.tabs.window.aistracker.tracker_stats() self.msgstatstxt.insert( tkinter.INSERT, export.create_summary_text(stats['Message Stats'])) self.shiptypestxt.insert( tkinter.INSERT, export.create_summary_text(stats['Ship Types'])) self.flagstxt.insert( tkinter.INSERT, export.create_summary_text(stats['Country Flags']))
def on_tree_item_doubleclick(self, event): """ open a message box with further details when a user double clicks a message """ item = self.tree.identify('item', event.x, event.y) clickedmsgno = self.tree.item(item)['values'][0] clickednmea = self.tree.item(item)['values'][1] messagewindow = MessageWindow(self.tabs.window) msgsummary = export.create_summary_text( self.tabs.window.messagelog.messagedict[(clickedmsgno, clickednmea)].__dict__) messagewindow.msgdetailsbox.append_text(msgsummary)
def show_stn_info(self): """ show individual station info """ self.stntxt.delete(1.0, tkinter.END) dropdowntext = self.stnoptions.get() if dropdowntext != '': try: lookupmmsi = self.stnlookup[dropdowntext] stninfo = export.create_summary_text( self.tabs.window.aistracker.stations[lookupmmsi]. get_station_info()) self.stntxt.insert(tkinter.INSERT, stninfo) except KeyError: tkinter.messagebox.showerror( 'Station Info', 'no data for MMSI - {}'.format(dropdowntext))
def test_text_summary(self): """ feed in a dictionary and see if the str output from the text summary method matches our expected output string """ testdict = { 'AIS Stats': { 'Total Unique Stations': 2, 'Total Messages Processed': 15, 'Message Stats': { 'Type 3 - Position Report Class A': 13, 'Type 5 - Static and Voyage Related Data': 2 }, 'AIS Station Types': { 'Class A': 2 }, 'Ship Types': { 'Cargo, all ships of this type': 2 }, 'Country Flags': { 'Bahamas': 1, 'Netherlands': 1 }, 'Times': 'No time data available.' }, 'NMEA Stats': { 'Total Sentences Processed': 17, 'Multipart Messages Reassembled': 2, 'Messages Recieved on Channel': { 'A': 13, 'B': 4 } } } expectedstr = r""" AIS Stats: Total Unique Stations: 2 Total Messages Processed: 15 Message Stats: Type 3 - Position Report Class A: 13 Type 5 - Static and Voyage Related Data: 2 AIS Station Types: Class A: 2 Ship Types: Cargo all ships of this type: 2 Country Flags: Bahamas: 1 Netherlands: 1 Times: No time data available. NMEA Stats: Total Sentences Processed: 17 Multipart Messages Reassembled: 2 Messages Recieved on Channel: A: 13 B: 4 """ testresult = export.create_summary_text(testdict) self.assertEqual(testresult, expectedstr)