Skip to content

Commit

Permalink
Path changed to Python Standards
Browse files Browse the repository at this point in the history
  • Loading branch information
HartzFrequency committed Jun 26, 2023
1 parent 1d3bd8b commit 7c0b874
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

def write_feedback(username, feedback):
# Read the current count from the file
with open("bus-booking-system\\Database\\Feedbacks\\feedbackCount.txt", "r") as count_file:
with open("bus_booking_system\\Database\\Feedbacks\\feedbackCount.txt", "r") as count_file:
count = int(count_file.read())

# Increment the count by 1
count += 1
# Write the updated count back to the file
with open("bus-booking-system\\Database\\Feedbacks\\feedbackCount.txt", "w") as count_file:
with open("bus_booking_system\\Database\\Feedbacks\\feedbackCount.txt", "w") as count_file:
count_file.write(str(count))

# Create the new filename using the updated count and the username
filename = "bus-booking-system\\Database\\Feedbacks\\"+str((count-1))+username+".txt"
filename = "bus_booking_system\\Database\\Feedbacks\\"+str((count-1))+username+".txt"

# Write the feedback to the new file
with open(filename, "w") as feedback_file:
Expand All @@ -33,7 +33,7 @@ def write_feedback(username, feedback):

def check_credentials(username, password):
# Read the stored usernames and passwords from text files
with open('bus-booking-system\\Database\\BufferData\\CurrentUser\\username.txt', 'r') as f_username, open('bus-booking-system\\Database\\BufferData\\CurrentUser\\password.txt', 'r') as f_password:
with open('bus_booking_system\\Database\\BufferData\\CurrentUser\\username.txt', 'r') as f_username, open('bus_booking_system\\Database\\BufferData\\CurrentUser\\password.txt', 'r') as f_password:
stored_usernames = f_username.read().splitlines()
stored_passwords = f_password.read().splitlines()
# Check if the entered credentials match any of the stored values
Expand Down Expand Up @@ -81,7 +81,7 @@ def Feedback_dialog(self):
"Help us to improve",
title="Feedback Window")

with open("bus-booking-system\\Database\\BufferData\\CurrentUser\\username.txt", 'r') as file:
with open("bus_booking_system\\Database\\BufferData\\CurrentUser\\username.txt", 'r') as file:
username = file.read()
write_feedback(username, dialog.get_input())

Expand All @@ -102,19 +102,19 @@ def delete_line(file_path, line_to_delete):
if line.strip() != line_to_delete:
file.write(line)

username_file_path = 'bus-booking-system\\Database\\Modules\\SignIn_Database\\username.txt'
password_file_path = 'bus-booking-system\\Database\\Modules\\SignIn_Database\\password.txt'
username_file_path = 'bus_booking_system\\Database\\Modules\\SignIn_Database\\username.txt'
password_file_path = 'bus_booking_system\\Database\\Modules\\SignIn_Database\\password.txt'

delete_line(username_file_path, entered_username)
delete_line(password_file_path, entered_password)
with open("bus-booking-system\\Database\\Modules\\DeleteAccount\\DeleteTransition.txt", 'w') as file:
with open("bus_booking_system\\Database\\Modules\\DeleteAccount\\DeleteTransition.txt", 'w') as file:
file.write(str(True))

self.destroy()

else:
print("error")
with open("bus-booking-system\\Database\\Modules\\DeleteAccount\\DeleteTransition.txt", 'w') as file:
with open("bus_booking_system\\Database\\Modules\\DeleteAccount\\DeleteTransition.txt", 'w') as file:
file.write(str(False))
return messagebox.showerror('Error','Enter Correct Credentials')

Expand Down
18 changes: 9 additions & 9 deletions bus_booking_system/Database/Modules/SignIn_Module/SignIn_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@


customtkinter.set_appearance_mode("dark")

def check_credentials(username, password):
# Read the stored usernames and passwords from text files
with open('bus-booking-system\\Database\\Modules\\SignIn_Database\\username.txt', 'r') as f_username, open('bus-booking-system\\Database\\Modules\\SignIn_Database\\password.txt', 'r') as f_password:
with open('bus_booking_system\\Database\\Modules\\SignIn_Database\\username.txt', 'r') as f_username, open('bus_booking_system\\Database\\Modules\\SignIn_Database\\password.txt', 'r') as f_password:
stored_usernames = f_username.read().splitlines()
stored_passwords = f_password.read().splitlines()

Expand All @@ -21,7 +21,7 @@ def check_credentials(username, password):
if username == stored_username and password == stored_password:
return True

return False
return False



Expand All @@ -34,7 +34,7 @@ def __init__(self):
# OPENEING WINDOW SIZE
self.title("Login")
self.geometry(f"{1240}x{720}")
self.bg_image = customtkinter.CTkImage(Image.open("bus-booking-system\Database\Image\Background_gradient.jpg"),size=(self.width, self.height))
self.bg_image = customtkinter.CTkImage(Image.open("bus_booking_system\Database\Image\Background_gradient.jpg"),size=(self.width, self.height))
self.bg_image_label = customtkinter.CTkLabel(self, image=self.bg_image)
self.bg_image_label.grid(row=0, column=0)

Expand Down Expand Up @@ -87,13 +87,13 @@ def login_event(self):
if check_credentials(entered_username, entered_password):
self.destroy()
#writing data in buffer
with open('bus-booking-system\\Database\\BufferData\\CurrentUser\\username.txt', 'w') as username:
with open('bus_booking_system\\Database\\BufferData\\CurrentUser\\username.txt', 'w') as username:
username.write(str(entered_username))
with open('bus-booking-system\\Database\\BufferData\\CurrentUser\\password.txt', 'w') as password:
with open('bus_booking_system\\Database\\BufferData\\CurrentUser\\password.txt', 'w') as password:
password.write(str(entered_password))
#correct transition check
value = True
with open('bus-booking-system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt', 'w') as file:
with open('bus_booking_system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt', 'w') as file:
file.write(str(value))

else:
Expand All @@ -112,9 +112,9 @@ def register():
password = entry_password.get()

# Save username and password in text files
with open("bus-booking-system\\Database\\Modules\\SignIn_Database\\username.txt", "a") as username_file:
with open("bus_booking_system\\Database\\Modules\\SignIn_Database\\username.txt", "a") as username_file:
username_file.write(username+"\n")
with open("bus-booking-system\\Database\\Modules\\SignIn_Database\\password.txt", "a") as password_file:
with open("bus_booking_system\\Database\\Modules\\SignIn_Database\\password.txt", "a") as password_file:
password_file.write(password+"\n")

# print("Username:", username)
Expand Down
8 changes: 4 additions & 4 deletions bus_booking_system/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@


def Transition_LoginToMain():
with open("bus-booking-system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt", "r") as file:
with open("bus_booking_system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt", "r") as file:
content = file.read()
value = bool(content)
# For debugging
# print(value)
if not value:
exit()

with open("bus-booking-system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt", "w") as file2:
with open("bus_booking_system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt", "w") as file2:
file2.truncate(0)


Expand Down Expand Up @@ -1404,7 +1404,7 @@ def download_ticket():

# -------------------------------------------------------------------------------------------------------------

my_img = PhotoImage(file="bus-booking-system/Database/Image/Bus_for_project.png")
home_img = PhotoImage(file="bus-booking-system/Database/Image/home.png")
my_img = PhotoImage(file="bus_booking_system/Database/Image/Bus_for_project.png")
home_img = PhotoImage(file="bus_booking_system/Database/Image/home.png")
tab1()
root.mainloop()

0 comments on commit 7c0b874

Please sign in to comment.