Add a bunch of usability stuff, including GUI support in Windows.
This commit is contained in:
parent
94d34996df
commit
89335e70a9
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
easygui
|
|
@ -11,11 +11,20 @@ inara_session = InaraSession(settings.get('inara', 'username'), settings.get('in
|
|||
try:
|
||||
companion_session.login(settings.get('ed_companion', 'username'), settings.get('ed_companion', 'password'))
|
||||
except companion.VerificationRequired:
|
||||
code = raw_input("Input Verification Code: ")
|
||||
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()
|
||||
|
||||
inara_session.update_credits(data['commander']['credits'])
|
||||
inara_session.update_location(data['lastSystem']['name'])
|
||||
|
||||
companion_session.close()
|
||||
if utils.windows_detected():
|
||||
easygui.msgbox("Inara updated!")
|
||||
else:
|
||||
print("Inara updated!")
|
||||
|
|
32
utils.py
32
utils.py
|
@ -1,5 +1,7 @@
|
|||
from ConfigParser import ConfigParser
|
||||
import os
|
||||
import easygui
|
||||
import platform
|
||||
|
||||
def get_config_dir():
|
||||
return os.path.join(os.path.expanduser('~'), '.ed_tools/')
|
||||
|
@ -19,15 +21,39 @@ def get_settings():
|
|||
|
||||
return settings
|
||||
|
||||
def windows_detected():
|
||||
return platform.system() == 'Windows'
|
||||
|
||||
def _init_settings(settings, filename):
|
||||
settings.add_section('ed_companion')
|
||||
settings.add_section('inara')
|
||||
if windows_detected():
|
||||
_settings_prompt_gui(settings)
|
||||
else:
|
||||
_settings_prompt_cli(settings)
|
||||
|
||||
with open(filename, 'wb') as f:
|
||||
settings.write(f)
|
||||
|
||||
def _settings_prompt_gui(settings):
|
||||
data = []
|
||||
easygui.multenterbox(
|
||||
"Enter your E:D and Inara credentials. You only need to do this once.",
|
||||
"Authentication Data",
|
||||
["Elite Username (email address)", "Elite Password",
|
||||
"Inara Username", "Inara Password"],
|
||||
data
|
||||
)
|
||||
settings.set('ed_companion', 'username', data[0])
|
||||
settings.set('ed_companion', 'password', data[1])
|
||||
settings.set('inara', 'username', data[2])
|
||||
settings.set('inara', 'password', data[3])
|
||||
easygui.msgbox("To change your settings later, edit " + filename)
|
||||
|
||||
|
||||
def _settings_prompt_cli(settings):
|
||||
settings.set('ed_companion', 'username', raw_input("Elite Username (email address): "))
|
||||
settings.set('ed_companion', 'password', raw_input("Elite Password: "))
|
||||
settings.set('inara', 'username', raw_input("Inara Username: "))
|
||||
settings.set('inara', 'password', raw_input("Inara Password: "))
|
||||
print "To change these settings later, edit " + filename
|
||||
|
||||
with open(filename, 'wb') as f:
|
||||
settings.write(f)
|
||||
|
|
Reference in New Issue
Block a user