# Path: neubot/utils_modules.py
# def modprobe(filter, context, message):


import sys
import textwrap
import logging
    import neubot.agent
    import neubot.api.client
    import neubot.database.main
    import neubot.bittorrent
    import neubot.http.client
    import neubot.http.server
    import neubot.privacy
    import neubot.speedtest.client
    import neubot.speedtest.client
    import neubot.speedtest.server
    import neubot.net.stream
from neubot import utils_modules
#
# XXX Good morning, this is an hack: py2exe does not
# load modules that are not referenced and we're very
# lazy in this file.  As a workaround let's load all
# modules when we're in windows and we are not frozen
# so we should reference all modules when py2exe is
# inspecting us.
#
if sys.platform == 'win32' and not hasattr(sys, 'frozen'):
    #import neubot.net.CA               # posix only
    #import neubot.server               # requires PyGeoIP

def run(argv):

    # /usr/bin/neubot module ...
    del argv[0]
    module = argv[0]

    if module == "help":
        sys.stdout.write("Neubot help -- prints available commands\n")

        commands = " ".join(sorted(MODULES.keys()))
        lines =  textwrap.wrap(commands, 60)
        sys.stdout.write("Commands: " + lines[0] + "\n")
        for s in lines[1:]:
            sys.stdout.write("          " + s + "\n")

        sys.stdout.write("Try `neubot CMD --help` for more help on CMD.\n")
        sys.exit(0)


# Path: neubot/utils_modules.py
# def modprobe(filter, context, message):


# Path: neubot/main/module.py
import sys
import textwrap
import logging
    import neubot.agent
    import neubot.api.client
    import neubot.database.main
    import neubot.bittorrent
    import neubot.http.client
    import neubot.http.server
    import neubot.privacy
    import neubot.speedtest.client
    import neubot.speedtest.client
    import neubot.speedtest.server
    import neubot.net.stream
from neubot import utils_modules

#
# XXX Good morning, this is an hack: py2exe does not
# load modules that are not referenced and we're very
# lazy in this file.  As a workaround let's load all
# modules when we're in windows and we are not frozen
# so we should reference all modules when py2exe is
# inspecting us.
#
if sys.platform == 'win32' and not hasattr(sys, 'frozen'):
    #import neubot.net.CA               # posix only
    #import neubot.server               # requires PyGeoIP

def run(argv):

    # /usr/bin/neubot module ...
    del argv[0]
    module = argv[0]

    if module == "help":
        sys.stdout.write("Neubot help -- prints available commands\n")

        commands = " ".join(sorted(MODULES.keys()))
        lines =  textwrap.wrap(commands, 60)
        sys.stdout.write("Commands: " + lines[0] + "\n")
        for s in lines[1:]:
            sys.stdout.write("          " + s + "\n")

        sys.stdout.write("Try `neubot CMD --help` for more help on CMD.\n")
        sys.exit(0)


    utils_modules.modprobe(None, "load_subcommand", MODULES)