Advertisement
MRtecno98

TecnoOS BETA 1.0.0001

Oct 24th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.80 KB | None | 0 0
  1. import subprocess , os
  2.  
  3. wd = "C:\\"
  4. prompt = wd + ">"
  5. path = "."
  6.  
  7. def handleBuiltIn(txt) :
  8.     if txt = "" :
  9.         return 7
  10.  
  11.     txt = calculateFormat(txt)
  12.    
  13.     if txt[0] == "cd" :
  14.         if len(txt) < 2 :
  15.             return 1
  16.         else :
  17.             if os.path.exists(txt[1]) :
  18.                 if os.path.isdir(txt[1]) :
  19.                     wd = txt[1]
  20.                     return 0
  21.                 else :
  22.                     print("The path is a file")
  23.                     return 1
  24.             else :
  25.                 print("Insesistent Path")
  26.                 return 1
  27.         return 0
  28.        
  29.  
  30. def updatePrompt() :
  31.     prompt = wd + ">"
  32.  
  33. def calculateFormat(cmd) :
  34.     a = False
  35.     i = 0
  36.     cmd = list(cmd)
  37.     for c in cmd :
  38.         if c = '"' :
  39.             if a :
  40.                 a = False
  41.             else :
  42.                 a = True
  43.         if not a :
  44.             if c == " " :
  45.                 cmd[i] = "ยง"
  46.         i += 1
  47.     return cmd
  48.  
  49. def getPrograms() :
  50.     files = os.listdir(path)
  51.     programs = list()
  52.  
  53.     for file in files :
  54.         if file.endswith(".exe") :
  55.             programs.append(file)
  56.  
  57.     return programs
  58.  
  59. def handle(txt) :
  60.     if txt == "" :
  61.         return 7
  62.     code = handleBuiltIn(txt)
  63.     if code != 1 or code != 7 :
  64.         return 0
  65.    
  66.     programs = getPrograms()
  67.     for program in programs :
  68.         if txt.lower() == program.split(".")[0] :
  69.             try :
  70.                 subprocess.run(path + os.sep + program, shell=True, check=True)
  71.             except :
  72.                 print("Process exited with non-0 exit code")
  73.  
  74. print("Tecnosoft OS [Versione 1.0.0001]")
  75. print("Copyright <c> 2017 MRtecno98 Inc. Tutti i diritti riservati")
  76. print()
  77.  
  78. while True :
  79.     cmd = input(prompt)
  80.     handle(txt)
  81.     updatePrompt()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement