#!/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_ndncppdev  - install ndn-cpp-dev (named-data/ndn-cpp-dev)"
    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_ndntlvping - install ndn-tlv-ping (named-data/ndn-tlv-ping)"
    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_ndncppdev",
                     "setup_security",
                     "install_NFD",
                     "install_ndntraffic",
                     "install_ndntlvping",
                     "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_ndncppdev")
                actionList.add("setup_security")
                actionList.add("install_NFD")
                actionList.add("install_ndntraffic")
                actionList.add("install_ndntlvping")
            module = __import__("setup_preparation_folder")
            module.run()
            module = __import__("install_dependencies")
            module.run()
            if "install_ndncppdev" in actionList:
                module = __import__("install_ndncppdev")
                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_ndntlvping" in actionList:
                module = __import__("install_ndntlvping")
                module.run()
            print ""
        else:
            usage()
    else:
        usage()


if __name__ == "__main__":
    main()
