def Login(): if (len(Admin.admin_dict) == 0): utils.ErrorPrint( "No record of admins... please register a few!!\n") return id = utils.IntegerInputGet("Enter admin id: ") if id not in Admin.admin_dict: utils.ErrorPrint( "Admin ID: {0} doesn't exist!!... please try again\n".format( id)) return pswd = utils.PasswdInputMatch("Enter password: "******"\n>> {0} <<\n".format(Admin.option_menu[x])) Admin.option_functions[x]()
def Login(): if (len(Customer.customer_dict) == 0): utils.ErrorPrint("No record of customers... please register!!\n") return id = utils.IntegerInputGet("Enter customer id: ") if id not in Customer.customer_dict: utils.ErrorPrint( "Customer ID: {0} doesn't exist!!... please try again\n". format(id)) return current_customer = Customer.customer_dict[id] if ((current_customer.passwd != "None") and (False == utils.PasswdInputMatch( "Enter password: "******"\n>> {0} <<\n".format(Customer.option_menu[x])) current_customer.option_functions[x]()
def Run(): Admin.login_menu[1] = "Login" Admin.login_menu[2] = "Register New Admin" Admin.login_functions[1] = Admin.Login Admin.login_functions[2] = Admin.Register Admin.option_menu[1] = "View Products" Admin.option_menu[2] = "Add Products" Admin.option_menu[3] = "Delete Products" Admin.option_menu[4] = "Modify Products" Admin.option_menu[5] = "Make Shipment" Admin.option_menu[6] = "Confirm Delivery" Admin.option_functions[1] = Admin.ViewProducts Admin.option_functions[2] = Admin.AddProducts Admin.option_functions[3] = Admin.DelProducts Admin.option_functions[4] = Admin.ModifyProducts Admin.option_functions[5] = Admin.MakeShipment Admin.option_functions[6] = Admin.ConfirmDelivery while (True): x = Admin.LoginMenuPrint() if (EXIT == x): break utils.ColorTextPrint(utils.BLUE, "\n>> {0} <<\n".format(Admin.login_menu[x])) Admin.login_functions[x]()
def PromptPrint(): dt = date.today() user = pwd.getpwuid(os.getuid()).pw_name cwd_path = os.getcwd() if cwd_path == str(Path.home()): cwd = "~" elif cwd_path == "/": cwd = "/" else: parent_path, cwd = os.path.split(cwd_path) utils.ColorTextPrint(utils.BLUE, "[{0} {1}] ".format(dt.strftime("%a %b %d"), user), True) print ("@ ", end="") utils.ColorTextPrint(utils.GREEN, "[{0}] ".format(cwd), True) print ("$ ", end="")
def ProductsBoughtPrint(self): if len(self.products_bought_dict) == 0: utils.ErrorPrint("No Products Bought yet!!\n") return utils.ColorTextPrint(utils.BLUE, "\nProducts Bought:\n") Products.HeadingPrint(True) utils.BoldPrint("{0:^15}|\n".format("Quantity")) for prod_id in sorted(self.products_bought_dict): print(Products.products_dict[prod_id], end="") print("\033[1;{0}m{1:^15}|\033[0m".format( utils.PURPLE, self.products_bought_dict[prod_id]))
def ViewPaymentOptions(self): if len(self.card_number_list) == 0: utils.ErrorPrint("Please add a Debit/Credit Card!!\n") return False utils.BoldPrint("\n|{0:^15}|{1:^20}|{2:^15}|\n".format( "S. No.", "Card Number", "Card Type")) num_list = self.card_number_list type_list = self.card_type_list for i in range(len(num_list)): utils.ColorTextPrint( utils.PURPLE, "|{0:^15}|{1:^20}|{2:^15}|\n".format(i + 1, num_list[i], type_list[i])) return True
def Print(self): if len(self.products_quantity_dict) == 0: utils.ErrorPrint("Your Cart is Empty!!\n") return utils.ColorTextPrint(utils.BLUE, "\nYour Cart:\n") Products.HeadingPrint(True) utils.BoldPrint("{0:^15}|\n".format("Quantity")) for prod_id in sorted(self.products_quantity_dict): print(Products.products_dict[prod_id], end="") print("\033[1;{0}m{1:^15}|\033[0m".format( utils.PURPLE, self.products_quantity_dict[prod_id])) utils.BoldPrint("\nTotal Amount: Rs. {0:.2f}\n".format( self.total_price))
def Run(): Guest.guest_number += 1 Guest.option_menu[1] = "View Products" Guest.option_menu[2] = "Get Registered" Guest.option_functions[1] = Admin.ViewProducts Guest.option_functions[2] = Guest.Register while (True): x = Guest.OptionMenuPrint() if (EXIT == x): break utils.ColorTextPrint(utils.BLUE, "\n>> {0} <<\n".format(Guest.option_menu[x])) Guest.option_functions[x]()
def Run(): Customer.login_menu[1] = "Login" Customer.login_functions[1] = Customer.Login Customer.option_menu[1] = "View Products" Customer.option_menu[2] = "Make Payment" Customer.option_menu[3] = "Add to Cart" Customer.option_menu[4] = "Delete from Cart" Customer.option_menu[5] = "View Cart" Customer.option_menu[6] = "Add Debit/Credit Card" Customer.option_menu[7] = "View Products Bought" while (True): x = Customer.LoginMenuPrint() if (EXIT == x): break utils.ColorTextPrint( utils.BLUE, "\n>> {0} <<\n".format(Customer.login_menu[x])) Customer.login_functions[x]()
def ls_run(args): if (args == ""): args = os.getcwd() elif (args[0] == '~'): args = TildeToHomeConvert(args) try: if not Path(args).exists(): utils.ErrorPrint("ls: cannot access {0}: no such file or directory".format(args)) return if (os.path.isfile(args)): print (args) return dir_content = os.listdir(args) for c in sorted(dir_content): if c[0] != '.': if (os.path.isdir("{0}/{1}".format(args, c))): utils.ColorTextPrint(utils.BLUE, "{0}\n".format(c), True) else: print (c) except Exception as err: utils.ErrorPrint("ls: {0}\n".format(err))