예제 #1
0
def data():
    filename = join()
    d = {}

    try:
        with open(filename, "a") as ap:
            #file size shorter than 13 bit
            if os.stat(filename).st_size <= 0:
                ap.write('nop klm:1234,0.0')
                ap.close()
                print ("Please create an account first!")
                return

            else:
                with open(filename, "r") as rd:
                    id_user = rd.read().split("\n")				#opened file in data read mode
                    for items in id_user:
                        indiv_user_info = re.split("[:,]",items)
                        #rot13() function is called for decoding
                        indiv_user_info[0] = rot13(indiv_user_info[0])
                        indiv_user_info[1],indiv_user_info[2] = str(indiv_user_info[1]),float(indiv_user_info[2])
                        d[indiv_user_info[0]] = indiv_user_info[1],indiv_user_info[2]
                    return d

    except:
        IOError or FileNotFoundError
        os.mkdir("Data")
        data()
예제 #2
0
def data():
    filename = join()
    d = {}
    new = ['Name','PIN','Amount','History']

    try:
        #file size shorter than 13 bit
        with open(filename, "a") as ap:
            if (os.path.getsize(filename)) <= 0:
                wr = csv.writer(ap)
                wr.writerow(new)
                ap.close()
                print ("Please create an account first!")
                return

            else:
                with open(filename, "r") as rd:
                        r = csv.reader(rd)
                        for indiv_user_info in r:
                            if indiv_user_info == ['Name','PIN','Amount','History']:
                                continue
                            else:
                                #rot13() function is called for decoding
                                indiv_user_info[0] = rot13(indiv_user_info[0])
                                indiv_user_info[2] = float(indiv_user_info[2])
                                d[indiv_user_info[0]] = indiv_user_info[1],indiv_user_info[2],indiv_user_info[3]
                        return d

    except:
        IOError or FileNotFoundError
        os.mkdir("Data")
        data()
예제 #3
0
def data():
    filename = join()
    d = {}
    new = ['Account Number','Name','PIN','Amount','Time','Email Address']

    try:
        #file size shorter than 13 bit
        with open(filename, "a") as ap:
            if (os.path.getsize(filename)) <= 0:
                wr = csv.writer(ap)
                wr.writerow(new)
                ap.close()
                print ("Please create an account first!")
                return

            else:
                with open(filename, "r") as rd:
                        r = csv.reader(rd)
                        for indiv_user_info in r:
                            if (indiv_user_info == ['Account Number','Name','PIN','Amount','Time','Email Address']) or (indiv_user_info == []):
                                continue
                            else:
                                try:
                                    #rot13() function is called for decoding
                                    indiv_user_info[1] = rot13(indiv_user_info[1])
                                    indiv_user_info[3] = float(indiv_user_info[3])
                                    d[indiv_user_info[0]] = indiv_user_info[1],indiv_user_info[2],indiv_user_info[3],indiv_user_info[4],indiv_user_info[5],indiv_user_info[6]

                                except IndexError:
                                    d[indiv_user_info[0]] = indiv_user_info[1],indiv_user_info[2],indiv_user_info[3],indiv_user_info[4],indiv_user_info[5],"None"
                        return d

    except (IOError or FileNotFoundError):
        os.mkdir("Data")
        data()
