#!/usr/bin/env python

import os
import sys
import platform
import subprocess

def has_admin():
    if platform.system() == 'Windows':
        try:
            # only windows users with admin privileges can read the C:\windows\temp
            temp = os.listdir(os.sep.join([os.environ.get('SystemRoot','C:\\windows'),'temp']))
        except:
            return False
        else:
            return True
    else:
    	if os.geteuid() == 0:
    		return True

def run_command(cmd):
	subprocess.check_call(cmd, shell=True, stdin=None, stdout=open(os.devnull, 'wb'))

def apt_install_package(package_name):
	print("> apt-get install {pack}".format(pack=package_name))
	run_command('apt-get install -y {pack}'.format(pack=package_name))

def add_apt_repository(repo):
	print("> add-apt-repository {repo}".format(repo=repo))
	run_command('add-apt-repository -y {repo}'.format(repo=repo))

def apt_update():
	print("> apt-get update")
	run_command("apt-get update")

print("=======<FTC Java Autoconfigurator>=======")
print("= written by @archimedespi of Team 6806 =")
if not has_admin():
	print("User does not have admin privileges!")
	print("Please run as an admin.")
	print("on Windows, this right click cmd.exe and select \"run as admin\"")
	print("on Mac or Linux, this means run with sudo")
	raise PermissionError("User does not have root/admin privileges")

if platform.system() == "Linux":
	if platform.dist()[0] == "Ubuntu"
elif platform.system() == "Windows":
	pass
elif platform.system() == "Darwin":
	pass
else:
	raise RuntimeError("System not supported by script")

#!/usr/bin/env python

import os
import sys
import platform
import subprocess

def has_admin():
    if platform.system() == 'Windows':
        try:
            # only windows users with admin privileges can read the C:\windows\temp
            temp = os.listdir(os.sep.join([os.environ.get('SystemRoot','C:\\windows'),'temp']))
        except:
            return False
        else:
            return True
    else:
    	if os.geteuid() == 0:
    		return True

def run_command(cmd):
	subprocess.check_call(cmd, shell=True, stdin=None, stdout=open(os.devnull, 'wb'))

def apt_install_package(package_name):
	print("> apt-get install {pack}".format(pack=package_name))
	run_command('apt-get install -y {pack}'.format(pack=package_name))

def add_apt_repository(repo):
	print("> add-apt-repository {repo}".format(repo=repo))
	run_command('add-apt-repository -y {repo}'.format(repo=repo))

def apt_update():
	print("> apt-get update")
	run_command("apt-get update")

print("=======<FTC Java Autoconfigurator>=======")
print("= written by @archimedespi of Team 6806 =")
if not has_admin():
	print("User does not have admin privileges!")
	print("Please run as an admin.")
	print("on Windows, this right click cmd.exe and select \"run as admin\"")
	print("on Mac or Linux, this means run with sudo")
	raise PermissionError("User does not have root/admin privileges")

if platform.system() == "Linux":
	if platform.dist()[0] == "Ubuntu":
		apt_install_package("python-software-properties software-properties-common")
		add_apt_repository("ppa:webupd8team/java")
		apt_update()
		run_command("echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections")
		run_command("echo oracle-java8-installer shared/accepted-oracle-license-v1-1 seen true | /usr/bin/debconf-set-selections")
		apt_install_package("oracle-java8-installer")
		apt_install_package("oracle-java8-set-default")


elif platform.system() == "Windows":
	pass
elif platform.system() == "Darwin":
	pass
else:
	raise RuntimeError("System not supported by script")

Install Java on Ubuntu