from subprocess import run
import time

from os import mkdir, chdir, system, getcwd

inputuser = input("What username do you want to have? ")

mkdir(inputuser)
chdir(inputuser)
print("Directory made:", inputuser)
mkdir("passwords")
chdir("passwords")
time.sleep(1)

with open("pincodething.py","w"):
    print("Pass file made")
#Reading app code


system('curl -O -k "https://pyos.pages.dev/downloads/essential/pincodething.py"')
with open("filecontentcode.txt", "w") as file:
    print("Hashing file made")
    file.write("0")
with open('usernamefile.txt', "w") as f:
    f.write("\n")
    f.write(inputuser)
    time.sleep(1)
    print('User file made')
with open('usernamefile.txt', "r") as f:
    nread = f.read()
chdir("../..")

chdir(inputuser)
mkdir("bash")
chdir('bash')
with open('fileuser.txt', "w") as f:
    f.write(nread)

#Create the apps

system('curl -O -k "https://pyos.pages.dev/downloads/essential/bash.py"')
chdir('../../..')
time.sleep(1)




chdir('home')

chdir(inputuser) 
system('curl -O -k "https://pyos.pages.dev/downloads/essential/homemenubash.py"')
system('curl -O -k "https://pyos.pages.dev/downloads/essential/fex.py"')
mkdir('user')
chdir('user')
mkdir('apps')
chdir('..')
chdir('../../')


chdir('home')
chdir(inputuser)
chdir('user/apps')


system('curl -O -k "https://pyos.pages.dev/downloads/createshortcut.py"')
system('curl -O -k "https://pyos.pages.dev/downloads/calender.py"')
system('curl -O -k "https://pyos.pages.dev/downloads/notepadapp.py"')


chdir('../..')
print('Apps made')
chdir('passwords')

print('Running password maker')
run('pincodething.py', shell=True)