<commit_before>from Core.Connection import *
from Core.Interfaceable import *
from Core.globals import environ
from PyQt4.QtCore import QPoint
import Core.util

class Router(Interfaceable):
    device_type = "Router"    

    def __init__(self):
        Interfaceable.__init__(self)
        self.menu.addAction("Wireshark", self.wireshark)
        self.menu.addAction("Graph", self.graph)
        self.tail = None
        self.wshark = None
        self.rstatsWindow = None
        
        self.lightPoint = QPoint(-19,-3)

    def graph(self):
        """
        Graph the stats of the running router
        """
        if not mainWidgets["main"].isRunning():
            mainWidgets["log"].append("You must start the topology first!")
            return
        
        if options["graphing"]:
            try:
                from UI.GraphWindow import GraphWindow
            except:
                mainWidgets["log"].append(
                        "Error: matplotlib required for graphing capabilities")
            else:
                self.rstatsWindow = GraphWindow(self.getName(), 
                                                mainWidgets["canvas"])
                self.rstatsWindow.show()

    def wireshark(self):
        """<commit_msg>Added Openflow switch to Router UI<commit_after>from Core.Connection import *
from Core.Interfaceable import *
from Core.globals import environ
from PyQt4.QtCore import QPoint
import Core.util

class Router(Interfaceable):
    device_type = "Router"    

    def __init__(self):
        Interfaceable.__init__(self)
        self.menu.addAction("Wireshark", self.wireshark)
        self.menu.addAction("Graph", self.graph)
        self.setProperty("openflow", "False")
        self.tail = None
        self.wshark = None
        self.rstatsWindow = None
        
        self.lightPoint = QPoint(-19,-3)

    def graph(self):
        """
        Graph the stats of the running router
        """
        if not mainWidgets["main"].isRunning():
            mainWidgets["log"].append("You must start the topology first!")
            return
        
        if options["graphing"]:
            try:
                from UI.GraphWindow import GraphWindow
            except:
                mainWidgets["log"].append(
                        "Error: matplotlib required for graphing capabilities")
            else:
                self.rstatsWindow = GraphWindow(self.getName(), 
                                                mainWidgets["canvas"])
                self.rstatsWindow.show()

    def wireshark(self):
        """
{'fraction_non_alphanumeric': 0.09516441005802707, 'fraction_numerical': 0.003094777562862669, 'mean_word_length': 1.7896440129449838, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '511938', 'n_tokens_mistral': 679, 'n_tokens_neox': 654, 'n_words': 159}