From 0654796a1a5d6809041695591971e3f857a9989c Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Thu, 21 Jan 2016 14:42:44 -0500 Subject: [PATCH] Add companion API. --- companion.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 companion.py diff --git a/companion.py b/companion.py new file mode 100644 index 0000000..961d46e --- /dev/null +++ b/companion.py @@ -0,0 +1,20 @@ +from edmc import companion as c +import platform +import easygui + +companion_session = companion.Session() + +def login(username, password): + try: + companion_session.login(username, password) + except companion.VerificationRequired: + if platform.system() == 'Windows': + code = easygui.enterbox("Input Verification Code (check your email)", + "Verification Required") + else: + code = raw_input("Input Verification Code (check your email): ") + companion_session.verify(code) + + +def get_data(): + return companion_session.query()