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

32 lines
833 B
Python
Raw Normal View History

2015-10-26 00:51:48 +00:00
#!/usr/bin/python
2016-01-21 19:42:54 +00:00
from elite_api import companion
import argparse
from pprint import pprint
2015-10-26 00:51:48 +00:00
import os
import utils
flag_parser = argparse.ArgumentParser(description="Report information about your Elite: Dangerous character.")
flag_parser.add_argument('--dump', action='store_true', help="Dump raw data.")
2015-10-26 00:51:48 +00:00
def main():
settings = utils.get_settings()
session = Session()
flags = flag_parser.parse_args()
2015-10-26 00:51:48 +00:00
2016-01-21 19:42:54 +00:00
companion.login(settings.get('ed_companion', 'username'), settings.get('ed_companion', 'password'))
data = companion.get_data()
2015-10-26 00:51:48 +00:00
# Now we have the data!
if flags.dump:
pprint(data)
else:
print "Commander %s" % data['commander']['name']
print "Credits: %s" % data['commander']['credits']
print "Location: %s" % data['lastSystem']['name']
2015-10-26 00:51:48 +00:00
session.close()
if __name__ == "__main__":
main()