#! /usr/bin/python

import argparse
import os

parser = argparse.ArgumentParser(description="Install script for MAVlink.")
parser.add_argument("-i", "--install", help="Install MAVlink.", action="store_true")
parser.add_argument("-u", "--uninstall", help="Uninstall MAVlink.", action="store_true")
parser.add_argument("-p", "--setpath", help="Set MAVlink system paths in PYTHONPATH.", action="store_true")
parser.add_argument("-r", "--resetpath", help="Delete MAVlink system paths in PYTHONPATH.", action="store_true")
args=parser.parse_args()

if args.install:
	print "Install MAVlink."
	os.system("git clone https://github.com/mavlink/mavlink.git")
	os.system("cd mavlink && git submodule init && git submodule update && cd ..")
	os.system("#sudo pip install MAVproxy")
	os.system("sudo pip install pymavlink")

elif args.uninstall:
	print "Uninstall MAVlink."
	os.system("sudo rm mavlink -r")
	os.system("#sudo pip uninstall MAVproxy")
	os.system("sudo pip uninstall pymavlink")

elif args.setpath:
	print "Set MAVlink system paths in PYTHONPATH."
	#todo: Pfad automaitsch erzeugen
	os.system("export PYTHONPATH=$PYTHONPATH:/home/usappz/master/GanymedTools/source/GanymedTools/mavlink/mavlink:/master/GanymedTools/source/GanymedTools/mavlink/src/javascript:/master/GanymedTools/source/GanymedTools/mavlink/src/python")

elif args.resetpath:
	print "Coming soon ..."

else:
	print "choose\n\n--install\n--uninstall\nor\n--help\n\n"