예제 #4
0
def del_account():
    d = data()
    filename = join()

    os.system('cls' if os.name == 'nt' else 'clear')
    acc_name = input("Delete Account\nEnter Full Name : ")

    if acc_name in d.keys():
        acc_pin = str(input("Enter 4-Digit Pin : "))

        if acc_pin == d[acc_name][0]:
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Delete Account :", acc_name)
            confirm = input("Please Confirm \n1. Yes \n2. No \n")

            if (confirm == '1') or (confirm.lower().startswith('y')):
                os.system('cls' if os.name == 'nt' else 'clear')
                del d[acc_name]

                #over_writing of existing file
                with open(filename, "w") as rd:
                    r = csv.writer(rd)
                    r.writerow(['Name', 'PIN', 'Amount', 'History'])
                    rd.close()

                with open(filename, "a") as ow:
                    for item in d.keys():
                        items = rot13(item)
                        over_write = [
                            items, d[item][0],
                            str(d[item][1]),
                            str(d[item][2])
                        ]
                        o = csv.writer(ow)
                        o.writerow(over_write)
                    ow.close()
                    print("Account Deleted Successfully! \n")
                    return login_user()

            elif (confirm == '2') or (confirm.lower().startswith('n')):
                os.system('cls' if os.name == 'nt' else 'clear')
                print("Account Not Deleted!")
                return login_user()

            else:
                os.system('cls' if os.name == 'nt' else 'clear')
                print("Account Not Deleted!")
                return login_user()

        else:
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Pin Did Not Match!")
            return login_user()

    else:
        os.system('cls' if os.name == 'nt' else 'clear')
        print("Account Does Not Exist!")
        return login_user()
예제 #5
0
def del_account():
    d = data()
    filename = join()

    os.system('cls' if os.name == 'nt' else 'clear')
    acc_name = input("Delete Account\nEnter Full Name : ")

    if acc_name in d.keys():
        acc_pin = str(input("Enter 4-Digit Pin : "))

        if acc_pin == d[acc_name][0]:
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Delete Account :", acc_name)
            confirm = input("Please Confirm \n1. Yes \n2. No \n")

            if (confirm == '1') or (confirm.lower().startswith('y')):
                os.system('cls' if os.name == 'nt' else 'clear')
                if d[acc_name] == d['abc xyz']:
                    del d[acc_name]
                else:
                    del d[acc_name], d['abc xyz']
                #over_writing of existing file
                with open(filename, "w") as rd:
                    rd.write('nop klm:1234,0.0')
                    rd.close()
                with open(filename, "a") as ow:
                    for item in d.keys():
                        items = rot13(item)
                        over_write = '\n' + items + ':' + d[item][
                            0] + ',' + str(d[item][1])
                        ow.write(over_write)
                    ow.close()
                    print("Account Deleted Successfully! \n")
                    return login_user()

            elif (confirm == '2') or (confirm.lower().startswith('n')):
                os.system('cls' if os.name == 'nt' else 'clear')
                print("Account Not Deleted!")
                return login_user()

            else:
                os.system('cls' if os.name == 'nt' else 'clear')
                print("Account Not Deleted!")
                return login_user()

        else:
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Incorrect Pin!")
            return login_user()

    else:
        os.system('cls' if os.name == 'nt' else 'clear')
        print("Account Does Not Exist!")
        return login_user()
예제 #6
0
def atm(user_name, Net_balance, Pin):
    filename = join()
    import time
    print(time.strftime("Date:%m-%h-%Y \nTime:%I:%M %p  Day:%A\n"))
    print(("Dear"), user_name + ("!"))
    print(("Welcome to YOB Service"), ('\n'))
    #User input for selection
    global net_balance
    net_balance += Net_balance
    Opr = input(
        "Please Select An Option Provided Below : \n1. Check Account Balance \n2. Deposit \n3. Withdraw \n0. Exit \n"
    )  #Starts the loop
    os.system('cls' if os.name == 'nt' else 'clear')
    if not Opr.isdigit():
        return atm(user_name, Net_balance, Pin)
    while float(Opr) != 0.0:

        if float(Opr) == 1.0:  #Prints amount in counter
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Your Acount Balance = Rs", net_balance, "\n")

        elif float(Opr) == 2.0:
            os.system('cls' if os.name == 'nt' else 'clear')
            deposit(net_balance)  #Deposit function is called

        elif float(Opr) == 3.0:
            os.system('cls' if os.name == 'nt' else 'clear')
            withdraw(net_balance)  #Withdraw function is called

        else:
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Wrong Option!")

        #Incase above condition(s) get meet
        #Loop continues untill input equals '0'
        Opr = input(
            "1. Check Account Balance \n2. Deposit \n3. Withdraw \n0. Exit \n")
        if not Opr.isdigit():
            os.system('cls' if os.name == 'nt' else 'clear')
            return atm(user_name, Net_balance, Pin)

    os.system('cls' if os.name == 'nt' else 'clear')
    print(
        "Thanks For Using ATM! \nWe Hope You Are Satisfied With Our Service.\nHave A Nice Day Ahead."
    )

    with open(filename, 'a+') as ap:
        #rot13() function is called for encoding
        enc = rot13(user_name)
        re_new = "\n" + enc + ":" + str(Pin) + "," + str(net_balance)
        ap.write(re_new)
        ap.close()
    return
예제 #7
0
def new_account():
    filename = join()
    user_name1 = input("New Account\nEnter First Name : ")
    os.system('cls' if os.name == 'nt' else 'clear')
    user_name2 = input("Enter Last Name : ")

    if (user_name1.isalpha() == False) or (user_name2.isalpha()
                                           == False) or (user_name1
                                                         == user_name2):
        os.system('cls' if os.name == 'nt' else 'clear')
        print("Invalid Name")
        return new_account()

    os.system('cls' if os.name == 'nt' else 'clear')
    pin_count = 0
    while pin_count != 3:
        print("Entries left :", (3 - pin_count))
        pin = str(input("Enter 4-Digit Pin : "))
        os.system('cls' if os.name == 'nt' else 'clear')

        if (len(pin) == 4) and (pin.isdigit() == True):
            os.system('cls' if os.name == 'nt' else 'clear')
            confirm_pin = str(input("Confirm Pin : "))

            if pin == confirm_pin:
                os.system('cls' if os.name == 'nt' else 'clear')
                print("Account Name :", user_name1 + ' ' + user_name2,
                      "\nPin :", pin)
                confirm = input("Please Confirm \n1. Yes \n2. No \n")

                if (confirm == '1') or (confirm.lower().startswith('y')):
                    os.system('cls' if os.name == 'nt' else 'clear')
                    with open(filename, "a") as wr:
                        enc_name = user_name1 + ' ' + user_name2
                        #rot13() function is called for encoding
                        enc = rot13(enc_name)
                        new = "\n" + enc + ":" + pin + ",0.0"
                        wr.write(new)
                        wr.close()
                        print("Account Created Successfully! \n")
                        return login_user()

                elif (confirm == '2') or (confirm.lower().startswith('n')):
                    os.system('cls' if os.name == 'nt' else 'clear')
                    print("Account Not Created!")
                    return login_user()

                else:
                    os.system('cls' if os.name == 'nt' else 'clear')
                    print("Account Not Created!")
                    return new_account()

            else:
                print("Your Pin Did Not Match!")
                pin_count += 1

        else:
            pin_count = pin_count
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Invalid Pin")

    os.system('cls' if os.name == 'nt' else 'clear')
    print("Account Not Created!")
    return login_user()
예제 #8
0
def atm(user_name, Net_balance, Pin, History):
    filename = join()
    import time, datetime
    print(time.strftime('Date:%d-%b-%Y \nTime:%I:%M %p  Today:%A\n'))
    print(("Dear"), user_name + ("!"))
    print(("Welcome to YOB Service"), ('\n'))
    #User input for selection
    global net_balance
    net_balance += Net_balance
    Opr = input(
        "Please Select An Option Provided Below : \n1. Check Account Balance \n2. Deposit \n3. Withdraw \n4. History \n0. Exit \n"
    )
    os.system('cls' if os.name == 'nt' else 'clear')
    if not Opr.isdigit():
        return atm(user_name, Net_balance, Pin, History)
    while int(Opr) != 0:

        #Prints amount in counter
        if int(Opr) == 1:
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Your Acount Balance = Rs", "{:,}".format(net_balance), "\n")

        #Deposit function is called
        elif int(Opr) == 2:
            os.system('cls' if os.name == 'nt' else 'clear')
            deposit(net_balance)

        #Withdraw function is called
        elif int(Opr) == 3:
            os.system('cls' if os.name == 'nt' else 'clear')
            withdraw(net_balance)

        elif int(Opr) == 4:
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Your Acount Was Previously Logged in on", History, "\n")

        else:
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Wrong Option!")

        #Incase above condition(s) get meet
        #Loop continues untill '0' is entered
        Opr = input(
            "Please Select An Option Provided Below : \n1. Check Account Balance \n2. Deposit \n3. Withdraw \n4. History \n0. Exit \n"
        )
        if not Opr.isdigit():
            Opr = 5
            os.system('cls' if os.name == 'nt' else 'clear')

    os.system('cls' if os.name == 'nt' else 'clear')
    print(
        "Thanks For Using ATM! \nWe Hope You Are Satisfied With Our Service.\nHave A Nice Day Ahead."
    )

    with open(filename, 'a+') as ap:
        #rot13() function is called for encoding
        enc = rot13(user_name)
        re_new = [
            enc,
            str(Pin),
            str(net_balance),
            time.strftime('%d-%b-%Y at %I:%M %p')
        ]
        w = csv.writer(ap)
        w.writerow(re_new)
        ap.close()
    return
예제 #9
0
def de_active_account():
    clear = ('cls' if os.name == 'nt' else 'clear')
    d = data()
    filename = join()

    os.system(clear)
    acc_no = input("Account De-activate\nEnter Account Number : ")

    if acc_no in d.keys():
        acc_pin = str(gp("Enter 4-Digit Pin : "))

        if acc_pin == d[acc_no][1]:
            os.system(clear)
            print("De-activate Account :", d[acc_no][0])
            confirm = input("Please Confirm \n1. Yes \n2. No \n")

            if (confirm == '1') or (confirm.lower().startswith('y')):
                os.system(clear)
                d[('#' + acc_no)] = d.pop(acc_no)
                #over_writing of existing file
                with open(filename, "w") as rd:
                    r = csv.writer(rd)
                    r.writerow([
                        'Account Number', 'Name', 'PIN', 'Amount', 'Time',
                        'Email Address'
                    ])
                    rd.close()

                with open(filename, "a") as ow:
                    for item in d.keys():
                        items = rot13(d[item][0])
                        over_write = [
                            item, items,
                            str(d[item][1]),
                            str(d[item][2]),
                            str(d[item][3]),
                            str(d[item][4])
                        ]
                        o = csv.writer(ow)
                        o.writerow(over_write)
                    ow.close()
                    print("Account De-Activated Successfully! \n")
                    return login_user()

            elif (confirm == '2') or (confirm.lower().startswith('n')):
                os.system(clear)
                print("Account Not De-Activated!")
                return login_user()

            else:
                os.system(clear)
                print("Account Not De-Activated!")
                return login_user()

        else:
            os.system(clear)
            print("Pin Did Not Match!")
            return login_user()

    elif ("#" + acc_no) in d.keys():
        os.system(clear)
        print("Account Is Already De-Active!")
        return login_user()

    else:
        os.system(clear)
        print("No match found!")
        return login_user()
예제 #10
0
def activate_account():
    clear = ('cls' if os.name == 'nt' else 'clear')
    d = data()
    filename = join()

    user_acc_no = str(input('Enter 12-Digit Account Number : '))
    os.system(clear)

    if not user_acc_no.isdigit():
        print('Invalid Account!')
        return login_user()

    elif user_acc_no in d.keys():
        print('Account Is Already Active!')
        return login_user()

    elif user_acc_no.isdigit():
        ch_acc_no = str('#' + user_acc_no)

        if ch_acc_no in d.keys():
            d[user_acc_no] = d.pop(ch_acc_no)
            print("Activate Account Name :", d[user_acc_no][0])
            confirm = input("Please Confirm \n1. Yes \n2. No \n")

            if (confirm == '1') or (confirm.lower().startswith('y')):
                os.system(clear)
                #over_writing of existing file
                with open(filename, "w") as rd:
                    r = csv.writer(rd)
                    r.writerow([
                        'Account Number', 'Name', 'PIN', 'Amount', 'Time',
                        'Email Address'
                    ])
                    rd.close()

                with open(filename, "a") as ow:
                    for item in d.keys():
                        items = rot13(d[item][0])
                        over_write = [
                            item, items,
                            str(d[item][1]),
                            str(d[item][2]),
                            str(d[item][3]),
                            str(d[item][4])
                        ]
                        o = csv.writer(ow)
                        o.writerow(over_write)
                    ow.close()
                    print("Account Activated Successfully! \n")
                    return login_user()

            elif (confirm == '2') or (confirm.lower().startswith('n')):
                os.system(clear)
                print("Account Not Activated!")
                return login_user()

            else:
                os.system(clear)
                print("Account Not Activated!")
                return login_user()

        else:
            os.system(clear)
            print('Account Does Not Exist')
            return login_user()
예제 #11
0
def new_account():
    clear = ('cls' if os.name == 'nt' else 'clear')
    import time, datetime

    filename = join()
    user_name1 = input("New Account\nEnter First Name : ")
    os.system(clear)
    user_name2 = input("Enter Last Name : ")

    if (user_name1.isalpha() == False) or (user_name2.isalpha()
                                           == False) or (user_name1
                                                         == user_name2):
        os.system(clear)
        print("Invalid Name!")
        return new_account()

    #auto-generated pin
    auto_gen_pin = rd.randint(1000, 9999)
    os.system(clear)

    full_name = (user_name1.lower()) + ' ' + (user_name2.lower())
    acc_no = account_no_gen(full_name)
    conf = code()
    Mail_address = input("Please Enter A Valid Email Address : ")
    if not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$",
                    Mail_address):
        os.system(clear)
        confirm_mail = "None"
        print("____INVALID-MAIL-ADDRESS____")

    else:
        MSG = "Confirming mail address!" + "\n\n" + "Account Number : " + acc_no + "\n\nYour Verification Code Is : '" + conf + "'"
        confirm_mail = sendmail(Mail_address, MSG, "Confirmation Mail")

        if (confirm_mail == True):
            os.system(clear)
            print("Verification Code Has Been Sent To Your Email Address!")
            conf_code = input("Enter Provided Code : ")
            if (conf_code.lower() == conf.lower()):
                confirm_mail = Mail_address
                os.system(clear)
                print("Email Address Verified!\n")

            else:
                os.system(clear)
                print(
                    "Invalid Code!\nYour Email Could Not Be Verified.\nYou May Try Again Later!\n"
                )
                confirm_mail = "None"

        else:
            os.system(clear)
            print(confirm_mail, '\n')
            confirm_mail = "None"

    print("Your Auto-Generated Pin : ", auto_gen_pin)
    confirm = input("Want To Use This Pin ? \n1. Yes \n2. No \n")

    if (confirm == '1') or (confirm.lower().startswith('y')):
        os.system(clear)

        print("Account Name :", user_name1 + ' ' + user_name2,
              "\nAccount Number :", acc_no, "\nPin :", auto_gen_pin)
        confirm = input("Please Confirm \n1. Yes \n2. No \n")

        if (confirm == '1') or (confirm.lower().startswith('y')):
            os.system(clear)
            with open(filename, "a+") as wr:
                #rot13() function is called for encoding
                enc = rot13(full_name)
                new = [
                    acc_no, enc, auto_gen_pin, '0.0',
                    time.strftime('%d-%b-%Y at %I:%M %p'), confirm_mail
                ]

                w = csv.writer(wr)
                w.writerow(new)
                wr.close()
                MSG = "Dear " + str(
                    full_name.upper()
                ) + "!\n\tWelcome To YOB(YOUR OWN BANK) Service. Your account is successfully created. \n\tThanks for putting your trust on our service. \n\n\nFor any queries, feel free to contact our 24 hours costumer service at: [email protected]"
                vr = sendmail(Mail_address, MSG)
                os.system(clear)
                if not (vr == True): print(vr)
                print("Account Created Successfully! \n")
                return login_user()

        elif (confirm == '2') or (confirm.lower().startswith('n')):
            os.system(clear)
            print("Account Not Created!")
            return login_user()

        else:
            os.system(clear)
            print("Account Not Created!")
            return new_account()

    else:
        os.system(clear)
        pin_count = 0
        print("Create Your Own Pin....")
        while pin_count != 3:
            print("Entries left :", (3 - pin_count))
            pin = str(gp("Enter 4-Digit Pin : "))
            os.system(clear)

            if (len(pin) == 4) and (pin.isdigit() == True):
                os.system(clear)
                confirm_pin = str(gp("Confirm Pin : "))

                if pin == confirm_pin:
                    os.system(clear)
                    print("Account Name :", user_name1 + ' ' + user_name2,
                          "\nAccount Number :", acc_no, "\nPin :", pin)
                    confirm = input("Please Confirm \n1. Yes \n2. No \n")

                    if (confirm == '1') or (confirm.lower().startswith('y')):
                        os.system(clear)
                        with open(filename, "a+") as wr:
                            #rot13() function is called for encoding
                            enc = rot13(full_name)
                            new = [
                                acc_no, enc, pin, '0.0',
                                time.strftime('%d-%b-%Y at %I:%M %p'),
                                confirm_mail
                            ]

                            w = csv.writer(wr)
                            w.writerow(new)
                            wr.close()
                            MSG = "Dear " + str(
                                full_name.upper()
                            ) + "!\n\tWelcome To YOB(YOUR OWN BANK) Service. Your account is successfully created. \n\tThanks for putting your trust on our service. \n\n\nFor any queries, feel free to contact our 24 hours costumer service at: [email protected]"
                            vr = sendmail(Mail_address, MSG)
                            os.system(clear)
                            if not (vr == True): print(vr)
                            print("Account Created Successfully! \n")
                            return login_user()

                    elif (confirm == '2') or (confirm.lower().startswith('n')):
                        os.system(clear)
                        print("Account Not Created!")
                        return login_user()

                    else:
                        os.system(clear)
                        print("Account Not Created!")
                        return new_account()

                else:
                    print("Your Pin Did Not Match!")
                    pin_count += 1

            else:
                pin_count = pin_count
                os.system(clear)
                print("Invalid Pin!")

        os.system(clear)
        print("Account Not Created!")
        return login_user()
