예제 #1
0
def ResponseAttempt(roll, password):

    response = attempt(roll, password)

    if not response:
        click.secho('Invalid Credentials, Sorry, try again',
                    fg='red',
                    bold=True)
        password = getpass.getpass("Password : "******"Password : ")
        response = attempt(roll, password)

    if not response:
        click.secho('Invalid Credentials, 3 incorrect attempts',
                    fg='red',
                    bold=True)
        exit(0)

    return response, password
예제 #2
0
def attendance(roll):
    """
    Get the credentials first
    """
    password = keyring.get_password('ERP', roll)
    saved_password = True

    if password != None:
        response = attempt(roll, password)

        if not response:
            click.echo(
                click.style('Password modified, Enter new password.',
                            fg='green',
                            bold=True))
            keyring.delete_password('ERP', roll)
            password = None

    if password == None:
        password = getpass.getpass("Password : "******"Subject Name", "Attended", "Percentage"],
                 tablefmt="fancy_grid"))

    # Store password locally if not saved already
    if not saved_password:
        ans = input("Do you want to store your password locally? (y/N) ")
        if ans == 'y':
            keyring.set_password('ERP', roll, password)
예제 #3
0
def test_attempt_none():

	when(scrapper).network(...).thenReturn(None)
	table = scrapper.attempt("16CSVWXYZ","password")
	
	assert not table

	unstub()
예제 #4
0
def test_attempt():

	with open("res/erp_standard.html") as f:
		text = f.read()

	when(scrapper).network(...).thenReturn(text)
	table = scrapper.attempt("16CSVWXYZ","password")
	
	assert len(table), 7
	assert table.keys(), ["CS4L001","CS4P001","CS4T001","CS4D001","CS6L029","CS6L002","CS6L010"]

	unstub()
예제 #5
0
def attendance(roll, password):
    """
    Fetch attendance from ERP and Pretty Print it on Terminal.
    """
    response = attempt(roll, password)
    if not response:
        click.secho('Invalid Credentials, Login failed.', fg='red', bold=True)
    else:
        table = make_table(response)
        print(
            tabulate(table,
                     headers=["Subject Name", "Attended", "Percentage"],
                     tablefmt="fancy_grid"))
예제 #6
0
def attendance(roll):
    """
    Get the credentials first
    """
    password = keyring.get_password('ERP', roll)
    if password == None:
        password = getpass.getpass("Password: "******"Do you want to store your password?(y/N)")
        if ans == 'y':
            keyring.set_password('ERP', roll, password)

    response = attempt(roll, password)
    response_ = rslt(roll, password)
    # Fetch attendance from ERP and Pretty Print it on Terminal.
    num = int(input('Enter 0 for Result and 1 for Attendance:'))
    if num == 1:

        if not response:
            click.secho('Invalid Credentials, Login failed.',
                        fg='red',
                        bold=True)
        else:
            table = attendance_table(response)
            print(
                tabulate(table,
                         headers=["Subject Name", "Attended", "Percentage"],
                         tablefmt="fancy_grid"))
    elif num == 0:
        if not response_:
            click.secho('Invalid Credentials, Login failed.',
                        fg='red',
                        bold=True)
        else:
            table = result_table(response_)
            print(
                tabulate(table,
                         headers=[
                             "Subject Code", "Subject Name", "L-T-P", "Credit",
                             "Grade"
                         ],
                         tablefmt="fancy_grid"))
예제 #7
0
파일: cli.py 프로젝트: pks18/acl
def attendance(roll):
    """
    Get the credentials first
    """
    password = keyring.get_password('ERP', roll)
    saved_password = True

    if password != None:
        response = attempt(roll, password)

        if not response:
            click.echo(
                click.style('Password modified, Enter new password.',
                            fg='green',
                            bold=True))
            keyring.delete_password('ERP', roll)
            password = None

    if password == None:
        password = getpass.getpass("Password : "******"Subject Code", "Subject Name", "Attended", "Percentage"
    ]
    show_table(attendance_table, attendance_header)

    # Fetch missed classes from ERP and Pretty Print it on Terminal.
    ans = input("Do you want to see the missed class(es) date-wise ? (y/N) ")
    if ans == 'y':
        input_subject = []
        specific_class_ans = input(
            "Do you want to see the missed class(es) of specific subject(s)? (y/N) "
        )
        if specific_class_ans == 'y':
            input_subject = [
                x for x in input(
                    "Enter the Subject code(s) seperated by spaces: ").split()
            ]

        attendance = None
        cached_yes = False

        try:
            with open(os.path.expanduser("~/.attendance_past.txt"), "r") as f:
                attendance = [line.split("\t") for line in f]
            cached_yes = input(
                "Unless your past attendance was updated recently, would you like us to use cached data? (y/N) "
            )
        except Exception:
            pass

        print("Please wait, it may take a while to fetch the information...")

        if attendance is not None and cached_yes == 'y':
            missed_class_response = MissedClassDates(roll, password,
                                                     attendance[0][0])
        else:
            missed_class_response = MissedClassDates(roll, password)
        if specific_class_ans != 'y':
            missed_class_table = make_missed_class_table(
                missed_class_response, attendance, cached_yes)
        else:
            missed_class_table = make_specific_sub_missed_class_table(
                missed_class_response, input_subject, attendance, cached_yes)
        Missed_class_headers = [
            "Subject Code", "Date", "Subject Name", "Attended"
        ]
        show_table(missed_class_table, Missed_class_headers)

    # Store password locally if not saved already
    if not saved_password:
        ans = input("Do you want to store your password locally? (y/N) ")
        if ans == 'y':
            keyring.set_password('ERP', roll, password)