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/update_inara.py

32 lines
981 B
Python
Raw Normal View History

2015-10-26 00:51:48 +00:00
#!/usr/bin/python
import easygui
from edmc import companion
from inara.inara import InaraSession
2015-10-26 00:51:48 +00:00
import utils
settings = utils.get_settings()
companion_session = companion.Session()
inara_session = InaraSession(settings.get('inara', 'username'), settings.get('inara', 'password'))
2015-10-26 00:51:48 +00:00
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): ")
2015-10-26 00:51:48 +00:00
companion_session.verify(code)
data = companion_session.query()
companion_session.close()
inara_session.update_credits(data['commander']['credits'])
inara_session.update_location(data['lastSystem']['name'])
2015-10-26 00:51:48 +00:00
if utils.windows_detected():
easygui.msgbox("Inara updated!")
else:
print("Inara updated!")