import os
import time
import socket
try:
    socket.create_connection(("www.google.com", 80))
    print("internet connected")

    os.mkdir('PYOS')
    os.chdir('PYOS')
    os.system('curl -O -k https://pyos.pages.dev/downloads/essential/cmdbootroot.py')
    os.mkdir('home')
    os.chdir('home')
    os.system('curl -O -k https://pyos.pages.dev/downloads/essential/usercreate.py')
    os.chdir('..')
    
    print(f'PYOS has officially been installed to your system at: {os.getcwd()}')
    getinputyesorno = input("Would you like to run it now? (it must be y or n no capitals not yes or no just y or n)")
    if getinputyesorno == "y":
        os.startfile('cmdbootroot.py')
    if getinputyesorno == "n":
        print("Closing...")
        time.sleep(3)
except OSError:
    print('Please connect to the internet before downloading PYOS')
    input('')