mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 07:47:14 +03:00
Initial work on getting the EDMC.py CLI to work under python3
*) Fix up print usage *) cPickle -> cpickle *) "EDMC.py -p <cmdr name>" appears to have never been properly updated for multi-account support.
This commit is contained in:
parent
95693edb19
commit
e9931aa348
10
EDMC.py
10
EDMC.py
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Command-line interface. Requires prior setup through the GUI.
|
||||
#
|
||||
@ -72,7 +72,7 @@ try:
|
||||
latest = ' (%s is available)' % items[lastversion]
|
||||
except:
|
||||
pass # Quietly suppress timeouts etc.
|
||||
print '%.2f%s' % (float(''.join(appversion.split('.')[:3])) / 100, latest) # just first three digits
|
||||
print('%.2f%s' % (float(''.join(appversion.split('.')[:3])) / 100, latest)) # just first three digits
|
||||
sys.exit(EXIT_SUCCESS)
|
||||
|
||||
if args.j:
|
||||
@ -92,7 +92,7 @@ try:
|
||||
monitor.parse_entry(line)
|
||||
except:
|
||||
if __debug__:
|
||||
print 'Invalid journal entry "%s"' % repr(line)
|
||||
print('Invalid journal entry "%s"' % repr(line))
|
||||
except Exception as e:
|
||||
sys.stderr.write("Can't read Journal file: %s\n" % unicode(e).encode('ascii', 'replace'))
|
||||
sys.exit(EXIT_SYS_ERR)
|
||||
@ -159,9 +159,9 @@ try:
|
||||
stats.export_status(data, args.t)
|
||||
|
||||
if data['commander'].get('docked'):
|
||||
print '%s,%s' % (data.get('lastSystem', {}).get('name', 'Unknown'), data.get('lastStarport', {}).get('name', 'Unknown'))
|
||||
print('%s,%s' % (data.get('lastSystem', {}).get('name', 'Unknown'), data.get('lastStarport', {}).get('name', 'Unknown')))
|
||||
else:
|
||||
print data.get('lastSystem', {}).get('name', 'Unknown')
|
||||
print(data.get('lastSystem', {}).get('name', 'Unknown'))
|
||||
|
||||
if (args.m or args.o or args.s or args.n or args.j):
|
||||
if not data['commander'].get('docked'):
|
||||
|
22
collate.py
22
collate.py
@ -58,7 +58,7 @@ def addcommodities(data):
|
||||
for key in sorted(commodities):
|
||||
writer.writerow(commodities[key])
|
||||
|
||||
print 'Added %d new commodities' % (len(commodities) - size_pre)
|
||||
print('Added %d new commodities' % (len(commodities) - size_pre))
|
||||
|
||||
# keep a summary of modules found
|
||||
def addmodules(data):
|
||||
@ -83,7 +83,7 @@ def addmodules(data):
|
||||
try:
|
||||
new = outfitting.lookup(module, companion.ship_map, True)
|
||||
except:
|
||||
print '%d, %s:' % (module['id'], module['name'])
|
||||
print('%d, %s:' % (module['id'], module['name']))
|
||||
print_exc(0)
|
||||
new = None
|
||||
if new:
|
||||
@ -110,7 +110,7 @@ def addmodules(data):
|
||||
for key in sorted(modules):
|
||||
writer.writerow(modules[key])
|
||||
|
||||
print 'Added %d new modules' % (len(modules) - size_pre)
|
||||
print('Added %d new modules' % (len(modules) - size_pre))
|
||||
|
||||
# keep a summary of ships found
|
||||
def addships(data):
|
||||
@ -158,33 +158,33 @@ def addships(data):
|
||||
for key in sorted(ships):
|
||||
writer.writerow(ships[key])
|
||||
|
||||
print 'Added %d new ships' % (len(ships) - size_pre)
|
||||
print('Added %d new ships' % (len(ships) - size_pre))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) <= 1:
|
||||
print 'Usage: collate.py [dump.json]'
|
||||
print('Usage: collate.py [dump.json]')
|
||||
else:
|
||||
# read from dumped json file(s)
|
||||
session = companion.Session()
|
||||
for f in sys.argv[1:]:
|
||||
with open(f) as h:
|
||||
print f
|
||||
print(f)
|
||||
data = json.load(h)
|
||||
if not data['commander'].get('docked'):
|
||||
print 'Not docked!'
|
||||
print('Not docked!')
|
||||
elif not data.get('lastStarport'):
|
||||
print 'No starport!'
|
||||
print('No starport!')
|
||||
else:
|
||||
if data['lastStarport'].get('commodities'):
|
||||
addcommodities(data)
|
||||
else:
|
||||
print 'No market'
|
||||
print('No market')
|
||||
if data['lastStarport'].get('modules'):
|
||||
addmodules(data)
|
||||
else:
|
||||
print 'No outfitting'
|
||||
print('No outfitting')
|
||||
if data['lastStarport'].get('ships'):
|
||||
addships(data)
|
||||
else:
|
||||
print 'No shipyard'
|
||||
print('No shipyard')
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Export ship loadout in E:D Shipyard plain text format
|
||||
|
||||
import cPickle
|
||||
import pickle
|
||||
from collections import defaultdict
|
||||
import os
|
||||
from os.path import join
|
||||
@ -40,7 +40,7 @@ slot_map = {
|
||||
|
||||
|
||||
# Ship masses
|
||||
ships = cPickle.load(open(join(config.respath, 'ships.p'), 'rb'))
|
||||
ships = pickle.load(open(join(config.respath, 'ships.p'), 'rb'))
|
||||
|
||||
|
||||
# Export ship loadout in E:D Shipyard plain text format
|
||||
@ -107,10 +107,10 @@ def export(data, filename=None):
|
||||
if slot.lower().startswith('slot'):
|
||||
loadout[slot[-1]].append(cr + name)
|
||||
elif __debug__ and not slot.lower().startswith('planetaryapproachsuite'):
|
||||
print 'EDShipyard: Unknown slot %s' % slot
|
||||
print('EDShipyard: Unknown slot %s' % slot)
|
||||
|
||||
except AssertionError as e:
|
||||
if __debug__: print 'EDShipyard: %s' % e
|
||||
if __debug__: print('EDShipyard: %s' % e)
|
||||
continue # Silently skip unrecognized modules
|
||||
except:
|
||||
if __debug__: raise
|
||||
|
Loading…
x
Reference in New Issue
Block a user