Advertisement
Techmo

PythonOS

Jan 28th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.88 KB | None | 0 0
  1. __author__ = 'Brad'
  2. import time
  3. import os
  4.  
  5. #This requires that you be running windows. Any other os will make errors.
  6. #you need a text file called "pass" in the same directory as this python file with your password #typed in it
  7. def calc():
  8.     os.system("cls")
  9.     function = raw_input("add, subtract, multiply, or divide?: ")
  10.     if function == "add":
  11.         os.system("cls")
  12.         x = raw_input("Insert first number: ")
  13.         os.system("cls")
  14.         y = raw_input("Insert second number: ")
  15.         os.system("cls")
  16.         add = int(x) + int(y)
  17.         print(str(x) + " + " + str(y) + " = " + str(add))
  18.         osScreen2()
  19.     elif function == "subtract":
  20.         os.system("cls")
  21.         x = raw_input("Insert first number: ")
  22.         os.system("cls")
  23.         y = raw_input("Insert second number: ")
  24.         os.system("cls")
  25.         add = int(x) - int(y)
  26.         print(str(x) + " - " + str(y) + " = " + str(add))
  27.         osScreen2()
  28.     elif function == "multiply":
  29.         os.system("cls")
  30.         x = raw_input("Insert first factor: ")
  31.         os.system("cls")
  32.         y = raw_input("Insert second factor: ")
  33.         os.system("cls")
  34.         add = int(x) * int(y)
  35.         print(str(x) + " x " + str(y) + " = " + str(add))
  36.         osScreen2()
  37.     elif function == "divide":
  38.         os.system("cls")
  39.         x = raw_input("Insert numerator: ")
  40.         os.system("cls")
  41.         y = raw_input("Insert denominator: ")
  42.         os.system("cls")
  43.         add = int(x) / int(y)
  44.         print(str(x) + " / " + str(y) + " = " + str(add))
  45.         osScreen2()
  46.     else:
  47.         print("Invalid operation")
  48.         osScreen2()
  49.  
  50.  
  51. # the say command-------------------------
  52. def say():
  53.     sent = raw_input("Say what?: ")
  54.     print(sent)
  55.     osScreen2()
  56. #--------------------------the resetpw command--------------------------
  57. def pwreset():
  58.     os.system("cls")
  59.     ps = raw_input("Enter your old password: ")
  60.     if ps == password:
  61.         os.system("cls")
  62.         dp = raw_input("Enter your new password: ")
  63.         open("pass.txt", 'w').close
  64.         f2 = open("pass.txt", "r+")
  65.         f2.write(dp)
  66.         os.system("cls")
  67.         print("Password Reset")
  68.         time.sleep(1)
  69.         os.system("cls")
  70.         osScreen2()
  71.     else:
  72.         os.system("cls")
  73.         print("Passcode Incorrect")
  74.         time.sleep(1)
  75.         osScreen()
  76. #--------------------------------------------------------------------------
  77. #---------------the coms command-------------------------------------------
  78. def commands():
  79.     print("commands: exit, resetpw, coms, clearsc, say, calc")
  80. # -------------------the loading account screen ----------------------------
  81. def loadOS():
  82.     os.system("cls")
  83.     print("loading your POS account.")
  84.     time.sleep(1)
  85.     os.system("cls")
  86.     print("loading your POS account..")
  87.     time.sleep(1)
  88.     os.system("cls")
  89.     print("loading your POS account...")
  90.     time.sleep(1)
  91.     osScreen()
  92. #------------------------------------------------------------------------------
  93. #---------------the command interpreter----------------------------------------
  94. def osScreen():
  95.     os.system("cls")
  96.     print("POS V 0.0.1")
  97.     print("for a list of commands type 'coms'")
  98.     osScreen2()
  99. def osScreen2():
  100.     command = raw_input("> ")
  101.     if command == "exit":
  102.         exit()
  103.     elif command == "resetpw":
  104.         pwreset()
  105.         osScreen2()
  106.     elif command == "coms":
  107.         commands()
  108.         osScreen2()
  109.     elif command == "clearsc":
  110.         os.system("cls")
  111.         osScreen2()
  112.     elif command == "say":
  113.         say()
  114.     elif command == "calc":
  115.         calc()
  116.     else:
  117.         print("Unknown command")
  118.         osScreen2()
  119.  
  120. print("Welcome to POS")
  121. print("--------------")
  122. password = raw_input("Code: ")
  123. f1 = open("pass.txt")
  124. setpass = f1.read()
  125. f1.close()
  126. if password == setpass:
  127.     loadOS()
  128. else:
  129.     print("Incorrect Passcode")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement