SHARE
TWEET

textlineos

a guest Feb 13th, 2020 147 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import assets
  2. import time
  3. import sys
  4. import random
  5. import os
  6.  
  7. #calculator
  8. def calculator():
  9.  print ("1. Addition")
  10.  print ("2. Subtraction")
  11.  print ("3. Multiplacation")
  12.  print ("4. Division")
  13.  print ("5. Primes to 100")
  14.  print ("")
  15.  question = input("Please select a option")
  16.  
  17.  if question == "1":
  18.     num1 = int(input("Enter first number: "))
  19.     print (num1)
  20.     num2 = int(input("Enter second number: "))
  21.     print (num2)
  22.     print ("")
  23.     ans = num1 + num2
  24.     print (ans)
  25.     bktoclk = input("Go back to calculator? [y/n]")
  26.     if bktoclk == "y":
  27.      calculator()
  28.     if bktoclk == "n":
  29.      menu()
  30.  if question == "2":
  31.     num1 = int(input("Enter first number: "))
  32.     print (num1)
  33.     num2 = int(input("Enter second number(what will be subtracted): "))
  34.     print (num2)
  35.     print ("")
  36.     ans = num1 - num2
  37.     print (ans)
  38.     bktoclk = input("Go back to calculator? [y/n]")
  39.     if bktoclk == "y":
  40.      calculator()
  41.     if bktoclk == "n":
  42.      menu()
  43.  if question == "3":
  44.     num1 = int(input("Enter first number: "))
  45.     print (num1)
  46.     num2 = int(input("Enter second number: "))
  47.     print (num2)
  48.     print ("")
  49.     ans = num1 * num2
  50.     print (ans)
  51.     bktoclk = input("Go back to calculator? [y/n]")
  52.     if bktoclk == "y":
  53.      calculator()
  54.     if bktoclk == "n":
  55.      menu()
  56.  if question == "4":
  57.     num1 = int(input("Enter first number(dividend): "))
  58.     print (num1)
  59.     num2 = int(input("Enter second number(divisor): "))
  60.     print (num2)
  61.     print ("")
  62.     ans = num1 / num2
  63.     print (ans)
  64.     bktoclk = input("Go back to calculator? [y/n]")
  65.     if bktoclk == "y":
  66.      calculator()
  67.     if bktoclk == "n":
  68.      menu()
  69.  if question =="5":
  70.    print ("")
  71.    print ("2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89 and lastly 97.")    
  72.  if question == "6":
  73.     print ("test")
  74. #dice roll program
  75. def diceroll():
  76.  min = 1
  77.  max = 6
  78.  
  79.  roll_again = "yes"
  80.  
  81.  while roll_again == "yes" or roll_again == "y":
  82.     print ("Rolling the dices...")
  83.     print ("The values are....")
  84.     print (random.randint(min, max))
  85.     print (random.randint(min, max))
  86.     bktodice = input("Roll Again? [y/n]")
  87.     if bktodice == "y":
  88.      diceroll()
  89.     if bktodice == "n":
  90.      menu()
  91.      
  92. def cointoss():
  93.     import random#Importing the random library.
  94.     toss=random.randint(0,1)#Toss variable's value randomly generated between the numer 0 and 1.
  95.     if toss==0:#If the varaiable is equal to 0 then:
  96.         print("")
  97.         print ("You Flipped Heads")#Heads is displayed
  98.         cgoag()
  99.    
  100.     else:#If the Toss is not 0 then:
  101.         print("")
  102.         print("You Flipped Tails")#Tails is displayed
  103.         cgoag()
  104.        
  105.  
  106. def cgoag():
  107.     goagain = input("Toss Again? [y/n]")
  108.     if goagain == "y":
  109.         cointoss()
  110.     if goagain == "n":
  111.         menu()
  112.  
  113.  
  114. def clocksingle():
  115.  while True:
  116.     from datetime import datetime
  117.     now = datetime.now()
  118.     print ("")
  119.     print ("%s/%s/%s %s:%s:%s" % (now.month,now.day,now.year,now.hour,now.minute,now.second))
  120.     menu()
  121.  
  122. def randomnumgen():
  123.     import random
  124.     print(random.randint(0,100))
  125.     bktordm = input("Generate Again? [y/n]")
  126.     if bktordm == "y":
  127.      randomnumgen()
  128.     if bktordm == "n":
  129.      menu()
  130.  
  131.  
  132. def adminmenu():
  133.     print("")
  134.     print("*********************************")
  135.     print("***  TextLineOS - Admin Menu  ***")
  136.     print("*********************************")
  137.     print("")
  138.     print("0. Main Menu")
  139.     print("1. Create New User")
  140.     print("2. Change Log")
  141.     print("3. Make New Admin Account")
  142.     print("4. Read Change Log")
  143.     print("5. SYSTEM LOG")
  144.     print("6. Dump System Log")
  145.     adq3m = input("Please select")
  146.     if adq3m == "1":
  147.            print ("")
  148.            register()
  149.     if adq3m == "2":
  150.            changelogadd()
  151.     if adq3m == "0":
  152.            menu()
  153.     if adq3m == "3":
  154.            createadminuser()
  155.     if adq3m == "4":
  156.            adminchangelog()
  157.     if adq3m == "5":
  158.            readsystemlog()
  159.     if adq3m == "6":
  160.            dumpsystemlog()
  161.    
  162.  
  163. def readsystemlog():
  164.     if os.path.exists("systemlog.txt"):
  165.         print("SYSTEM LOG IS DELYAED BY A SESSION")
  166.         f = open("systemlog.txt", "r")
  167.         print("")
  168.         print("--")
  169.         print(f.read())
  170.         print("--")
  171.         adminmenu()
  172.     else:
  173.       print("*************************************")
  174.       print("ERROR: System Log file does not exist")
  175.       print("*************************************")
  176.       adminmenu()
  177.    
  178.  
  179.        
  180.  
  181. def dumpsystemlog():
  182.  if os.path.exists("systemlog.txt"):
  183.   os.remove("systemlog.txt")
  184.   adminmenu()
  185.  else:
  186.   print("*************************************")
  187.   print("ERROR: System Log file does not exist")
  188.   print("*************************************")
  189.   adminmenu()
  190.    
  191.    
  192. #add to changelog
  193. def changelogadd():
  194.     version = input("Please Input Version Number")
  195.     changed = input("Please Input The Changes")
  196.     file = open("changelog.txt","a")
  197.     file.write("")
  198.     file.write(version)
  199.     file.write("--")
  200.     file.write(changed)
  201.     file.write("\n")
  202.     file.close()
  203.     print("Change Log Made!")
  204.     adminmenu()
  205.  
  206. def checkperms():
  207.     username = input("Please enter your username")
  208.     password = input("Please enter your password")  
  209.     for line in open("adminaccountfile.txt","r").readlines(): # Read the lines
  210.         login_info = line.split() # Split on the space, and store the results in a list of two strings
  211.         if username == login_info[0] and password == login_info[1]:
  212.             print("Correct credentials!")
  213.             adminmenu()
  214.             f = open("systemlog.txt", "a")
  215.             f.write("Successful Login|Admin Login")
  216.             f.write("\n")
  217.             f.close()
  218.             return True
  219.     print("Incorrect credentials. - ACCESS DENIED")
  220.     menu()
  221.     f = open("systemlog.txt", "a")
  222.     f.write("Failed Login-Admin Login")
  223.     f.write("\n")
  224.     f.close()
  225.     print("")
  226.     return False
  227.  
  228.    
  229. def createadminuser():
  230.     adminusername = input("Please Input your desired username")
  231.     adminpassword = input("Please input your desired password ")
  232.     file = open("adminaccountfile.txt","a")
  233.     file.write(adminusername)
  234.     file.write(" ")
  235.     file.write(adminpassword)
  236.     file.write("\n")
  237.     file.close()
  238.     f = open("systemlog.txt", "a")
  239.     f.write("Successful Registration|Admin")
  240.     f.write("\n")
  241.     f.close()
  242.     print("Adminastrator Account Created!")
  243.     adminmenu()
  244.  
  245. def changelog():
  246.     f = open("changelog.txt", "r")
  247.     print("")
  248.     print("--")
  249.     print(f.read())
  250.     print("--")
  251.     bktordm = input("Go back to menu?[y/n]")
  252.     if bktordm == "y":
  253.      menu()
  254.     if bktordm == "n":
  255.      changelog()
  256.  
  257. def adminchangelog():
  258.     f = open("changelog.txt", "r")
  259.     print("")
  260.     print("--")
  261.     print(f.read())
  262.     print("--")
  263.     bktordm = input("Go back to menu?[y/n]")
  264.     if bktordm == "y":
  265.      adminmenu()
  266.     if bktordm == "n":
  267.      adminchangelog()
  268.      
  269.    
  270. #menu code
  271. def menu():
  272.     adq1 = input("Open main menu? [y/n]")
  273.     if adq1 == "y":
  274.         print ("")
  275.         print("*****************************")
  276.         print("***   TextLineOS - Menu    ***")
  277.         print("*****************************")
  278.         print("")
  279.         print ("LOADING... Main menu")
  280.         print ("")
  281.         print ("0. Log off")
  282.         print ("1. Calculator")
  283.         print ("2. Roll The Dice")
  284.         print ("3. Current Time")
  285.         print ("4. Random Number Generator")
  286.         print ("5. Read System Change Log")
  287.         print ("6. Flip A Coin")
  288.         print ("7. Conversion Menu")
  289.         print ("a. Admin Menu")
  290.         adq2m = input("Please select")
  291.         if adq2m == "1":
  292.            print ("Loading calculator")
  293.            calculator()
  294.         if adq2m == "2":
  295.            diceroll()
  296.         if adq2m == "0":
  297.            sys.exit
  298.         if adq2m == "3":
  299.            clocksingle()
  300.         if adq2m == "4":
  301.            randomnumgen()
  302.         if adq2m == "a":
  303.            checkperms()
  304.         if adq2m == "1":
  305.            sys.exit
  306.         if adq2m == "5":
  307.            changelog()
  308.         if adq2m == "6":
  309.             cointoss()
  310.         if adq2m == "7":
  311.             convmenu()
  312.  
  313. def convmenu():
  314.     print("****************************************")
  315.     print("***   TextLineOS - Conversion Menu   ***")
  316.     print("****************************************")
  317.     print("")
  318.     print("0. Exit")
  319.     print("1. Hours To Minutes")
  320.     print("2. Minutes To Hours")
  321.     adq3m = input("Please select")
  322.     if adq3m == "0":
  323.         menu()
  324.     if adq3m == "1":
  325.         hrtomin()
  326.     if adq3m == "2":
  327.         mintohr()
  328.  
  329. def hrtomin():
  330.     print("Hour to minutes")
  331.     hours = int(input("Enter Hours: "))
  332.     qsc1 = hours * 60
  333.     print ("Total Minutes:")
  334.     print (qsc1)
  335.     bcktoconv()
  336.  
  337. def mintohr():
  338.     print("Minutes To Hours")
  339.     hours = int(input("Enter Minutes: "))
  340.     qsc2 = hours / 60
  341.     print ("Total Minutes:")
  342.     print (qsc2)
  343.     bcktoconv()
  344.  
  345.  
  346. def bcktoconv():
  347.     adq3n = input("Main Menu Or Conversion Menu?[main/conv]")
  348.     if adq3n == "main":
  349.         menu()
  350.     if adq3n == "conv":
  351.         convmenu()    
  352.            
  353.  
  354. def register():
  355.     username = input("Please Input your desired username")
  356.     password = input("Please input your desired password ")
  357.     file = open("accountfile.txt","a")
  358.     file.write(username)
  359.     file.write(" ")
  360.     file.write(password)
  361.     file.write("\n")
  362.     file.close()
  363.     f = open("systemlog.txt", "a")
  364.     f.write("Successful Registration|User")
  365.     f.write("\n")
  366.     f.close()
  367.     print("Account Created!")
  368.     adminmenu()
  369.            
  370. def login():
  371.     print("Log In")
  372.     print("*****************************")
  373.     print("***  TextLineOS - Login   ***")
  374.     print("*****************************")
  375.     print("")
  376.     username = input("Please enter your username")
  377.     password = input("Please enter your password")  
  378.     for line in open("accountfile.txt","r").readlines(): # Read the lines
  379.         login_info = line.split() # Split on the space, and store the results in a list of two strings
  380.         if username == login_info[0] and password == login_info[1]:
  381.             print("Correct credentials!")
  382.             menu()
  383.             f = open("systemlog.txt", "a")
  384.             f.write("Successful Login|User Login")
  385.             f.write("\n")
  386.             f.close()
  387.             return True
  388.     print("Incorrect credentials. - ACCESS DENIED")
  389.     login()
  390.     f = open("systemlog.txt", "a")
  391.     f.write("Failed Login-User Login")
  392.     f.write("\n")
  393.     f.close()
  394.     print("")
  395.     return False
  396.  
  397.  
  398.  
  399. login()
  400.  
  401. #f = open("systemlog.txt", "a")
  402. #f.write("SYSTEM STARTUP")
  403. #f.write("\n")
  404. #f.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top