objects.gui.peerGridDisplay.peerGridDisplay Class Reference

Code generated by "Boa Constructor". More...

List of all members.

Public Member Functions

def __init__
def GetListCtrl
def GetSortImages
def fromEntList
 Builds the Peer List using a List of networkEntity Objects.
def fromEntGeoLocDict
 Builds the Peer List using a Dictionary of Coordinate Tuples to List of networnEntity objects.
def fromEntDict
 Builds the Peer List using a Dictionary of Coordinate Tuples to List of networnEntity objects.
def getForeignIP
 Returns the Foreign IP Address (as in what IP its connected to) of the supplied networkEntity.
def getProcName
 Returns the Process Name communicating with the supplied networkEntity.
def getPid
 Returns the Pid communicating with the supplied networkEntity.
def getISP
 Returns the ISP of the supplied networkEntity.
def getOrg
 Returns the Organization Name of the supplied networkEntity.
def addEntityToList
 Helper Function used to add a networkedEntity to the Peer List control.
def OnButtonShowTraceButton
 "Show Trace" Button Handler
def getColumnText
 Retrieves the string value of a column/index location in the Peer List.
def OnButtonReconstructButton
 "Reconstruct TCP Conversation" Button Handler (Not Implemented)
def OnListCtrlPeersListItemSelected
 "Select Peer List Item" Handler.
def OnListCtrlPeersListItemDeselected
 "Deselect Peer List Item" Handler.
def OnListCtrlPeersListColClick
 "Click on Peer List Column" Handler (not implemented).
def OnSortOrderChanged
 Called when the sort direction has changed.
def OnButtonExportListButton
 "Export to File" Button Handler (Not Implemented)

Public Attributes

 flexGridSizerControls
 flexGridSizerButtons
 panelControls
 listCtrlPeers
 buttonShowTrace
 buttonExportList
 up
 dn
 selectedPeer
 peerList
 itemDataMap
 PeerDict


Detailed Description

Code generated by "Boa Constructor".

This class should be edited using the Boa Constructor IDE. Minimal inline documentation will be provided for this class as it may interfere with the automatic code generation.

The peerGridDisplay class represents the applications's 'Peer List' window

Definition at line 86 of file peerGridDisplay.py.


Member Function Documentation

def objects.gui.peerGridDisplay.peerGridDisplay.__init__ (   self,
  parent 
)

Definition at line 218 of file peerGridDisplay.py.

00218                               :
00219         self._init_ctrls(parent)
00220         
00221         il = wx.ImageList(16,16, True)
00222         self.up = il.AddWithColourMask(
00223             wx.Bitmap(globalStrings.sort_up, wx.BITMAP_TYPE_BMP), "blue")
00224         self.dn = il.AddWithColourMask(
00225             wx.Bitmap(globalStrings.sort_down, wx.BITMAP_TYPE_BMP), "blue")
00226         
00227         # assign the image list to it
00228         self.listCtrlPeers.AssignImageList(il, wx.IMAGE_LIST_SMALL)
00229         
00230         wx.lib.mixins.listctrl.ColumnSorterMixin.__init__(self,15)
00231         
00232         self.selectedPeer = None
00233         self.peerList = []
00234         
    def GetListCtrl(self):

def objects.gui.peerGridDisplay.peerGridDisplay.addEntityToList (   self,
  ent 
)

Helper Function used to add a networkedEntity to the Peer List control.

Parameters:
ent networkedEntity object

Definition at line 317 of file peerGridDisplay.py.

