Advertisement
Techmo

PythonOS2

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