-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathedce_client.py
executable file
·64 lines (49 loc) · 1.69 KB
/
edce_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import sys
if sys.version_info.major < 3:
print("You need to use Python 3.x, e.g. python3 <filename>")
exit()
import configparser
import edce.query
import edce.error
import edce.util
import edce.eddn
import edce.config
import edce.globals
import json
import argparse
edce.globals.interactive = True
edce.globals.debug = False
edce.eddn.testSchema = False
edce.eddn.schemaVersion = 3
parser = argparse.ArgumentParser()
parser.add_argument("-v","--version", help="show current version", action="store_true")
args = parser.parse_args()
if args.version:
print("EDCE Version " + edce.globals.version)
quit()
try:
#New for cAPI 2.4, will perform three queries and combine them in one string
#New paths data.commander -> data.profile.commander
res = edce.query.performQuery()
data = edce.util.edict(res)
edce.util.writeJSONLog(data.profile.commander.name,data.profile.lastSystem.name,data)
station = ""
if data.profile.commander.docked:
station = "/" + data.profile.lastStarport.name
print("CMDR:\t" + data.profile.commander.name)
print("System:\t" + data.profile.lastSystem.name + station)
if "ship" in data.profile:
if "shipName" in data.profile.ship:
print("Ship:\t" + data.profile.ship.shipName + " (" + data.profile.ship.name + ")")
else:
print("Ship:\t" + data.profile.ship.name)
if edce.config.getString('preferences','enable_eddn').lower().find('y') >= 0:
if data.profile.commander.docked:
print("Attempting to post market data to EDDN, this may take a minute...")
edce.eddn.postMarketData(data.market, data.profile.lastSystem.name)
print("Done.")
except edce.error.Error as e:
print("EDCE: " + e.message)
except:
print("Unexpected error:", sys.exc_info()[0])
raise