diff --git a/FindPath.py b/FindPath.py deleted file mode 100644 index d5ab51e..0000000 --- a/FindPath.py +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################ -try: #if started value assigned, don't run - exec(findpath()) -except: #otherwise, run - def findpath(): - #import modules - import os - import sys - import time - - #set variables - segment=[] - count=0 - dic={} - y=0 - #get file path - filepath=__file__ + "check universal functions" - - #translate windows to macOS/linux if applicable, by changing character 92 (\) to / - #then, split on the / - modfilepath=(filepath.replace(chr(92),"/")).split("/") - - for step in modfilepath: - if count==0: #ignore first, which is a "" or a "D:" - count=1 - segment.append("") - continue - segment.append(step) #adds step to path - try: - exec(open("/".join(segment)+"/universal functions.py").read()) #opens universal functions - global path_to_directory #sets global path file to the user-chosen path - path_to_directory="/".join(segment) - break - except: #if can not open universal functions file - continue - try: - open(path_to_directory+"/universal functions.py", "r").read() - return open(path_to_directory+"/universal functions.py", "r").read() - except: - sys.exit("It seems that the universal functions file cannot run!") - exec(findpath()) -############################################################################ -#All above uses os module to locate the project folder using user input - #It then opens universal functions using this path diff --git a/Assessment Task 2 - ATM System.pdf b/Great-Bank-main/PDFs and diagrams/Assessment Task 2 - ATM System.pdf similarity index 100% rename from Assessment Task 2 - ATM System.pdf rename to Great-Bank-main/PDFs and diagrams/Assessment Task 2 - ATM System.pdf diff --git a/Data Flow Diagram.drawio b/Great-Bank-main/PDFs and diagrams/Data Flow Diagram.drawio similarity index 100% rename from Data Flow Diagram.drawio rename to Great-Bank-main/PDFs and diagrams/Data Flow Diagram.drawio diff --git a/Data Flow Diagram.pdf b/Great-Bank-main/PDFs and diagrams/Data Flow Diagram.pdf similarity index 100% rename from Data Flow Diagram.pdf rename to Great-Bank-main/PDFs and diagrams/Data Flow Diagram.pdf diff --git a/README.md b/Great-Bank-main/README.md similarity index 100% rename from README.md rename to Great-Bank-main/README.md diff --git a/RUN-ME!.bat b/Great-Bank-main/RUN-ME!.bat similarity index 100% rename from RUN-ME!.bat rename to Great-Bank-main/RUN-ME!.bat diff --git a/Great-Bank-main/Scripts/Backup for essential users/users - Copy.txt b/Great-Bank-main/Scripts/Backup for essential users/users - Copy.txt new file mode 100644 index 0000000..69b1bf2 --- /dev/null +++ b/Great-Bank-main/Scripts/Backup for essential users/users - Copy.txt @@ -0,0 +1,7 @@ +Hello there. If you should not be here then you should close this. +** +ved,1234,0 +sameer,4321,1 +dunne,1111,2 +******** +david,1111,4 \ No newline at end of file diff --git a/Great-Bank-main/Scripts/balances.txt b/Great-Bank-main/Scripts/balances.txt new file mode 100644 index 0000000..788dddf --- /dev/null +++ b/Great-Bank-main/Scripts/balances.txt @@ -0,0 +1,3 @@ +Ved: 0,10000000.00 +Sameer: 1,1234373851080470.00 +Dunne: 2,1000.00Ass diff --git a/Scripts/keyboard-0.13.5-py3-none-any.whl b/Great-Bank-main/Scripts/keyboard-0.13.5-py3-none-any.whl similarity index 100% rename from Scripts/keyboard-0.13.5-py3-none-any.whl rename to Great-Bank-main/Scripts/keyboard-0.13.5-py3-none-any.whl diff --git a/Scripts/main.py b/Great-Bank-main/Scripts/main.py similarity index 55% rename from Scripts/main.py rename to Great-Bank-main/Scripts/main.py index 867b04c..50eb6f3 100644 --- a/Scripts/main.py +++ b/Great-Bank-main/Scripts/main.py @@ -1,8 +1,40 @@ +######################################################################### Importing the modules import os # imports os module + from os import get_terminal_size + import sys # imports sys module + import time # imports time module -from datetime import datetime as dm + +from datetime import datetime as dm #imports datetime + #from datetime + #module as dm + +import stat #imports stat + +import shutil #imports shutil + +import wx #imports WxPython to + #make an app and + #find the monitor + #size + +from os import system #import system + #to modify the + #os atributes + +import keyboard #import the keyboard + #module, allowing + #the script to + #send keystrokes + +######################################################################### + + + + + ######################################################################### Code for Universal Functions try: #when a function is called and it is @@ -113,12 +145,18 @@ def findpath(): #define the findpath() function -############################################################################ Class for Balance + + + +############################################################################ Balance + userlist = open("users.txt") #open the user.txt file -userdic = {} #creates a dictionary for user name and password +userdic = {} #creates a dictionary for + #user name and password -usernum = {} #and a dictionary for username and user number +usernum = {} #and a dictionary for + #username and user number for combo in userlist: #combo is user name + pin try: #tries the code underneath @@ -153,6 +191,7 @@ def findpath(): #define the findpath() function #the rest of the code charbreak=0.025 #set charbreak for slow + endbreak=0.065 #set endbreak for slow def getbal(marker, mode="read", value=0): #Defines the function @@ -405,64 +444,191 @@ def getbal(marker, mode="read", value=0): #Defines the function #can save and be #accessed by other #users + ############################################################################# + + ############################################################################# Transactions - -def deposit(user): #a function for the user to interact with and add money to their account - balance=getbal(usernum[user]) #find the amount of money in their account - wipe() #clear screen to allow new content + +def deposit(user): #a function for the user + #to interact with and + #add money to their + #account + + balance=getbal(usernum[user]) #find the amount of + #money in their + #account + + wipe() #clear screen to + #allow new content + logo(2) #display logo in corner - choice=tinput(f'\nHello, {correctcaps(user, ["all"])}. How much would you like to deposit? Type "cancel" to cancel. $').lower() #ask the user to submit deposit amount - if choice=="cancel": #if the user enters the cancel input + + choice=tinput(f'\nHello, {correctcaps(user, ["all"])}. How much would you like to deposit? Type "cancel" to cancel. $').lower() #ask the user to + #submit deposit + #amount + + if choice=="cancel": #if the user + #enters the + #cancel input + menu(user) #return to menu return #end - choice=checktype(choice) #convert choice to the highest type possibe (float > int > str) - if type(choice)==str: #if the input type entered is invalid and not "cancel" - sprint("String input is not valid! An integer or float input is required. Please try again.") #tell the user that they have entered invalid input + choice=checktype(choice) #convert choice to + #the highest type + #possibe + #(float > int > str) + + if type(choice)==str: #if the input type + #entered is invalid + #and not "cancel" + + sprint("String input is not valid! An integer or float input is required. Please try again.") #tell the user that + #they have entered + #invalid input return deposit(user) #ask again - if not choice%5 == 0 or not int(choice)>0: #if they have entered a float or integer, but it is not a valid cash combination - sprint("This amount is invalid! Only combinations of cash notes can be accepted! Please try again.") #tell the user that they have entered invalid input + if not choice%5 == 0 or not int(choice)>0: #if they have + #entered a + #float or integer, + #but it is not + #a valid cash + #combination + + sprint("This amount is invalid! Only combinations of cash notes can be accepted! Please try again.") #tell the user + #that they have + #entered invalid + #input + return deposit(user) #ask again - elif choice%5==0: #if the cash amount is a valid amount, continue on - choice=int(str(choice).replace(".0", "")) #remove the decimal from the end - getbal(usernum[user], "write", balance+int(choice)) #write the new balance to the user's line in the balances file - sprint(f"You deposit ${choice}.00 into account {correctcaps(user, ['all'])}. Your new balance is ${balance+choice}.00") #successful deposit output message - ask(user, "deposit", choice) #function to ask if the user wants to see their receipt for the deposit + + elif choice%5==0: #if the cash + #amount is a + #valid amount, + #continue on + + choice=int(str(choice).replace(".0", "")) #removes the decimal + #from the end + + getbal(usernum[user], "write", balance+int(choice)) #writes the new + #balance to the + #user's line in + #the balances file + + sprint(f"You deposit ${choice}.00 into account {correctcaps(user, ['all'])}. Your new balance is ${balance+choice}.00") #successful deposit + #output message + ask(user, "deposit", choice) #function to ask + #if the user wants + #to see their + #receipt for the + #deposit + return #end the function - input("wait why is this popped up? Maybe check the deposit function... ") #message that triggers as a debug marker if for some reason the function doesn't end + input("wait why is this popped up? Maybe check the deposit function... ") #message that triggers + #as a debug marker if + #for some reason + #the function doesn't + #end def withdraw(user): #function to deposit - balance=getbal(usernum[user]) #find the amount of money in their account - wipe() #clear screen to allow new content - logo(2) #display logo in corner - choice=tinput(f'\nHello, {correctcaps(user, ["all"])}. How much would you like to withdraw? Type "cancel" to cancel. $').lower() #interacts with user and asks for amount to withdraw - if choice=="cancel": #if the user enters the cancel input + balance=getbal(usernum[user]) #find the amount + #of money in + #their account + + wipe() #clear screen + #to allow new + #content + + logo(2) #display logo + #in corner + + choice=tinput(f'\nHello, {correctcaps(user, ["all"])}. How much would you like to withdraw? Type "cancel" to cancel. $').lower() #interacts with user + #and asks for + #amount to withdraw + + if choice=="cancel": #if the user + #enters the + #cancel input + menu(user) #return to menu return #end - choice=checktype(choice)#convert choice to the highest type possibe (float > int > str) - if type(choice)==str: #if the input type entered is invalid and not "cancel" - sprint("String input is not valid! An integer or float input is required. Please try again.") #tell the user that they have entered invalid input + choice=checktype(choice)#convert choice + #to the highest + #type possibe + #(float > int > str) + + if type(choice)==str: #if the input + #type entered + #is invalid + #and not "cancel" + + sprint("String input is not valid! An integer or float input is required. Please try again.") #tell the user + #that they have + #entered invalid + #input + return withdraw(user) #ask again - if not (choice%10==0 and choice > 40) or not choice>0: #if they have entered a float or integer, but it is not a valid cash combination (20s and 50s) - sprint("This amount is invalid! Only combinations of $20 and $50 cash notes can be withdrawn! Please try again.") #tell user what input is valid + + if not (choice%10==0 and choice > 40) or not choice>0: #if they have + #entered a float + #or integer, + #but it is not + #a valid cash + #combination + #(20s and 50s) + + sprint("This amount is invalid! Only combinations of $20 and $50 cash notes can be withdrawn! Please try again.") #tell user what + #input is valid + return withdraw(user) #ask again - if choice > balance: #checks for if the user is withdrawing too much - sprint(f"This amount is invalid! You are trying to withdraw ${choice}, but you only have ${balance} in your account!") #tell the user that they do not have enough money + + if choice > balance: #checks for if + #the user is + #withdrawing + #too much + + sprint(f"This amount is invalid! You are trying to withdraw ${choice}, but you only have ${balance} in your account!") #tell the user + #that they do + #not have + #enough money + return withdraw(user) #ask again - elif choice%5==0: #if the cash amount is a valid amount, continue on - choice=int(str(choice).replace(".0", "")) #remove the decimal from the end - getbal(usernum[user], "write", balance-int(choice)) #write the new balance to the user's line in the balances file - sprint(f"You withdraw ${choice}.00 from account {correctcaps(user, ['all'])}. Your new balance is ${balance-choice}.00") #successful withdrawl output message - ask(user, "withdraw", choice) #function to ask if the user wants to see their receipt for the withdrawl + elif choice%5==0: #if the cash + #amount is a + #valid amount, + #continue on + + choice=int(str(choice).replace(".0", "")) #remove the + #decimal from + #the end + + getbal(usernum[user], "write", balance-int(choice)) #write the new + #balance to the + #user's line + #in the balances + #file + + sprint(f"You withdraw ${choice}.00 from account {correctcaps(user, ['all'])}. Your new balance is ${balance-choice}.00") #successful withdrawl + #output message + ask(user, "withdraw", choice) #function to + #ask if the user + #wants to see + #their receipt + #for the + #withdrawl + +def receipt(user, transact, amount): #function to make a receipt + #based on the input user, + #process, and amount + + now = dm.now() #get a variable from + #current date and time -def receipt(user, transact, amount): #function to make a receipt based on the input user, process, and amount - now = dm.now() #get a variable from current date and time transactlog=(f''' {logo(0, "small", "y")} @@ -472,7 +638,8 @@ def receipt(user, transact, amount): #function to make a receipt based on the in User: {correctcaps(user, ['all'])}, PIN: {userdic[user]} Transaction: {correctcaps(transact)} of ${amount}. New Balance: ${getbal(usernum[user])} - {now.strftime('Great Bank® Ltd. %Y')}''') #an f-string that fills in a template to construct a reciept for the user. + {now.strftime('Great Bank® Ltd. %Y')}''') + #an f-string that fills in a template to construct a reciept for the user. #line 1 adds the small logo to the corner of the receipt #line 3 adds the Date and Time #line 4 adds the Location, taking the name of the user's computer and a random number between 1 and 6 @@ -483,59 +650,151 @@ def receipt(user, transact, amount): #function to make a receipt based on the in #line 9 is a fake registed company name and the year for realism a=True #boolean + i=0 # + dic={} # + slots=3 + while a==True: #until a is not true + i+=1 #count - if not os.path.exists(f"receipts/{user}/"): #Checks for if a user folder exists - os.mkdir(f"receipts/{user}/") #makes a directory for the user if none exists - for count in range(1, slots+1): #repeat three times, for reciept 1, receipt 2, and receipt 3 - try: #attempt to make a new file with count as the receipt number - receipt=open(f"receipts/{user}/receipt {count}.txt", "x") #test if receipt count exists already, if it does, throws exception - receipt.write(transactlog) #if it does not, writes the receipt contents into it + + if not os.path.exists(f"receipts/{user}/"): #Checks for if + #a user folder + #exists + + os.mkdir(f"receipts/{user}/") #makes a directory for + #the user if none exists + + for count in range(1, slots+1): #repeat three times, + #for reciept 1, + #receipt 2, and + #receipt 3 + + try: #attempt to make a + #new file with count + #as the receipt number + + receipt=open(f"receipts/{user}/receipt {count}.txt", "x") #test if receipt count + #exists already, if it + #does, throws exception + + receipt.write(transactlog) #if it does not, writes + #the receipt contents + #into it + receipt.close() #closes the file - a=False #makes a not true so that the function goes to end + + a=False #makes a not true so + #that the function + #goes to end + break #exit for loop - except: #if the file already exists - for line in open(f"receipts/{user}/receipt {count}.txt"): #opens the file that is known to exist - try: #for every line, checks if it has the date and time on it - dic[line.strip("Date and Time: ").split(" ")[2]]=count #if it is the correct line, extracts date and time, exception is thrown otherwise + + except: #if the file + #already exists + + for line in open(f"receipts/{user}/receipt {count}.txt"): #opens the file + #that is known + #to exist + + try: #for every line, checks + #if it has the date + #and time on it + + dic[line.strip("Date and Time: ").split(" ")[2]]=count #if it is the correct line, + #extracts date and time, + #exception is thrown otherwise break #end for loop - except: #if it is the wrong line + + except: #if it is + #the wrong line + pass #do nothing + count+=1 #increment to next receipt - if a==True: #will run if all receipt slots are taken - lis=[] #define an empty list - for element in dic: #each time extracted corresponds to the receipt number it was extracted from - lis.append(element) #make a list from all the keys - lis=sorted(lis) #sort the list (to find the oldest one) - count=dic[lis[0]] #sets receipt number to that of oldest receipt + if a==True: #will run if all + #receipt slots + #are taken + + lis=[] #define an empty + #list + + for element in dic: #each time extracted + #corresponds to the + #receipt number it + #was extracted from + + lis.append(element) #make a list + #from all the + #keys + + lis=sorted(lis) #sort the list + #(to find + #the oldest one) + + count=dic[lis[0]] #sets receipt number + #to that of oldest + #receipt + receipt=open(f"receipts/{user}/receipt {count}.txt", "w") #overwrite the receipt + receipt.write(transactlog) #write to the receipt + receipt.close() #close file + a=False #end the while loop return transactlog #for ask function -def ask(user, transact, amount): #function to ask the user if they want to see the receipt - transactlog=receipt(user, transact, amount) #get contents thst were written to receipt +def ask(user, transact, amount): #function to ask the user + #if they want to see + #the receipt + + transactlog=receipt(user, transact, amount) #get contents that + #were written to + #receipt logo(2) # logo in corner - print_receipt = checkinput("Would you like to print a reciept? Y|N: ") #ask the user if they wish to see the receipt - if print_receipt in ["y", "yes"]: #if they answer positively - wipe() #clear screen to make space for receipt + print_receipt = checkinput("Would you like to print a reciept? Y|N: ") #ask the user if they + #wish to see the receipt + + if print_receipt in ["y", "yes"]: #if they answer + #positively + + wipe() #clear screen to + #make space for + #receipt + logo(16) #logo in corner - print(transactlog) #print the receipt's contents - t(0.5) #wait a small bit of time - print("\nPress Ctrl+C when done reading, or wait for 10 seconds to pass.") #tell user what is happening with wait - t(10, ["interrupt"]) #wait for 10 seconds, or (due to interrupt parameter) until KeyboardInterrupt is thrown + print(transactlog) #print the receipt's + #contents + + t(0.5) #waits a small + #bit of time + + print("\nThe screen will clear in 10 seconds.") #tell user what is + #happening with + #wait + + t(10) #wait for 10 seconds, + #or (due to interrupt + #parameter) until + #KeyboardInterrupt + #is thrown + menu(user) #return to the menu + return #end #if negative input + sprint("Thank you for using the Great Bank ATM") #end message + menu(user) #return to the menu + return #end ############################################################################# @@ -543,7 +802,9 @@ def ask(user, transact, amount): #function to ask the user if they want to see t -############################################################################# Class for Miscellaneous functions + + +############################################################################# Miscellaneous functions def logo(height_in, size="large", rtn="no"): #Defines the logo() function #to print the logo in the @@ -556,21 +817,57 @@ def logo(height_in, size="large", rtn="no"): #Defines the logo() function #To use the function in combination - testforvalue("screen_height", 50) #set values for screen_width and screen_height if none exist already - wipe() #runs the wipe function - try: #attempt to set the screen_width to the columns parameter - screen_width=columns #try to do it - except: #if it can't (maybe logo invoked separately?) then - screen_width=40 #set screen_width to 40 as a default - global charbreak #charbreak for the sprint function + testforvalue("screen_height", 50) #set values for + #screen_width + #and screen_height + #if none exist + #already + + wipe() #runs the + #wipe function + + try: #attempt to + #set the + #screen_width + #to the + #columns parameter + + screen_width=columns #try to + #do it + + except: #if it can't + #(maybe logo + #invoked separately?) + #then + + screen_width=40 #set screen_width + #to 40 as a default + + global charbreak #charbreak for + #the sprint + #function + olc=charbreak #preserve charbreak - charbreak=0 #no pause between letter prints + + charbreak=0 #no pause + #between + #letter prints + global endbreak #for sprint + ole=endbreak #preserve endbreak + endbreak=0 #no pause between lines - for i in range(int(screen_width/60)): #repeat for 1/60th of the screen width + + for i in range(int(screen_width/60)): #repeat for 1/60th + #of the screen width + print("") #add a spacer to top - gap=int(screen_width/80)*" " #find the gap from the side of the screen + + gap=int(screen_width/80)*" " #find the gap + #from the side + #of the screen + log=(f''' {gap}+================================================+ {gap}ǁ GGGGGGGGGGGGG BBBBBBBBBBBBBBBBB ǁ @@ -614,28 +911,65 @@ def logo(height_in, size="large", rtn="no"): #Defines the logo() function """ #logo 2 (possibly used in future) - if size=="small": #if asking for small logo - log=("""+--------+\n |::::::::|\n |::Great:|\n |::Bank::|\n |::::::::|\n +--------+""") #small logo (done in this format because unicode can't map to linebreaks?) + if size=="small": #if asking + #for small + #logo + + log=("""+--------+\n |::::::::|\n |::Great:|\n |::Bank::|\n |::::::::|\n +--------+""") #small logo (done in + #this format because + #unicode can't map + #to linebreaks?) if rtn in ["y", "yes"]: #if returning + return log - for line in log.split("/n"): #print the logo line by line? + + for line in log.split("/n"): #print the logo + #line by line? print(line) - for j in range((screen_height-height_in)-20): #loop to space up the logo + for j in range((screen_height-height_in)-20): #loop to space + #up the logo + print("") #newlines + endbreak=ole #reset endbreak + charbreak=olc #reset charbreak -def local(s_w=32, s_h=38): #locsl function, this reads between universal start function and the local functions, starting the process. - wipe() #clear the screen for more contnet - global screen_width # - global screen_height # +def local(s_w=32, s_h=38): #local function, this + #reads between + #universal start + #function and the + #local functions, + #starting the process. + + wipe() #clear the screen + #for more contnet + + global screen_width #makes the variable + #screen_width Global + + global screen_height #makes the variable + #screen_height global + screen_width=s_w #set + screen_height=s_h #set - gap1=int((screen_width-128)/2)*" " #spacingfrom the side of the screen for 'Great' - gap2=int((screen_width-96)/2)*" " #spacing from the side of the screen for 'Bank' - print(int((screen_height-40)/4)*"\n", end="") #spacer from the top of the screen to center the text + gap1=int((screen_width-128)/2)*" " #spacingfrom the + #side of the + #screen for + #'Great' + + gap2=int((screen_width-96)/2)*" " #spacing from the + #side of the + #screen for + #'Bank' + + print(int((screen_height-40)/4)*"\n", end="") #spacer from the + #top of the + #screen to center + #the text print(f''' {gap1} GGGGGGGGGGGGG tttt {gap1} GGG::::::::::::G ttt:::t @@ -686,83 +1020,117 @@ def local(s_w=32, s_h=38): #locsl function, this reads between universal start f def login(name,password): logo(1) - if int(userdic[name])==int(password): #This checks if the login details are correct based on the dictionary made at start of script (and modified in register, maybe) - sprint(f"{correctcaps(name, ['all'])} successfully logged in.") #Displays the login was successful - - menu(name) #calls menu function, this allows the rest of the code to continue - - else: #This makes it so that if the user - #has not submitted the correct login - #then they will not be granted access - - sprint(f"This is not the PIN for user {correctcaps(name, ['all'])}. Please try again.") #displays that the user has - #entered the wrong login details + if int(userdic[name])==int(password): #This checks if the + #login details are + #correct based on + #the dictionary + #made at start + #of script (and + #modified in + #register, maybe) + + sprint(f"{correctcaps(name, ['all'])} successfully logged in.") #Displays the + #login was + #successful + + menu(name) #calls menu function, + #this allows the + #rest of the code + #to continue + + else: #This makes it so + #that if the user + #has not submitted + #the correct login + #then they will not + #be granted access + + sprint(f"This is not the PIN for user {correctcaps(name, ['all'])}. Please try again.") #displays that + #the user has + #entered the + #wrong login + #details access("login") - def register(name,password): + name=name.strip() - file = open("users.txt","a") #a+ Opens a file for both appending and reading. - # The file pointer is at the end of the file if - # the file exists. The file opens in the append mode. + + file = open("users.txt","a") #a+ Opens a file for both + #appending and reading. + # The file pointer is at + #the end of the file if + # the file exists. The + #file opens in the append mode. # If the file does not exist, - # it creates a new file for reading and writing + # it creates a new file for + #reading and writing + global nextmark - file.write(f'\n{name},{password},{nextmark}') #writes name and password to - #the user credentials file + file.write(f'\n{name},{password},{nextmark}') #writes name and + #password to + #the user credentials + #file + global userdic + userdic[name]=password global usernum + usernum[name]=nextmark file.close() #closes the file - file=open("balances.txt", "a") #open the balances text file + file=open("balances.txt", "a") #open the balances + #text file if int(nextmark)==70: amount="421.00" sprint(" YOU ARE THE 70TH CUSTOMER YOU GET $421 FREE") else: amount="10.00" sprint(f"User {correctcaps(name, ['all'])} is now registered. As a bonus, you have a free $10 in your new account.") - file.write(f"{correctcaps(name, ['all'])}: {nextmark},{amount}\n") #add an entry to the balances file for the new user, with $420. + + file.write(f"{correctcaps(name, ['all'])}: {nextmark},{amount}\n") #add an entry to the + #balances file for + #the new user, + #with $420. file.close() nextmark+=1 wipe() #clears the screen login(name,password) #runs the login function +def begin(something=""): #the beginning + #of the whole + #login thing -def begin(something=""): #the beginning of the whole login thing - if something!="": #this is a check to see if a login/register decision has already been specified. If it has, run that and end. - access(something) - return - logo(1) - access(checkinput("""Would you like to "login" to, "register", or "delete" a user? """, ["login", "register", "delete", "l", "r", "d", "exit"])) #Prompts user to input either, only asked if not specified + if something != "": # this is a + #check to see + #if a login/register + #decision has + #already been + #specified. If + #it has, run + #that and end. + + access(something) + + return + + logo(1) + + access(checkinput("""Would you like to "exit", or "login" to, "register", or "delete" a user? """, #Prompts user to input + ["exit", "e", "login", "register", "delete", "l", "r", #either, only asked + "d"])) #if not specified - -def access(option, name=""): #script to ask for username and password - option=option.lower() - wipe() - logo(3) - if option=="exit": - sys.exit("exited by initial menu") - if option=="l": - option="login" - elif option=="r": - option="register" - elif option=="d": - option="delete" - - if name=="": - - print(f"\n{correctcaps(option)}:") - name = tinput("""Enter your name, or "cancel" to cancel: """).lower() #prompts the user to input their name - if name=="cancel": - return begin() - if option in ["delete", "d"]: + + + +#----------------------------------------------------------------------------# Remaining work to comment +def delete(name): global usernum global userdic if not name in userdic: @@ -773,51 +1141,49 @@ def access(option, name=""): #script to ask for username and password return begin() else: PIN = tinput(f'To delete {name}, enter the PIN, or "cancel" to cancel: ') - if PIN=="cancel": + if PIN == "cancel": return begin() - if int(PIN)==int(userdic[name]): + if int(PIN) == int(userdic[name]): try: - file = open("users.txt").readlines() #a+ Opens a file for both appending and reading. - extra = file[:file.index("**\n")+1] #save everything above the first divisor - file = file[file.index("**\n")+1:] #remove everything above the divisior - file.remove("********\n") #remove the divisor between main accounts and extra accounts - for count, elem in enumerate(file[usernum[name]+1:], usernum[name]): - elem=elem.split(",") - elem=[str(elem[0])]+[elem[1]]+[str(int(elem[2])-1)] - elem=",".join(elem) - file[count+1] = elem - print(file) + file = open("users.txt").readlines() # a+ Opens a file for both appending and reading. + extra = file[:file.index("**\n") + 1] # save everything above the first divisor + file = file[file.index("**\n") + 1:] # remove everything above the divisior + file.remove("********\n") # remove the divisor between main accounts and extra accounts + for count, elem in enumerate(file[usernum[name] + 1:], usernum[name]): + elem = elem.split(",") + elem = [str(elem[0])] + [elem[1]] + [str(int(elem[2]) - 1)] + elem = ",".join(elem) + file[count + 1] = elem file.pop(usernum[name]) try: - ex=[] + ex = [] for count, elem in enumerate(file[3:], 3): - ex.append("\n"+str(elem)) + ex.append("\n" + str(elem)) except: pass - open("users.txt", "w").writelines(extra+file[:3]+["********"]+ex) + open("users.txt", "w").writelines(extra + file[:3] + ["********"] + ex) except: print("Part A failed") try: file2 = open("balances.txt").readlines() - for count, elem in enumerate(file2[usernum[name]+1:], usernum[name]): - ex, elem=elem.split(" ") - elem=elem.split(",") - elem=[str(int(elem[0])-1)]+[elem[1]] - elem=",".join(elem) - file2[count+1] = f'{ex} {elem}' + for count, elem in enumerate(file2[usernum[name] + 1:], usernum[name]): + ex, elem = elem.split(" ") + elem = elem.split(",") + elem = [str(int(elem[0]) - 1)] + [elem[1]] + elem = ",".join(elem) + file2[count + 1] = f'{ex} {elem}' file2.pop(usernum[name]) - usernum=dict(sorted(usernum.items(), key=lambda x: x[1])) + usernum = dict(sorted(usernum.items(), key=lambda x: x[1])) for count, elem in enumerate(usernum): - if count<=usernum[name]: + if count <= usernum[name]: continue - usernum[elem]=usernum[elem]-1 + usernum[elem] = usernum[elem] - 1 usernum.pop(name) userdic.pop(name) - file2[len(file2)-1]="\n"+str(file2[len(file2)-1].strip("\n")) open("balances.txt", "w").writelines(file2) global nextmark - nextmark-=1 + nextmark -= 1 sprint(f"User {name} deleted!") except: sys.exit(input("Part B failed")) @@ -827,46 +1193,88 @@ def access(option, name=""): #script to ask for username and password sprint("This is not the PIN!") access("delete", name) - if option in ["login", "l"] : #Checks what the user has input - #and runs the next script based on - #what they chose - - if name in userdic: - password = checkintype(f"Enter the PIN for user {correctcaps(name, ['all'])}: ", [int]) #get the user to input password - login(name,password) #runs the login function +def access(option, name=""): #script to ask + #for username + #and password + + option = option.lower() + wipe() + logo(3) + if option in ["e", "exit"]: + sprint("Shutting down. Thank you for using Great Bank ATM.") + sys.exit("exited by initial menu") + if option == "l": + option = "login" + elif option == "r": + option = "register" + elif option == "d": + option = "delete" + + if name == "": + print(f"\n{correctcaps(option)}:") + name = tinput("""Enter your name, or "cancel" to cancel: """).lower() # prompts the user to input their name + if name == "cancel": + return begin() - else: - sprint(f"The user {correctcaps(name, ['all'])} is not registered. Please try again.") - begin("login") - - elif option in ["register", "r"]: #Checks what the user has input - #and runs the next script based on - #what they chose - if name.isalnum() == False: - sprint("Sorry. You have entered invalid characters. ") - sprint("Only letters and numbers are allowed in your username ") - access("register") - if name in userdic: - sprint(f"The user {correctcaps(name, ['all'])} is already registered. Please try again.") - begin("register") - password="0" - while len(str(password))!=4 or password.isdigit() == False: - wipe() - logo(2) - print("Register: ") - password = str(tinput(f"Enter a new PIN for user {correctcaps(name, ['all'])}: ")) #prompts the user to input - if password=="cancel": #their password - return begin() - if password.isdigit() == False: - sprint("The password must only be a 4 character digit") - sprint("For example: 1234") - continue + if option in ["delete", "d"]: + delete(name) + + + if option in ["login", "l"]: #Checks what the + #user has input + #and runs the + #next script + #based on + #what they chose + + if name in userdic: - if len(password)==4: - return register(name,password) #runs the register function' + password = checkintype(f"Enter the PIN for user {correctcaps(name, ['all'])}: ", + + [int]) #get the user + #to input + #password + + login(name, password) #runs the + #login function else: - sprint("This PIN is the wrong length! The PIN needs to be four digits long and must only be digits.") + sprint(f"The user {correctcaps(name, ['all'])} is not registered. Please try again.") + begin("login") + + elif option in ["register", "r"]: #Checks what + #the user has input + #and runs the + #next script + #based on + #what they chose + + if name.isalnum() == False: + sprint("Sorry. You have entered invalid characters. ") + sprint("Only letters and numbers are allowed in your username ") + access("register") + if name in userdic: + sprint(f"The user {correctcaps(name, ['all'])} is already registered. Please try again.") + begin("register") + password = "0" + while len(str(password)) != 4 or password.isdigit() == False: + wipe() + logo(2) + print("Register: ") + password = str( + tinput(f"Enter a new PIN for user {correctcaps(name, ['all'])}: ")) # prompts the user to input + if password == "cancel": # their password + return begin() + if password.isdigit() == False: + sprint("The password must only be a 4 character digit") + sprint("For example: 1234") + continue + + if len(password) == 4: + return register(name, password) # runs the register function' + + else: + sprint("This PIN is the wrong length! The PIN needs to be four digits long and must only be digits.") ############################################################################# @@ -877,7 +1285,7 @@ def access(option, name=""): #script to ask for username and password def menu(user): balance=getbal(usernum[user]) - logo(11) + logo(9) charbreak=0.01 choice_input=checkinput(f"""Hello, {correctcaps(user, ['all'])}, your current balance is ${balance}.00 @@ -905,99 +1313,188 @@ def menu(user): ############################################################################# -#ask("ved", "robbery", 21320) -import stat -import shutil -mypath ="C:/noclear" -fname = mypath + "/" + "noclear.txt" -try: #all of this runs if the user is using the command prompt -########################################################################################################################################################## +############################################################################# Optimises user Experience in the command line + +mypath = "C:/noclear" +fname = mypath + "/" + "noclear.txt" - os.get_terminal_size() #this functiins throws an exception if the script is not running in terminal - def sprint (input_string, words_or_letters="letters", newline="yes"): #this redefines the sprint function to be terminal-friendly - space="\n" - if newline!="yes": - space="" +try:# all of this + # runs if the + # user is using + # the command + # prompt + + os.get_terminal_size() #this functions + #throws an + #exception if + #the script is + #not running in + #terminal + + def sprint(input_string, words_or_letters="letters", newline="yes"): # this redefines + # the sprint + # function to be + # terminal-friendly + + space = "\n" + if newline != "yes": + space = "" print(input_string, end=space) - t(0.045*len(input_string)) - - def tinput(instring, a="frick!"): + t(0.045 * len(input_string)) + + + def tinput(instring, a="!"): return input(instring) - def checkintype(input_string, list_of_types, letter="", slow=True): #repeat until an input is of required type - stringlist=[] - if slow==True: - iner=checktype(tinput(input_string, letter)) #make iner a float or int if possible + + + def checkintype(input_string, list_of_types, letter="", slow=True): # repeat until + # an input is + # of required + # type + + stringlist = [] + + if slow == True: + + iner = checktype(tinput(input_string, letter)) # make iner + # a float or + # int if possible + else: - iner=checktype(input(input_string)) + + iner = checktype(input(input_string)) + for value in list_of_types: - if type(iner)==value: #if type of input matches requirement - return iner #return and end strings - stringlist.append(str(value).strip("").replace("s", "", 2).replace(" ", "").replace("'", "")) #turn types into + + if type(iner) == value: # if type of + # input matches + # requirement + + return iner # return and + # end strings + + stringlist.append( + str(value).strip("").replace("s", "", 2).replace(" ", "").replace("'", "")) # turn types into + if float in list_of_types and int not in list_of_types: - if type(iner)==int: + + if type(iner) == int: return float(iner) - print(str(type(iner)).strip("").replace("s", "", 2).replace(" ", "").replace("'", "")+" is incorrect type!") #print fail - tline(liststring("Valid","",", ",stringlist)) #fail + + print(str(type(iner)).strip("").replace("s", "", 2).replace(" ", "").replace("'", + "") + " is incorrect type!") # print fail + + tline(liststring("Valid", "", ", ", stringlist)) # fail + wipe() + logo(4) - return checkintype(input_string, list_of_types, letter, slow) #run again - def checkinput(input_string, comparison_list=["y", "yes", "n", "no"], modifier_list=[""]): #asks for input until given input is in given list of accepted - mods=set(modifier_list) + + return checkintype(input_string, list_of_types, letter, slow) # run again + + + def checkinput(input_string, comparison_list=["y", "yes", "n", "no"], modifier_list=[""]): # asks for input + # until given input + # is in given + # list of accepted + mods = set(modifier_list) if "modlist" in modifier_list: sprint("modlist - Opens this menu") sprint("pc, preserve, preservecaps - Preserves Capitals") sprint("db, dev, debug, developer - Activates Debug Mode") - inn=tinput(str(input_string)) #input of given string - innn=inn - if len(mods.intersection({"pc", "preserve", "preservecaps"}))==0: - innn=innn.lower() - if len(mods.intersection({"db", "debug", "dev", "developer"}))>0: + inn = tinput(str(input_string)) # input of given string + innn = inn + if len(mods.intersection({"pc", "preserve", "preservecaps"})) == 0: + innn = innn.lower() + if len(mods.intersection({"db", "debug", "dev", "developer"})) > 0: print(innn) print(innn in comparison_list) - if innn in comparison_list: #if input is in list given, then return it - return innn #return input - else: #if input is not in given list - charbreak=0.01 - endbreak=0.05 - tline(str(inn)+" is not a valid response.") #print that it is not in list - tline(liststring("Valid","",", ",comparison_list)) #print what's valid + if innn in comparison_list: # if input is + # in list given, + # then return it + + return innn # return input + else: #if input is + #not in given list + + charbreak = 0.01 + + endbreak = 0.05 + + tline(str(inn) + " is not a valid response.") #print that it + #is not in list + + tline(liststring("Valid", "", ", ", comparison_list)) # print what's valid wipe() logo(4) - return checkinput(input_string, comparison_list) #run again - try: #attempt to delete file - try: - shutil.rmtree(mypath) - except: - os.chmod(mypath, stat.S_IWRITE) - shutil.rmtree(mypath) + return checkinput(input_string, comparison_list) # run again + + + try: # attempt to delete file + try: + shutil.rmtree(mypath) + except: + os.chmod(mypath, stat.S_IWRITE) + shutil.rmtree(mypath) except: - pass #if the file does not exist - + pass # if the file does not exist + ############################################################## - # obtained from https://stackoverflow.com/a/3129494 - import wx #import WxPython to make an app and find the monitor size - app = wx.App(False) # the wx.App object must be created first. - col, lin=wx.GetDisplaySize() # returns a tuple + app = wx.App(False) # the wx.App object + # must be created + # first. + + col, lin = wx.GetDisplaySize() # returns a tuple ############################################################## - - from os import system #import system to modify the os atributes - system(f'mode con: cols={col} lines={lin}') #change the size of the terminal window - import keyboard #import the keyboard module, allowing the script to send keystrokes - keyboard.press_and_release('F11') #this fullscreens the terminal window - -########################################################################################################################################################## -except: #this runs if they are not using the command prompt - try: #attempt to make a file that triggers the clear() function - os.makedirs(mypath,0o777) #make a folder for the file - open(fname,"w").close() #make a marker file - except: #if the file already exists + + system(f'mode con: cols={col} lines={lin}') # change the size + # of the terminal + # window + + keyboard.press_and_release('F11') # this fullscreens + # the terminal + # window + +except: #this runs if + #they are not + #using the + #command prompt + + try: #attempt to make + #a file that + #triggers the + #clear() function + + os.makedirs(mypath,0o777) #makes a folder + #for the file + + open(fname,"w").close() #makes a marker + #file + + except: #if the file + #already exists + pass - tinput("This script is recommended to be run on the command line, using the provided batch file, but if you wish to continue, press Enter: ") #Tell user + + tinput("This script is recommended to be run on the command line, using the provided batch file, but if you wish to continue, press Enter: ") #Tell user + +############################################################################# + + + + + + + + +############################################################################# Mainline of the Code wipe() sprint("loading...") wipe() start("The GREAT Bank") + +############################################################################# \ No newline at end of file diff --git a/Scripts/receipts/dunne/a.txt b/Great-Bank-main/Scripts/receipts/dunne/a.txt similarity index 100% rename from Scripts/receipts/dunne/a.txt rename to Great-Bank-main/Scripts/receipts/dunne/a.txt diff --git a/Scripts/receipts/sameer/a.txt b/Great-Bank-main/Scripts/receipts/sameer/a.txt similarity index 100% rename from Scripts/receipts/sameer/a.txt rename to Great-Bank-main/Scripts/receipts/sameer/a.txt diff --git a/Scripts/receipts/sameer/marker.txt b/Great-Bank-main/Scripts/receipts/sameer/marker.txt similarity index 100% rename from Scripts/receipts/sameer/marker.txt rename to Great-Bank-main/Scripts/receipts/sameer/marker.txt diff --git a/Scripts/receipts/sameer/receipt 1.txt b/Great-Bank-main/Scripts/receipts/sameer/receipt 1.txt similarity index 100% rename from Scripts/receipts/sameer/receipt 1.txt rename to Great-Bank-main/Scripts/receipts/sameer/receipt 1.txt diff --git a/Great-Bank-main/Scripts/receipts/sameer/receipt 2.txt b/Great-Bank-main/Scripts/receipts/sameer/receipt 2.txt new file mode 100644 index 0000000..90550fe --- /dev/null +++ b/Great-Bank-main/Scripts/receipts/sameer/receipt 2.txt @@ -0,0 +1,15 @@ + + +--------+ + |::::::::| + |::Great:| + |::Bank::| + |::::::::| + +--------+ + + Date and Time: 06/20/21 at 20:03:53. + Location: LAPTOP-FHAS41PR branch, machine #2 + Transaction ID: 65534 + User: Sameer, PIN: 4321 + Transaction: Deposit of $1324567890. + New Balance: $1234373851080470 + Great Bank Ltd. 2021 \ No newline at end of file diff --git a/Great-Bank-main/Scripts/receipts/sameer/receipt 3.txt b/Great-Bank-main/Scripts/receipts/sameer/receipt 3.txt new file mode 100644 index 0000000..cf8d7ad --- /dev/null +++ b/Great-Bank-main/Scripts/receipts/sameer/receipt 3.txt @@ -0,0 +1,15 @@ + + +--------+ + |::::::::| + |::Great:| + |::Bank::| + |::::::::| + +--------+ + + Date and Time: 06/20/21 at 20:01:22. + Location: LAPTOP-FHAS41PR branch, machine #3 + Transaction ID: 86905 + User: Sameer, PIN: 4321 + Transaction: Deposit of $1234567890. + New Balance: $1234372526512580 + Great Bank Ltd. 2021 \ No newline at end of file diff --git a/Scripts/receipts/ved/a.txt b/Great-Bank-main/Scripts/receipts/ved/a.txt similarity index 100% rename from Scripts/receipts/ved/a.txt rename to Great-Bank-main/Scripts/receipts/ved/a.txt diff --git a/Scripts/receipts/ved/receipt 1.txt b/Great-Bank-main/Scripts/receipts/ved/receipt 1.txt similarity index 100% rename from Scripts/receipts/ved/receipt 1.txt rename to Great-Bank-main/Scripts/receipts/ved/receipt 1.txt diff --git a/Scripts/receipts/ved/receipt 2.txt b/Great-Bank-main/Scripts/receipts/ved/receipt 2.txt similarity index 100% rename from Scripts/receipts/ved/receipt 2.txt rename to Great-Bank-main/Scripts/receipts/ved/receipt 2.txt diff --git a/Scripts/universal functions.py b/Great-Bank-main/Scripts/universal functions.py similarity index 100% rename from Scripts/universal functions.py rename to Great-Bank-main/Scripts/universal functions.py diff --git a/Scripts/users.txt b/Great-Bank-main/Scripts/users.txt similarity index 80% rename from Scripts/users.txt rename to Great-Bank-main/Scripts/users.txt index 247579c..0c96208 100644 --- a/Scripts/users.txt +++ b/Great-Bank-main/Scripts/users.txt @@ -3,5 +3,4 @@ Hello there. If you should not be here then you should close this. ved,1234,0 sameer,4321,1 dunne,1111,2 -******** -eric,2608,3 \ No newline at end of file +******** \ No newline at end of file diff --git a/Scripts/wxPython-4.1.1-cp39-cp39-win_amd64.whl b/Great-Bank-main/Scripts/wxPython-4.1.1-cp39-cp39-win_amd64.whl similarity index 100% rename from Scripts/wxPython-4.1.1-cp39-cp39-win_amd64.whl rename to Great-Bank-main/Scripts/wxPython-4.1.1-cp39-cp39-win_amd64.whl diff --git a/Scripts/FindPath.py b/Scripts/FindPath.py deleted file mode 100644 index d5ab51e..0000000 --- a/Scripts/FindPath.py +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################ -try: #if started value assigned, don't run - exec(findpath()) -except: #otherwise, run - def findpath(): - #import modules - import os - import sys - import time - - #set variables - segment=[] - count=0 - dic={} - y=0 - #get file path - filepath=__file__ + "check universal functions" - - #translate windows to macOS/linux if applicable, by changing character 92 (\) to / - #then, split on the / - modfilepath=(filepath.replace(chr(92),"/")).split("/") - - for step in modfilepath: - if count==0: #ignore first, which is a "" or a "D:" - count=1 - segment.append("") - continue - segment.append(step) #adds step to path - try: - exec(open("/".join(segment)+"/universal functions.py").read()) #opens universal functions - global path_to_directory #sets global path file to the user-chosen path - path_to_directory="/".join(segment) - break - except: #if can not open universal functions file - continue - try: - open(path_to_directory+"/universal functions.py", "r").read() - return open(path_to_directory+"/universal functions.py", "r").read() - except: - sys.exit("It seems that the universal functions file cannot run!") - exec(findpath()) -############################################################################ -#All above uses os module to locate the project folder using user input - #It then opens universal functions using this path diff --git a/Scripts/balances.txt b/Scripts/balances.txt deleted file mode 100644 index 39c6746..0000000 --- a/Scripts/balances.txt +++ /dev/null @@ -1,3 +0,0 @@ -Ved: 0,10000000.00 -Sameer: 1,12346911830.00 -Dunne: 2,1000.00 \ No newline at end of file diff --git a/Scripts/clock.py b/Scripts/clock.py deleted file mode 100644 index cd1b005..0000000 --- a/Scripts/clock.py +++ /dev/null @@ -1,151 +0,0 @@ -############################################################################ -try: #if started value assigned, don't run - exec(findpath()) -except: #otherwise, run - def findpath(): - #import modules - import os - import sys - import time - - #set variables - segment=[] - count=0 - dic={} - y=0 - #get file path - filepath=__file__ + "check universal functions" - - #translate windows to macOS/linux if applicable, by changing character 92 (\) to / - #then, split on the / - modfilepath=(filepath.replace(chr(92),"/")).split("/") - - for step in modfilepath: - if count==0: #ignore first, which is a "" or a "D:" - count=1 - segment.append("") - continue - segment.append(step) #adds step to path - try: - exec(open("/".join(segment)+"/universal functions.py").read()) #opens universal functions - global path_to_directory #sets global path file to the user-chosen path - path_to_directory="/".join(segment) - break - except: #if can not open universal functions file - continue - try: - open(path_to_directory+"/universal functions.py", "r").read() - return open(path_to_directory+"/universal functions.py", "r").read() - except: - sys.exit("It seems that the universal functions file cannot run!") - exec(findpath()) -############################################################################ -#All above uses os module to locate the project folder using user input - #It then opens universal functions using this path -charbreak=0.05 -endbreak=0.9 -userdic={} -user="ved" -userdic["ved"]=1234 - -def logo(height_in, size="large", rtn="no"): #a function to print the logo in the corner of the screen -Ved - try: - screen_width - except: - screen_width=40 - global charbreak #charbreak for the sprint function - olc=charbreak #preserve charbreak - charbreak=0 #no pause between letter prints - global endbreak #for sprint - ole=endbreak #preserve endbreak - endbreak=0 #no pause between lines - gap=int(screen_width/80)*" " #find the gap from the side of the screen - log=(f''' - {gap}+================================================+ - {gap}ǁ GGGGGGGGGGGGG BBBBBBBBBBBBBBBBB ǁ - {gap}ǁ GGG::::::::::::G B::::::::::::::::B ǁ - {gap}ǁ GG:::::::::::::::G B::::::BBBBBB:::::B ǁ - {gap}ǁ G:::::GGGGGGGG::::G BB:::::B B:::::B ǁ - {gap}ǁ G:::::G GGGGGG B::::B B:::::B ǁ - {gap}ǁ G:::::G B::::B B:::::B ǁ - {gap}ǁ G:::::G B::::BBBBBB:::::B ǁ - {gap}ǁ G:::::G GGGGGGGGGG B:::::::::::::BB ǁ - {gap}ǁ G:::::G G::::::::G B::::BBBBBB:::::B ǁ - {gap}ǁ G:::::G GGGGG::::G B::::B B:::::B ǁ - {gap}ǁ G:::::G G::::G B::::B B:::::B ǁ - {gap}ǁ G:::::G G::::G B::::B B:::::B ǁ - {gap}ǁ G:::::GGGGGGGG::::G BB:::::BBBBBB::::::B ǁ - {gap}ǁ GG:::::::::::::::G B:::::::::::::::::B ǁ - {gap}ǁ GGG::::::GGG:::G B::::::::::::::::B ǁ - {gap}ǁ GGGGGG GGGGreat BBBBBBBBBBBBBBBBBank ǁ - {gap}+================================================+ - ''') #the logo - if size=="small": - log=("""+-------+ -|::::::::| -|::Great:| -|::Bank::| -|::::::::| -+-------+""") - if rtn in ["y", "yes"]: - return log - sprint(log, "l") - for j in range((screen_height-height_in)-int(screen_width/80)-19): #loop to space up the logo - print("") #newlines - endbreak=ole #reset endbreak - charbreak=olc #reset charbreak - -def receipt(user, transact, amount) - from datetime import datetime as dm - import os - now = dm.now() # current date and time - transactlog=(f"""{logo(0, "small", "y")} - - {dm.now().strftime('Date and Time: %D at %H:%M:%S.')} - Location: {os.environ['COMPUTERNAME']} branch, machine #{r(1,6)} - Transaction ID: {r(20000, 500000)} - User: {correctcaps(user, ['all'])}, PIN: {userdic[user]} - Transaction: {correctcaps(transact)} of ${amount}. - """) - - a=True - while a==True: - dic={} - for count in range(1,4): - try: - a=False - receipt=open(f"receipts/{user}/receipt {count}.txt", "x") - receipt.write(transactlog) - receipt.close() - break - except: - e=0 - for line in open(f"receipts/{user}/receipt {count}.txt"): - try: - dic[line.strip("Date and Time: ").split(" ")[2]]=count - break - except: - e+=1 - count+=1 - if a==True: - lis=[] - for element in dic: - lis.append(element) - lis=sorted(lis) - count=dic[lis[0]] - receipt=open(f"receipts/{user}/receipt {count}.txt", "w") - receipt.write(transactlog) - receipt.close() - -transact=transactlist[len(transactlist)-1] -e=0 -while True and e==1: - try: - transact=transactlist[transactlist.index(transact)+1] - except: - transact=transactlist[0] - now1 = dm.now() - t(0.3) - if now1.strftime("%S")!=(dm.now()).strftime("%S"): - curtime=(dm.now()).strftime(f"Transaction {transact} processed on %D at %H:%M:%S.") - print(curtime) diff --git a/Scripts/print_file.py b/Scripts/print_file.py deleted file mode 100644 index 7a8390e..0000000 --- a/Scripts/print_file.py +++ /dev/null @@ -1,13 +0,0 @@ -import os - -try: - user -except: - user=input("Which user? ") -try: - number -except: - number=int(input("What number? ")) -while number>3 or number<0: - number=input("The current value for number, {number} is invalid! Enter a new value.") -os.startfile(os.path.dirname(os.path.realpath(__file__))+f"/receipts/{user}/receipt {number}.txt", "print")