예제 #12
0
def amount_transfer(account_no, balance, acc_no, address):
    import time, datetime
    clear = ('cls' if os.name == 'nt' else 'clear')
    os.system(clear)

    d = data()
    filename = join()
    amount = 0.0

    print(":: Amount Transfer ::")
    Inactive_account = str('#' + account_no)

    if Inactive_account in d.keys():
        os.system(clear)
        print(":: Provided Account Number Is Not Active! ::")
        return amount

    elif account_no in d.keys():
        try:
            amount = input("Enter Amount In Rupees: ")

            if float(amount) < 0.0 or ('-' in amount):
                os.system(clear)
                print(":: Please Enter Right Amount! ::\n")
                return amount_transfer(account_no, balance, acc_no, address)

            elif float(amount) > float(balance):
                os.system(clear)
                print(
                    ":: Amount Can Not Be Transferred! ::\n:: Your Acount Balance = Rs",
                    balance, "::", "\n")
                return amount_transfer(account_no, balance, acc_no, address)

            else:
                os.system(clear)
                print(":: Account Number :", account_no, "::")
                print(":: Name :", d[account_no][0], "::")
                print(":: Amount Transfer = Rs",
                      "{:,} ::".format(float(amount)), "\n")

                confirm = input("Please Confirm \n1. Yes \n2. No \n")

                if (confirm == '1') or (confirm.lower().startswith('y')):
                    with open(filename, 'a+') as ap:
                        #rot13() function is called for encoding
                        enc = rot13(d[account_no][0])
                        current_balance = balance
                        balance = str(float(d[account_no][2]) + float(amount))
                        Message = str(
                            "Amount of 'Rs " + str(amount) +
                            "' was received on " +
                            str(time.strftime('%d-%b-%Y at %I:%M %p')) +
                            ", through Account Number: " + str(acc_no))
                        re_new = [
                            account_no, enc, d[account_no][1], balance,
                            d[account_no][3], d[account_no][4], Message
                        ]
                        w = csv.writer(ap)
                        w.writerow(re_new)
                        ap.close()

                    os.system(clear)
                    MSG_from = "You Have Successfully Transferred An Amount Of Rs " + str(
                        amount) + " To A/C #" + str(
                            account_no
                        ) + "\n\nYour Net Account Balance Is Rs " + str(
                            float(current_balance) - float(amount))
                    MSG_to = "You Have Received An Amount Of Rs " + str(
                        amount) + " From A/C #" + str(
                            acc_no
                        ) + "\n\nYour Net Account Balance Is Rs " + str(
                            float(balance))
                    sendmail(address, MSG_from)
                    msg2 = sendmail(d[account_no][4], MSG_to)
                    os.system(clear)
                    if not (msg2 == True): print(msg2)
                    print(":: Amount Transferred Successfully! ::")
                    return amount
                else:
                    amount = 0
                    os.system(clear)
                    print(":: Amount Transfer Unsuccessful! ::")
                    return amount

        except ValueError as err:
            os.system(clear)
            print("Error :", err)
            print(":: Please Enter Right Amount! ::\n")
            return amount_transfer(account_no, balance, acc_no, address)
    else:
        os.system(clear)
        print(":: No Match Found! ::")
        return amount
