#!/usr/bin/python2
import os
import sys
import inspect
from sets import Set

def usage():
    print "\nUSAGE:"
    print "  ./install_apps.py [OPTIONS]\n"
    print "  Install NDN applications"
    print "  Latest source codes will be downloaded from their GitHub"
    print "  named-data repositories (https://github.com/named-data)"
    print "\nOPTIONS:"
    print "  install_ndncxx     - install ndn-cxx (named-data/ndn-cxx)"
    print "  setup_security     - create an identity using ndnsec (/tmp/nfd_integration)"
    print "  install_NFD        - install NFD (named-data/NFD)"
    print "  install_ndntraffic - install ndn-traffic-generator (named-data/ndn-traffic-generator)"
    print "  install_ndntools   - install ndn-tools (named-data/ndn-tools)"
    print "  install_repo       - install repo-ng (named-data/repo-ng)"
    print "  install_infoedit   - install infoedit"
    print "  install_tools      - install tests tools"
    print "  install_all        - do all of the above"
    print "  help               - print this message and exit\n"


def main():
    cmd_subfolder = os.path.realpath(
        os.path.abspath(os.path.join(os.path.split(
            inspect.getfile(inspect.currentframe()))[0], "install_helpers")))
    if cmd_subfolder not in sys.path:
        sys.path.insert(0, cmd_subfolder)
    validOptions = [ "install_ndncxx",
                     "setup_security",
                     "install_NFD",
                     "install_ndntraffic",
                     "install_ndntools",
                     "install_repo",
                     "install_infoedit",
                     "install_tools",
                     "install_all",
                     "help" ]

    if len(sys.argv) > 1:
        actionList = Set(sys.argv[1:])
        optionsStatus = 0
        for option in actionList:
            if option not in validOptions:
                print "Invalid option provided - " + option
                optionsStatus = -1
                break
        if optionsStatus == 0 and "help" not in actionList:
            if "install_all" in actionList:
                actionList.add("install_ndncxx")
                actionList.add("setup_security")
                actionList.add("install_NFD")
                actionList.add("install_ndntraffic")
                actionList.add("install_ndntools")
                actionList.add("install_repo")
                actionList.add("install_infoedit")
                actionList.add("install_tools")
            module = __import__("setup_preparation_folder")
            module.run()
            module = __import__("install_dependencies")
            module.run()
            if "install_ndncxx" in actionList:
                module = __import__("install_ndncxx")
                module.run()
            if "setup_security" in actionList:
                module = __import__("setup_security")
                module.run()
            if "install_NFD" in actionList:
                module = __import__("install_NFD")
                module.run()
            if "install_ndntraffic" in actionList:
                module = __import__("install_ndntraffic")
                module.run()
            if "install_ndntools" in actionList:
                module = __import__("install_ndntools")
                module.run()
            if "install_repo" in actionList:
                module = __import__("install_repo")
                module.run()
            if "install_infoedit" in actionList:
                module = __import__("install_infoedit")
                module.run()
            if "install_tools" in actionList:
                module = __import__("install_tools")
                module.run()
            print ""
        else:
            usage()
    else:
        usage()


if __name__ == "__main__":
    main()
