From 5303cc7766ae4a9b40f3c6961aaae2d700639510 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Thu, 21 Jan 2016 14:42:54 -0500 Subject: [PATCH] Add companion API, and use it. --- elite_api | 2 +- elite_info.py | 11 +++-------- update_inara.py | 19 ++++--------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/elite_api b/elite_api index 207bab7..0654796 160000 --- a/elite_api +++ b/elite_api @@ -1 +1 @@ -Subproject commit 207bab717584f69c447633642f3ece5b1864d4bc +Subproject commit 0654796a1a5d6809041695591971e3f857a9989c diff --git a/elite_info.py b/elite_info.py index 314abc3..1fe38fd 100755 --- a/elite_info.py +++ b/elite_info.py @@ -1,6 +1,6 @@ #!/usr/bin/python -from edmc.companion import Session, VerificationRequired +from elite_api import companion import argparse from pprint import pprint import os @@ -14,13 +14,8 @@ def main(): session = Session() flags = flag_parser.parse_args() - try: - session.login(settings.get('ed_companion', 'username'), settings.get('ed_companion', 'password')) - except VerificationRequired: - code = raw_input("Input Verification Code: ") - session.verify(code) - - data = session.query() + companion.login(settings.get('ed_companion', 'username'), settings.get('ed_companion', 'password')) + data = companion.get_data() # Now we have the data! if flags.dump: diff --git a/update_inara.py b/update_inara.py index 63ed32f..6322356 100755 --- a/update_inara.py +++ b/update_inara.py @@ -1,25 +1,14 @@ #!/usr/bin/python -from edmc import companion -from inara.inara import InaraSession +from elite_api import companion +from elite_api.inara import InaraSession import utils settings = utils.get_settings() -companion_session = companion.Session() inara_session = InaraSession(settings.get('inara', 'username'), settings.get('inara', 'password')) -try: - companion_session.login(settings.get('ed_companion', 'username'), settings.get('ed_companion', 'password')) -except companion.VerificationRequired: - if utils.windows_detected(): - 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) - -data = companion_session.query() -companion_session.close() +companion.login(settings.get('ed_companion', 'username'), settings.get('ed_companion', 'password')) +data = companion.get_data() inara_session.update_credits(data['commander']['credits']) inara_session.update_location(data['lastSystem']['name'])