From 1afff18b2dcf7d20466d87124dae1f9403d1449a Mon Sep 17 00:00:00 2001 From: Marius Sandu-Popa Date: Fri, 11 Dec 2009 22:54:18 +0200 Subject: [PATCH] update viewer: added peer port plot option --- viewer/p2p-nexteditor.py | 16 +++++++++++----- viewer/test.py | 41 ---------------------------------------- 2 files changed, 11 insertions(+), 46 deletions(-) delete mode 100644 viewer/test.py diff --git a/viewer/p2p-nexteditor.py b/viewer/p2p-nexteditor.py index a26c3bc..05a822f 100644 --- a/viewer/p2p-nexteditor.py +++ b/viewer/p2p-nexteditor.py @@ -58,6 +58,8 @@ class PlotterThread(Thread): restrictions.append(('direction', '1', 'eq')) if self.options[3]: + if self.options[4]: + restrictions.append(('peer_port', self.options[4], 'eq')) restrictions.append(('peer_ip', self.options[3], 'eq')) vbmc = VerboseMessageCollection(self.dbname, self.cs_id, restrictions) @@ -173,8 +175,9 @@ class ControlPanel(HasTraits): upload_speed = Bool() acceleration = Bool() stats = Bool() - direction = Enum("Both", "In", "Out") + direction = Enum("In/Out", "In", "Out") ip = Str() + port = Str() plot = Button() @@ -226,9 +229,12 @@ class ControlPanel(HasTraits): Item('57'), Item('stats', label="Statistics")), HGroup( - Item('direction'), - Item('28'), - Item('ip', label="Peer IP"), enabled_when='object.stats'), + #HGroup( + Item('ip', label="Peer IP"), + Item('port', show_label=False), + Item('direction', show_label=False), + #Item('28'), + enabled_when='object.stats'), show_border=True, label='Plotting Options'), Item('10'), Item('plot', show_label=False), @@ -314,7 +320,7 @@ class ControlPanel(HasTraits): self.figure.subplots_adjust(left=0.03, right=0.97, top=0.98) PlotterThread(dbfile, self.cs_id, 0, self.plot_figure, options, 1).start() else: - options2 = [self.time_start, self.time_stop, self.direction, self.ip] + options2 = [self.time_start, self.time_stop, self.direction, self.ip, self.port] axes = self.figure.add_subplot(2,1,2) axes.grid(linestyle='dashed') axes = self.figure.add_subplot(2,2,1) diff --git a/viewer/test.py b/viewer/test.py deleted file mode 100644 index 3f85146..0000000 --- a/viewer/test.py +++ /dev/null @@ -1,41 +0,0 @@ -import sys -import getopt -import julian -import matplotlib.pyplot as plt -from config import * -from DbObjects import * -import numpy as np - -def main(): - msg_types = {0:[0, "CHOKE"], 1:[0, "UNCHOKE"], 2:[0, "INTERESTED"], 3: [0, "NOT_INTERESTED"], \ - 4:[0, "HAVE"], 5:[0, "BITFIELD"], 6:[0, "REQUEST"], 7:[0, "PIECE"], 8:[0, "CANCEL"], \ - 9:[0, "DHT_PORT"]} - dbname = 'test.db' - vbmc = VerboseMessageCollection(dbname, 4); - vbmcit = vbmc.getIter() - while True: - try: - vbm = next(vbmcit) - except StopIteration: - break - msg_types[vbm.message_type][0] = msg_types[vbm.message_type][0] + 1; - - print msg_types - fig = plt.figure() - ax = fig.add_subplot(111) - plt.subplots_adjust(left=0.13, right=0.90) - vals = [] - ticks = [] - pos = np.arange(len(msg_types))+.3 - for list in msg_types.values(): - vals.append(list[0]) - ticks.append(list[1]) - ax.barh(pos, vals, height=0.3, align='center') - ax.grid(True) - plt.yticks(pos, ticks) - #ax.set_yticklabels(ticks); - plt.show() - - -if __name__ == "__main__": - sys.exit(main()) -- 2.20.1