From cfa3e54a1ebb181b44e36b3980269abfdd09fd87 Mon Sep 17 00:00:00 2001 From: MadhavChoudhary Date: Fri, 4 Jan 2019 13:26:57 +0530 Subject: [PATCH 1/3] Added functionality to store the user password --- source/__init__.py | 2 +- source/cli.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/source/__init__.py b/source/__init__.py index 95d1c91..2e15522 100755 --- a/source/__init__.py +++ b/source/__init__.py @@ -3,4 +3,4 @@ from source.cli import attendance if __name__ == '__main__': - attendance() + attendance() \ No newline at end of file diff --git a/source/cli.py b/source/cli.py index 020f09a..9122f9f 100644 --- a/source/cli.py +++ b/source/cli.py @@ -1,12 +1,21 @@ import click +import keyring +import getpass from source.scrapper import attempt from tabulate import tabulate @click.command() -@click.option('-r', '--roll', prompt='Roll Number', help='Enter the Roll Number for ERP Login.') -@click.password_option('-p', '--password', prompt=True, hide_input=True, confirmation_prompt=False, - help='Enter Password for ERP Login.') -def attendance(roll, password): +def attendance(): + """ + Get the credentials first + """ + roll = input("Roll No: ") + password = keyring.get_password('ERP', roll) + if password == None: + password = getpass.getpass("Password: ") + ans = input("Do you want to store your password?(y/N)") + if ans=='y': + keyring.set_password('ERP', roll, password) """ Fetch attendance from ERP and Pretty Print it on Terminal. """ @@ -27,4 +36,4 @@ def make_table(response): row.append(data['percentage']) result.append(row) - return result + return result \ No newline at end of file From 07c0fea6f839c647546f985883eacf722142f985 Mon Sep 17 00:00:00 2001 From: MadhavChoudhary Date: Fri, 4 Jan 2019 13:36:31 +0530 Subject: [PATCH 2/3] Updated Reqirements --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 548c3b4..bea2054 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,4 @@ six==1.11.0 tabulate==0.8.2 urllib3==1.24.1 Werkzeug==0.14.1 +keyring==17.1.1 \ No newline at end of file From 1b26247aac310baf1ac85c00523cb084e16ac5c2 Mon Sep 17 00:00:00 2001 From: Aman Pratap Singh Date: Fri, 4 Jan 2019 14:58:12 +0530 Subject: [PATCH 3/3] Add Roll option for the command. --- source/cli.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/cli.py b/source/cli.py index 9122f9f..a350fd5 100644 --- a/source/cli.py +++ b/source/cli.py @@ -5,21 +5,23 @@ from tabulate import tabulate @click.command() -def attendance(): +@click.option('-r', '--roll', prompt='Roll Number', help='Enter the Roll Number for ERP Login.') +def attendance(roll): """ Get the credentials first """ - roll = input("Roll No: ") password = keyring.get_password('ERP', roll) if password == None: password = getpass.getpass("Password: ") ans = input("Do you want to store your password?(y/N)") if ans=='y': keyring.set_password('ERP', roll, password) - """ - Fetch attendance from ERP and Pretty Print it on Terminal. - """ + + + # 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: @@ -36,4 +38,4 @@ def make_table(response): row.append(data['percentage']) result.append(row) - return result \ No newline at end of file + return result