Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'Brad'
- import time
- import os
- import platform
- import subprocess
- import smtplib
- #external file applications
- from eret import errorcodes
- def cls():
- os.system("clear")
- def mail():
- print("PCOS Email Client v0.3")
- print("--------------------------")
- gmail_user = raw_input("Enter your email: ")
- gmail_pwd = raw_input("Enter your email password: ")
- FROM = gmail_user
- TO = [raw_input("Enter recipient email: ")] #must be a list
- SUBJECT = raw_input("Enter email subject: ")
- TEXT = raw_input("Enter message: ")
- # Prepare actual message
- message = """\From: %s\nTo: %s\nSubject: %s\n\n%s
- """ % (FROM, ", ".join(TO), SUBJECT, TEXT)
- try:
- #server = smtplib.SMTP(SERVER)
- server = smtplib.SMTP("smtp.gmail.com", 587) #or port 465 doesn't seem to work!
- server.ehlo()
- server.starttls()
- server.login(gmail_user, gmail_pwd)
- server.sendmail(FROM, TO, message)
- #server.quit()
- server.close()
- print 'successfully sent the mail'
- except:
- print (errorcodes(2))
- osScreen2()
- def count():
- cls()
- cend = float(raw_input("Count to what number?: "))
- cls()
- crate = float(raw_input("Count by?: "))
- cls()
- cstart = float(raw_input("Count from?: "))
- cls()
- choice = raw_input("Write to file?(Y/N): ").lower()
- cls()
- if choice == "y":
- fname = raw_input("Enter the name of the file to write to: ")
- cls()
- open(fname, "w").close()
- cfile = open(fname, "r+")
- x = cstart
- while x <= cend:
- if choice == "y":
- cfile.write(str(x) + ", ")
- cfile.flush()
- else:
- print(x)
- print(x)
- x += crate
- osScreen2()
- def calculator():
- cls()
- function = raw_input("add, subtract, multiply, or divide?: ")
- if function == "add":
- cls()
- print("Insert first number: ")
- x = float(raw_input())
- cls()
- print("Insert second number: ")
- y = float(raw_input())
- cls()
- add = float(x) + float(y)
- print(str(x) + " + " + str(y) + " = " + str(add))
- elif function == "subtract":
- cls()
- x = float(raw_input("Insert first number: "))
- cls()
- y = float(raw_input("Insert second number: "))
- cls()
- add = float(x) - float(y)
- print(str(x) + " - " + str(y) + " = " + str(add))
- elif function == "multiply":
- cls()
- x = int(raw_input("Insert first factor: "))
- cls()
- y = int(raw_input("Insert second factor: "))
- cls()
- add = float(x) * float(y)
- print(str(x) + " x " + str(y) + " = " + str(add))
- elif function == "divide":
- cls()
- x = float(raw_input("Insert numerator: "))
- cls()
- y = float(raw_input("Insert denominator: "))
- cls()
- add = float(x) / float(y)
- print(str(x) + " / " + str(y) + " = " + str(add))
- else:
- print("invalid operation")
- calculator()
- osScreen2()
- def view():
- name = raw_input("Insert the name of the file you would like to open(inlude any extensions): ")
- if name == "pass.txt" or name == "state.txt":
- print(errorcodes(1))
- view()
- else:
- try:
- fdata = open(name, "r+").read()
- except IOError:
- cls()
- print("Invalid file name")
- time.sleep(2)
- cls()
- view()
- cls()
- print("The file contains:")
- print("")
- print(fdata)
- osScreen2()
- def rstusr():
- cls()
- f1 = open("usr.txt", "r+")
- username = f1.read()
- us1 = raw_input("Enter your old username: ")
- if us1 == username:
- cls()
- dp = raw_input("Enter your new username: ")
- open("usr.txt", 'w').close()
- f3 = open("usr.txt", "r+")
- f3.write(dp)
- f3.flush()
- cls()
- print("Username Reset")
- time.sleep(1)
- cls()
- osScreen2()
- else:
- cls()
- print("Username does not exist")
- time.sleep(1)
- osScreen()
- def new():
- name = raw_input("Insert name of new file (use .txt if you want a text file): ")
- if name == "pass.txt" or name == "state.txt":
- print(errorcodes(1))
- new()
- else:
- open(name, "w").close()
- file1 = open(name, "r+")
- cls()
- print("PyEdit v0.1.1")
- print("Enter text to be written to file then press 'Enter'")
- print(" ")
- print(" ")
- data = raw_input()
- file1.write(data)
- file1.flush()
- file1.close()
- osScreen2()
- # the say command-------------------------
- def say():
- sent = raw_input("Say what?: ")
- print(sent)
- osScreen2()
- def cpuname():
- if platform.system() == "Windows":
- return platform.processor()
- elif platform.system() == "Darwin":
- return subprocess.check_output(['/usr/sbin/sysctl', "-n", "machdep.cpu.brand_string"]).strip()
- elif platform.system() == "Linux":
- command = "cat /proc/cpuinfo"
- return subprocess.check_output(command, shell=True).strip()
- return ""
- def sysinfo():
- print("OS name: " + platform.release())
- print("OS type: " + platform.system())
- print("OS version: " + platform.version())
- print("CPU: " + cpuname())
- print("CPU type: " + platform.machine())
- print("Python version: " + platform.python_version())
- print("Network name: " + platform.node())
- osScreen2()
- #--------------------------the resetpw command--------------------------
- def pwreset():
- cls()
- f1 = open("pass.txt", "r+")
- password = f1.read()
- ps = raw_input("Enter your old password: ")
- if ps == password:
- cls()
- dp = raw_input("Enter your new password: ")
- open("pass.txt", 'w').close()
- f2 = open("pass.txt", "r+")
- f2.write(dp)
- f2.flush()
- open("state.txt", "w").close()
- oss = open("state.txt", "r+")
- oss.write("osState: 0")
- cls()
- print("Password Reset")
- time.sleep(1)
- cls()
- osScreen2()
- else:
- cls()
- print("Passcode Incorrect")
- time.sleep(1)
- osScreen()
- #--------------------------------------------------------------------------
- #---------------the coms command-------------------------------------------
- def commands():
- print("commands: exit, mail, resetpw, rstusr, coms, clearsc, say, calc, new, view, sysinf, count")
- # -------------------the loading account screen ----------------------------
- def loadOS():
- cls()
- print("loading your POS account.")
- time.sleep(1)
- cls()
- print("loading your POS account..")
- time.sleep(1)
- cls()
- print("loading your POS account...")
- time.sleep(1)
- osScreen()
- #------------------------------------------------------------------------------
- #---------------the command interpreter----------------------------------------
- def osScreen():
- cls()
- print("PCOS V 0.2.3 on " + platform.system() + " version: " + platform.version())
- print("for a list of commands type 'coms'")
- osScreen2()
- def osScreen2():
- command = raw_input("> ")
- if command == "exit":
- exit()
- elif command == "resetpw":
- pwreset()
- osScreen2()
- elif command == "coms":
- commands()
- osScreen2()
- elif command == "mail":
- mail()
- elif command == "count":
- count()
- elif command == "clearsc":
- cls()
- osScreen2()
- elif command == "say":
- say()
- elif command == "rstusr":
- rstusr()
- elif command == "calc":
- calculator()
- elif command == "sysinf":
- sysinfo()
- elif command == "new":
- new()
- elif command == "view":
- view()
- else:
- print("Unknown command")
- osScreen2()
- def first():
- try:
- f1 = open("pass.txt")
- setpass = f1.read()
- f1.close()
- print("Welcome to POS")
- print("--------------")
- state = open("state.txt", "r+")
- st = state.read()
- if st == "osState: 1":
- print("WARNING: using default os passcode")
- print("----------------------------------")
- us = raw_input("Enter Username: ")
- if us in open("usr.txt").read():
- cls()
- print("Welcome to POS")
- print("--------------")
- if st == "osState: 1":
- print("WARNING: using default os passcode")
- print("----------------------------------")
- password = raw_input("Enter Password: ")
- if password == setpass:
- loadOS()
- else:
- cls()
- print("Code Incorrect")
- time.sleep(3)
- first()
- else:
- cls()
- print("User does not exist")
- time.sleep(3)
- cls()
- first()
- except IOError:
- print("Creating system files...")
- time.sleep(3)
- cls()
- open("pass.txt", "w").close()
- p1 = open("pass.txt", "r+")
- p1.write("password")
- p1.flush()
- open("usr.txt", "w").close()
- p1 = open("usr.txt", "r+")
- p1.write("user")
- p1.flush()
- open("state.txt", "w").close()
- f1 = open("state.txt", "r+")
- f1.write("osState: 1")
- f1.flush()
- print("done")
- time.sleep(1)
- cls()
- first()
- first()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement