This repository has been archived on 2019-12-04. You can view files and clone it, but cannot push or open issues or pull requests.
inara_updater/actions.py

26 lines
825 B
Python

"""
This module mostly serves as a shim between the elite_api library and the rest of our program.
"""
from elite_api import companion
from elite_api.inara import InaraSession
def do_logins(settings):
inara_session = InaraSession(settings.get('inara', 'username'), settings.get('inara', 'password'))
companion.login(settings.get('ed_companion', 'username'), settings.get('ed_companion', 'password'))
return inara_session
def update_inara(inara_session):
data = companion.get_data()
assets = inara_session.update_credits(data['commander']['credits'])
inara_session.update_location(data['lastSystem']['name'])
return {
'cmdr': data['commander']['name'],
'location': data['lastSystem']['name'],
'credits': data['commander']['credits'],
'assets': assets,
'ship_id': data['ship']['id'],
}