00317                                   :
00318         
00319         since     = timeUtil.formatDateTime(ent.since)
00320         idleTime  = timeUtil.formatTimeDiff(time.time() - int(ent.lastUpdateTS))
00321         
00322     
00323     
00324         index = self.listCtrlPeers.InsertStringItem(sys.maxint, self.getForeignIP(ent))        
00325         self.listCtrlPeers.SetStringItem(index, 1, str(ent.foreignPort))
00326         self.listCtrlPeers.SetStringItem(index, 2, str(ent.selfPort))
00327         self.listCtrlPeers.SetStringItem(index, 3, self.getProcName(ent))
00328         self.listCtrlPeers.SetStringItem(index, 4, self.getPid(ent))
00329         self.listCtrlPeers.SetStringItem(index, 5, since)
00330         
00331         totalKB = "%6.2f" % (float(ent.totalBytes) / float(1000))
00332         self.listCtrlPeers.SetStringItem(index, 6, totalKB)
00333         
00334         try:
00335             self.listCtrlPeers.SetStringItem(index, 7, ent.foreignCity)
00336         except Exception, e:
00337             self.listCtrlPeers.SetStringItem(index, 7, "N/A")
00338             
00339         self.listCtrlPeers.SetStringItem(index, 8, str(ent.foreignStateProv))
00340         self.listCtrlPeers.SetStringItem(index, 9, str(ent.foreignCountry))            
00341         self.listCtrlPeers.SetStringItem(index, 10, self.getOrg(ent))
00342         self.listCtrlPeers.SetStringItem(index, 11, self.getISP(ent))
00343         
00344         lon = "%3.2f" % (ent.foreignLongitude)
00345         lat = "%3.2f" % (ent.foreignLatitude)
00346          
00347         self.listCtrlPeers.SetStringItem(index, 12, lon)
00348         self.listCtrlPeers.SetStringItem(index, 13, lat)
00349         
00350         self.listCtrlPeers.SetStringItem(index, 14, idleTime)                    
00351         
00352         self.listCtrlPeers.SetItemData(index, index)
00353         wrappedEnt = entityColumnSorter(ent)
00354         
00355         self.itemDataMap[index] = wrappedEnt
00356 
00357 
00358 
    ## "Show Trace" Button Handler

def objects.gui.peerGridDisplay.peerGridDisplay.fromEntDict (   self,
  entDict 
)

Builds the Peer List using a Dictionary of Coordinate Tuples to List of networnEntity objects.

Parameters:
entDict Dictionary ([lon, lat) : List(networkEntiry)]

Definition at line 271 of file peerGridDisplay.py.

00271                                   :
00272         if entDict == None: return
00273         
00274         self.PeerDict = entDict
00275         
00276         self.itemDataMap = {}
00277         
00278         for key, ent in entDict.iteritems():                        
00279             self.addEntityToList(ent)
00280             self.peerList.append(ent)
00281 
    ## Returns the Foreign IP Address (as in what IP its connected to) of the supplied networkEntity

def objects.gui.peerGridDisplay.peerGridDisplay.fromEntGeoLocDict (   self,
  entDict 
)

Builds the Peer List using a Dictionary of Coordinate Tuples to List of networnEntity objects.

Parameters:
entDict Dictionary ([lon, lat) : List(networkEntiry)]

Definition at line 256 of file peerGridDisplay.py.

00256                                         :
00257         if entDict == None: return
00258         
00259         self.PeerDict = entDict
00260     
00261         self.itemDataMap = {}
00262     
00263         for key, entList in entDict.iteritems():
00264             for ent in entList:                        
00265                 self.addEntityToList(ent)
00266                 self.peerList.append(ent)
00267     
00268     
    ## Builds the Peer List using a Dictionary of Coordinate Tuples to List of networnEntity objects

def objects.gui.peerGridDisplay.peerGridDisplay.fromEntList (   self,
  entList 
)

Builds the Peer List using a List of networkEntity Objects.

Parameters:
entList List of networkEntity Objects.

Definition at line 244 of file peerGridDisplay.py.

00244                                   :
00245         if entList == None: return
00246         
00247         self.itemDataMap = {}
00248         
00249         for ent in entList:                        
00250             self.addEntityToList(ent)
00251             self.peerList.append(ent)            
00252     
00253     
    ## Builds the Peer List using a Dictionary of Coordinate Tuples to List of networnEntity objects

def objects.gui.peerGridDisplay.peerGridDisplay.getColumnText (   self,
  index,
  col 
)

Retrieves the string value of a column/index location in the Peer List.

Parameters:
index Index number of the list
col column number
Returns:
String

Definition at line 393 of file peerGridDisplay.py.

00393                                        :
00394         item = self.listCtrlPeers.GetItem(index, col)
00395         return item.GetText()
00396     
00397     
    ## "Reconstruct TCP Conversation" Button Handler (Not Implemented)

def objects.gui.peerGridDisplay.peerGridDisplay.getForeignIP (   self,
  ent 
)

Returns the Foreign IP Address (as in what IP its connected to) of the supplied networkEntity.

Parameters:
ent networkedEntity object

Definition at line 284 of file peerGridDisplay.py.

00284                                :
00285         return ent.foreignIPAddress
00286     
00287     
00288     
    ## Returns the Process Name communicating with the supplied networkEntity

