Exemplo n.º 1
0
    def do_load(self, line):
        """Loads a file.

        Parameters
        ----------
        line : string
            A string containing command line arguments.
            See help_load.
        """

        # Get the args
        args = line.split()

        # Make sure only 1 argument is provided
        if not check_args(args, 1):
            return
        try:
            # Initialize bw with the log file
            base = os.path.basename(args[0])
            self.bw = BlackWidow({'log_file': os.path.splitext(base)[0]})

            # Initialie network from the file
            self.network = parser.config_network(args[0], self.bw)

            # Create a new figure
            f = plt.figure(2)

            # Show the network if show_network is True
            if self.show_network:
                self.do_show("")
        except Exception as e:
            print e
Exemplo n.º 2
0
    def create_network(self, settings=None, f=None):
        """Initializes the network and bw variables.

        Parameters
        ----------
        settings : dict, optional
            A dictionary of settings (the default is None). See `Blackwidow`
            for valid values.
        f : string, optional
            The filename containing the network (the default is None).
        """

        # If settings are not provided, initialize bw and network without any
        # settings.
        if settings is None:
            self.bw = BlackWidow()
            self.network = Network(self.bw)

        # Initialize bw and network with settings
        else:
            self.bw = BlackWidow(settings)
            self.network = parser.config_network(f, self.bw)

        # Reset visual parameters
        self.do_reset_v("")

        # Clear the plot
        self.do_clear("")

        # Create a new figure to show the network
        f = plt.figure(2)
        self.do_show("")
Exemplo n.º 3
0
def test_host():
    network = config_network('cases/case0.json', None)
    network.dump()
    assert network.devices['H1'].network_id == 'H1'