예제 #13
0
def atm(user_name, Net_balance, Pin, History, acc_no, address):
    filename = join()
    clear = ('cls' if os.name == 'nt' else 'clear')
    #input for change of pin
    # new_pin_opt = input("Change Pin : \n1. Yes \n2. No \n")
    # os.system(clear)
    # if (new_pin_opt == '1') or (new_pin_opt.lower().startswith('y')):

    import time, datetime
    print(time.strftime('Date:%d-%b-%Y \nTime:%I:%M %p  Today:%A\n'))
    print("""
     Y     Y             000            BBBBBB
      Y   Y           00     00         B     B
       Y Y          00         00       B     B
        Y          00           00      BBBBBB
        Y           00         00       B     B
        Y             00     00         B     B
        Y                000            BBBBBB
    """)

    print(("DEAR"), (user_name.upper()) + ("!"))
    print("WELCOME TO YOB SERVICE \n")
    #User input for selection
    global net_balance
    net_balance += Net_balance
    Opr = input(
        ":: Please Select An Option Provided Below : \n1. Check Account Balance \n2. Check Acount Number \n3. Deposit \n4. Withdraw \n5. Transfer Amount \n6. Last Acive Session \n7. Change Pin  \n8. Change/Verify Mail Address \n0. Exit \n"
    )
    os.system(clear)

    if not Opr.isdigit():
        Opr = 9

    while int(Opr) != 0:

        if int(Opr) == 1:
            os.system(clear)
            print(":: Your Acount Balance = Rs", "{:,} ::".format(net_balance),
                  "\n")

        elif int(Opr) == 2:
            os.system(clear)
            print(":: Your Account Number =", acc_no, ":: \n")

        #Deposit function is called
        elif int(Opr) == 3:
            os.system(clear)
            deposit(net_balance, address)

        #Withdraw function is called
        elif int(Opr) == 4:
            os.system(clear)
            withdraw(net_balance, address)

        #Amount Transfer function is called
        elif int(Opr) == 5:
            os.system(clear)
            if net_balance < 0.0:
                print(
                    ":: Amount Can Not Be Transferred! ::\n:: Your Acount Balance = Rs",
                    balance, "::", "\n")

            else:
                account_no = input('Enter 12-Digit Account Number : ')
                if (account_no == acc_no):
                    os.system(clear)
                    print(":: Amount Transfer Not Possible! ::")
                    print(":: Provided Account Number Is Yours! ::\n")
                else:
                    amount = amount_transfer(account_no, net_balance, acc_no,
                                             address)
                    net_balance -= float(amount)

        elif int(Opr) == 6:
            os.system(clear)
            print(":: Your Acount Was Previously Logged in on", History, "::",
                  "\n")

        #Change Pin function is called
        elif int(Opr) == 7:
            os.system(clear)
            Pin = change_pin(Pin, address)

        elif int(Opr) == 8:
            os.system(clear)
            Mail_address = input(":: Please Enter A Valid Email Address : ")
            conf = code()
            MSG = "Confirming Mail Address.\n\nAccount Number : " + acc_no + "\n\nYour Verification Code Is : '" + conf + "'"

            if Mail_address == address:
                os.system(clear)
                print(
                    ":: Your Email Address Is Verified! ::\n:: Want To Change Your Address ?"
                )
                opt = input("1. Yes\n2. No \n")
                os.system(clear)

                if opt.lower().startswith("y") or opt == '1':
                    Mail_address = input(
                        ":: Please Enter A New Valid Email Address : ")

                    if Mail_address == address:
                        os.system(clear)
                        print(":: Email Address Already Verified! ::")

                    else:
                        verify = sendmail(Mail_address, MSG,
                                          "Confirmation Mail")

                        if (verify == True):
                            os.system(clear)
                            print(
                                "Verification Code Has Been Sent To Your Email Address!"
                            )
                            user_conf = input("Enter Provided Code : ")
                            if (user_conf.lower() == conf.lower()):
                                address = Mail_address
                                os.system(clear)
                                print(
                                    "Email Address Verified And Changed Successfully!\n"
                                )

                            else:
                                os.system(clear)
                                print(
                                    "Invalid Code!\nYour Email Could Not Be Verified.\nYou May Try Again Later!\n"
                                )

                        else:
                            os.system(clear)
                            print(verify)

                else:
                    print(":: Email Address Unchanged! ::")

            else:
                os.system(clear)
                verify = sendmail(Mail_address, MSG, "Confirmation Mail")

                if (verify == True):
                    os.system(clear)
                    print(
                        "Verification Code Has Been Sent To Your Email Address!"
                    )
                    user_conf = input("Enter Provided Code : ")
                    if (user_conf.lower() == conf.lower()):
                        address = Mail_address
                        os.system(clear)
                        print(
                            "Email Address Verified And Changed Successfully\n"
                        )

                    else:
                        os.system(clear)
                        print(
                            "Invalid Code!\nYour Email Could Not Be Verified.\nYou May Try Again Later!\n"
                        )

                else:
                    os.system(clear)
                    print(verify)

        else:
            os.system(clear)
            print(":: Invalid Selection! ::")

        #Incase above condition(s) get meet
        #Loop continues untill '0' is entered
        Opr = input(
            ":: Please Select An Option Provided Below : \n1. Check Account Balance \n2. Check Acount Number \n3. Deposit \n4. Withdraw \n5. Transfer Amount \n6. Last Acive Session \n7. Change Pin  \n8. Change/Verify Mail Address \n0. Exit \n"
        )
        if not Opr.isdigit():
            Opr = 9
            os.system(clear)

    os.system(clear)
    print(
        "::: Thanks For Using ATM! :::\n::: We Hope You Are Satisfied With Our Service. :::\n::: Have A Nice Day Ahead. :::"
    )
    print("About:")
    with open('About.txt', 'r') as infile:
        show = infile.read()
        print(show)

    with open(filename, 'a+') as ap:
        #rot13() function is called for encoding
        enc = rot13(user_name.lower())
        re_new = [
            acc_no, enc,
            str(Pin),
            str(net_balance),
            time.strftime('%d-%b-%Y at %I:%M %p'), address
        ]
        w = csv.writer(ap)
        w.writerow(re_new)
        ap.close()
    return