def objects.gui.peerGridDisplay.peerGridDisplay.getISP (   self,
  ent 
)

Returns the ISP of the supplied networkEntity.

Parameters:
ent networkedEntity object

Definition at line 305 of file peerGridDisplay.py.

00305                          :
00306         return ent.foreignISP
00307     
00308     
    ## Returns the Organization Name of the supplied networkEntity

def objects.gui.peerGridDisplay.peerGridDisplay.GetListCtrl (   self  ) 

Definition at line 235 of file peerGridDisplay.py.

00235                          :
00236         return self.listCtrlPeers
00237 
    def GetSortImages(self):

def objects.gui.peerGridDisplay.peerGridDisplay.getOrg (   self,
  ent 
)

Returns the Organization Name of the supplied networkEntity.

Parameters:
ent networkedEntity object

Definition at line 311 of file peerGridDisplay.py.

00311                          :
00312         return ent.foreignOrganization
00313     
00314     
    ## Helper Function used to add a networkedEntity to the Peer List control.

def objects.gui.peerGridDisplay.peerGridDisplay.getPid (   self,
  ent 
)

Returns the Pid communicating with the supplied networkEntity.

Parameters:
ent networkedEntity object

Definition at line 298 of file peerGridDisplay.py.

00298                          :
00299         return ent.Pid
00300     
00301     
00302     
    ## Returns the ISP of the supplied networkEntity

def objects.gui.peerGridDisplay.peerGridDisplay.getProcName (   self,
  ent 
)

Returns the Process Name communicating with the supplied networkEntity.

Parameters:
ent networkedEntity object

Definition at line 291 of file peerGridDisplay.py.

00291                               :
00292         return str(ent.processName)
00293     
00294     
00295     
    ## Returns the Pid communicating with the supplied networkEntity

def objects.gui.peerGridDisplay.peerGridDisplay.GetSortImages (   self  ) 

Definition at line 238 of file peerGridDisplay.py.

00238                            :
00239         return (self.dn, self.up)
00240         
00241 
    ## Builds the Peer List using a List of networkEntity Objects

def objects.gui.peerGridDisplay.peerGridDisplay.OnButtonExportListButton (   self,
  event 
)

"Export to File" Button Handler (Not Implemented)

Parameters:
event Standard wx.Button event

Definition at line 433 of file peerGridDisplay.py.

00433                                              :
00434         dlg = wx.FileDialog(self, "Export to file", "\\", "PeerList.csv", "Comma Separated Values (*.csv)|*.csv", style=wx.SAVE|wx.OVERWRITE_PROMPT)
00435         
00436         if dlg.ShowModal() == wx.ID_OK:
00437             path = dlg.GetPath()
00438             FILE = open(path,"w")
00439             FILE.write("RemoteIP,RemotePort,LocalPort,Application,PID,Since,KbXfer,City,State/Prov,Country,Organization,ISP,Lon,Lat,IdleTime\n")
00440             
00441             for ent in self.peerList:
00442                 totalKB = "%6.2f" % (float(ent.totalBytes) / float(1000))
00443                 idleTime  = timeUtil.formatTimeDiff(time.time() - int(ent.lastUpdateTS))
00444                 
00445                 since     = timeUtil.formatDateTime(ent.since)
00446                 
00447     
00448                 
00449                 try:
00450                     nextLine = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%3.2f,%3.2f,%s" %(ent.foreignIPAddress.replace(',', ' '),                                                                                      
00451                                                                                       str(ent.foreignPort).replace(',', ' '),
00452                                                                                       str(ent.selfPort).replace(',', ' '),
00453                                                                                       ent.processName.replace(',', ' '),
00454                                                                                       str(ent.Pid).replace(',', ' '),
00455                                                                                       since.replace(',', ' '),
00456                                                                                       totalKB.replace(',', ' '),
00457                                                                                       ent.foreignCity.replace(',', ' '),
00458                                                                                       ent.foreignStateProv.replace(',', ' '),
00459                                                                                       ent.foreignCountry.replace(',', ' '),
00460                                                                                       ent.foreignOrganization.replace(',', ' '),
00461                                                                                       ent.foreignISP.replace(',', ' '),
00462                                                                                       ent.foreignLongitude,
00463                                                                                       ent.foreignLatitude,
00464                                                                                       idleTime.replace(',', ' '))
00465                     nextLine = nextLine.encode('utf-8')
00466                 except Exception, ex:
00467                     logger.log(__name__ + ": Exception Writing Entity List line to file: " + str(ex))
00468                 else:                
00469                     FILE.write(nextLine + "\n")
00470             
00471             FILE.close()
00472             
00473         
        

