Added a --dump flag to print the raw json data from the companion API.
This commit is contained in:
parent
d5dd4f9458
commit
ed7a00a181
|
@ -1,12 +1,17 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
from companion import Session, VerificationRequired
|
from companion import Session, VerificationRequired
|
||||||
|
import argparse
|
||||||
import os
|
import os
|
||||||
import utils
|
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.")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
settings = utils.get_settings()
|
settings = utils.get_settings()
|
||||||
session = Session()
|
session = Session()
|
||||||
|
flags = flag_parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
session.login(settings.get('ed_companion', 'username'), settings.get('ed_companion', 'password'))
|
session.login(settings.get('ed_companion', 'username'), settings.get('ed_companion', 'password'))
|
||||||
|
@ -17,9 +22,12 @@ def main():
|
||||||
data = session.query()
|
data = session.query()
|
||||||
|
|
||||||
# Now we have the data!
|
# Now we have the data!
|
||||||
print "Commander %s" % data['commander']['name']
|
if flags.dump:
|
||||||
print "Credits: %s" % data['commander']['credits']
|
print data
|
||||||
print "Location: %s" % data['lastSystem']['name']
|
else:
|
||||||
|
print "Commander %s" % data['commander']['name']
|
||||||
|
print "Credits: %s" % data['commander']['credits']
|
||||||
|
print "Location: %s" % data['lastSystem']['name']
|
||||||
|
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user