Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess , os
- wd = "C:\\"
- prompt = wd + ">"
- path = "."
- def handleBuiltIn(txt) :
- if txt = "" :
- return 7
- txt = calculateFormat(txt)
- if txt[0] == "cd" :
- if len(txt) < 2 :
- return 1
- else :
- if os.path.exists(txt[1]) :
- if os.path.isdir(txt[1]) :
- wd = txt[1]
- return 0
- else :
- print("The path is a file")
- return 1
- else :
- print("Insesistent Path")
- return 1
- return 0
- def updatePrompt() :
- prompt = wd + ">"
- def calculateFormat(cmd) :
- a = False
- i = 0
- cmd = list(cmd)
- for c in cmd :
- if c = '"' :
- if a :
- a = False
- else :
- a = True
- if not a :
- if c == " " :
- cmd[i] = "ยง"
- i += 1
- return cmd
- def getPrograms() :
- files = os.listdir(path)
- programs = list()
- for file in files :
- if file.endswith(".exe") :
- programs.append(file)
- return programs
- def handle(txt) :
- if txt == "" :
- return 7
- code = handleBuiltIn(txt)
- if code != 1 or code != 7 :
- return 0
- programs = getPrograms()
- for program in programs :
- if txt.lower() == program.split(".")[0] :
- try :
- subprocess.run(path + os.sep + program, shell=True, check=True)
- except :
- print("Process exited with non-0 exit code")
- print("Tecnosoft OS [Versione 1.0.0001]")
- print("Copyright <c> 2017 MRtecno98 Inc. Tutti i diritti riservati")
- print()
- while True :
- cmd = input(prompt)
- handle(txt)
- updatePrompt()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement