<commit_before>#!/usr/bin/env python

from mininet.cli import CLI
from mininet.log import info

def MCLI(**networks):
    prompt = 'crossdomain> '
    while True:
        cmd = raw_input(prompt)
        if cmd == 'quit':
            break
        if cmd == 'help':
            info('ls     list all available networks\n')
            info('<net>  switch the cli to <net>\n')
            info('quit   quit the cli and close the simulator\n')
            info('help   print this list\n')
        elif cmd == 'ls':
            info('\n'.join(sorted(networks.keys())))
            info('\n')
        elif cmd in networks.keys():
            CLI.prompt = '%s> ' % cmd
            info('***** Running CLI for %s *****\n' % cmd)
            net = networks[cmd]
            CLI(net)
        else:
            info('Unknown command: %s\n' % cmd)<commit_msg>Use cross domain shell<commit_after>#!/usr/bin/env python

import readline
from cmd import Cmd

from mininet.cli import CLI
from mininet.log import info


class CrossDomainCmd(Cmd):
    def __init__(self, completekey='tab', stdin=None, stdout=None, **networks):
        Cmd.__init__(self, completekey, stdin, stdout)
        self.intro = "A console to help controll crossdomain networks\n"
        self.prompt = "Cross Domain >"
        self.networks = networks

    def do_ls(self, arg):
        print('\n'.join(sorted(self.networks.keys())))
        print('\n')

    def help_ls(self):
        print("List all available networks\n")

    def do_exit(self, arg):
        return True

    def help_exit(self):
        print("Exit the console")

    do_quit = do_exit

    help_quit = help_exit

    do_EOF = do_exit

    help_EOF = help_exit

    def do_net(self, arg):
        domain_name = arg.split(' ')[0]
        if domain_name in self.networks.keys():
            print('***** Running CLI for %s *****\n' % domain_name)
            net = self.networks[domain_name]
            CLI(net)
        else:
            print("***** Cannot find domain named \"" + domain_name +
                  "\" *****")

    def help_net(self):
        print("Choose a domain and connect its mininet shell")
        print("format: net <domain name>")

    def do_execute(self, arg):
        # TODO: do some magic
        pass

    def help_execute(self):
        print("Execute a command on a node")
        print("format: execute <domain_name:node_name> <command>")


def MCLI(**networks):
    cmd = CrossDomainCmd(networks)
    cmd.cmdloop()


if __name__ == '__main__':
    MCLI()
{'fraction_non_alphanumeric': 0.1315057608263806, 'fraction_numerical': 0.0003972983710766786, 'mean_word_length': 2.1712846347607053, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6771071', 'n_tokens_mistral': 801, 'n_tokens_neox': 759, 'n_words': 218}