def objects.gui.peerGridDisplay.peerGridDisplay.OnButtonReconstructButton (   self,
  event 
)

"Reconstruct TCP Conversation" Button Handler (Not Implemented)

Parameters:
event Standard wx.Button event

Definition at line 400 of file peerGridDisplay.py.

00400                                               :
00401         pass
00402 
00403 
00404 
00405 
    ## "Select Peer List Item" Handler.

def objects.gui.peerGridDisplay.peerGridDisplay.OnButtonShowTraceButton (   self,
  event 
)

"Show Trace" Button Handler

Parameters:
event Standard wx.Button event

Definition at line 361 of file peerGridDisplay.py.

00361                                             :
00362         
00363         if self.selectedPeer == None:
00364             return
00365         
00366         #get the PK from the currently selected item
00367         try:
00368 
00369             foreignIP = self.listCtrlPeers.GetItemText(self.selectedPeer)
00370             srcPort   = self.getColumnText(self.selectedPeer, 2)
00371             dstPort   = self.getColumnText(self.selectedPeer, 1)
00372                 
00373             traceDisplay = None
00374             traceDisplay = traceDisplayDialog(self, foreignIP, srcPort, dstPort)
00375             traceDisplay.ShowModal()
00376             
00377         except Exception, e:
00378                 errMsg = "There was an error opening Trace Display window.\nDetailed Error:\n%s " % (str(e))
00379                 
00380                 dlg = wx.MessageDialog(None, errMsg, 'Error', wx.ICON_ERROR)
00381                 result = dlg.ShowModal()
00382                 dlg.Destroy()
00383         finally:
00384             if traceDisplay is not None:
00385                 traceDisplay.Destroy()
00386     
00387     
00388     
    ## Retrieves the string value of a column/index location in the Peer List.

def objects.gui.peerGridDisplay.peerGridDisplay.OnListCtrlPeersListColClick (   self,
  event 
)

"Click on Peer List Column" Handler (not implemented).

Parameters:
event Standard event

Definition at line 421 of file peerGridDisplay.py.

00421                                                 :
00422         pass
00423 
00424 
    ## Called when the sort direction has changed

def objects.gui.peerGridDisplay.peerGridDisplay.OnListCtrlPeersListItemDeselected (   self,
  event 
)

"Deselect Peer List Item" Handler.

Parameters:
event Standard event

Definition at line 415 of file peerGridDisplay.py.

00415                                                       :
00416         self.selectedPeer = None
00417         
00418         
    ## "Click on Peer List Column" Handler (not implemented).

def objects.gui.peerGridDisplay.peerGridDisplay.OnListCtrlPeersListItemSelected (   self,
  event 
)

"Select Peer List Item" Handler.

Parameters:
event Standard event

Definition at line 408 of file peerGridDisplay.py.

00408                                                     :
00409         item = event.GetItem()
00410         self.selectedPeer = item.GetId()
00411 
00412 
    ## "Deselect Peer List Item" Handler.

def objects.gui.peerGridDisplay.peerGridDisplay.OnSortOrderChanged (   self  ) 

Called when the sort direction has changed.

Definition at line 426 of file peerGridDisplay.py.

00426                                 :
00427         print "sorted"
00428         self.selectedPeer = self.listCtrlPeers.GetFirstSelected()
00429         
00430         
    ## "Export to File" Button Handler (Not Implemented)


Member Data Documentation

Definition at line 208 of file peerGridDisplay.py.

Definition at line 200 of file peerGridDisplay.py.

Definition at line 224 of file peerGridDisplay.py.

Definition at line 150 of file peerGridDisplay.py.

Definition at line 145 of file peerGridDisplay.py.

Definition at line 247 of file peerGridDisplay.py.

Definition at line 180 of file peerGridDisplay.py.

Definition at line 172 of file peerGridDisplay.py.

Definition at line 259 of file peerGridDisplay.py.

Definition at line 233 of file peerGridDisplay.py.

Definition at line 232 of file peerGridDisplay.py.

Definition at line 222 of file peerGridDisplay.py.


The documentation for this class was generated from the following file:

Generated on Mon Mar 30 00:26:32 2009 for EyeSpy by  doxygen 1.5.8