Skip to content

Commit

Permalink
EDDN Server Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
bgol committed Jul 3, 2017
1 parent c9bc653 commit 4c82de7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

Jul 03 2017 (bgol, horizon branch):
. Updated EDAPI plugin to version 4.2.0
- Added "login option.
- EDDN Server Migration

May 31 2017 (bgol, horizon branch):
. Updated Journal plugin to ignore all events in multicrew.
. Missed the station command to output the category name.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ Frontier provides an API for their mobile app. This can be used to report accura
save: Save the API response (tmp/profile.YYYYMMDD_HHMMSS.json).
test: Test the plugin with a json file (test=[FILENAME]).
warn: Ask for station update if a API<->DB diff is encountered.
login: Ask for login credentials.

##Elite Dangerous netLog parser import plugin:

Expand Down
36 changes: 24 additions & 12 deletions plugins/edapi_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from collections import namedtuple


__version_info__ = ('4', '1', '1')
__version_info__ = ('4', '2', '0')
__version__ = '.'.join(__version_info__)

# ----------------------------------------------------------------
Expand Down Expand Up @@ -116,8 +116,15 @@ def __init__(
self.profile = response.json()
self.text = response.text
except:
sys.exit('Unable to parse JSON response for /profile!\
Try with --debug and report this.')
if self.debug:
print(' URL:', response.url)
print('status:', response.status_code)
print(' text:', response.text)
sys.exit(
"Unable to parse JSON response for /profile!"
"\nTry to relogin with the 'login' option."
"{}".format("" if self.debug else "\nTry with --debug and report this.")
)

def _getBasicURI(self, uri, values=None):
'''
Expand Down Expand Up @@ -232,23 +239,23 @@ def _doLogin(self):

class EDDN:
_gateways = (
'http://eddn-gateway.elite-markets.net:8080/upload/',
'https://eddn.edcd.io:4430/upload/',
# 'http://eddn-gateway.ed-td.space:8080/upload/',
)

_commodity_schemas = {
'production': 'http://schemas.elite-markets.net/eddn/commodity/3',
'test': 'http://schemas.elite-markets.net/eddn/commodity/3/test',
'production': 'https://eddn.edcd.io/schemas/commodity/3',
'test': 'https://eddn.edcd.io/schemas/commodity/3/test',
}

_shipyard_schemas = {
'production': 'http://schemas.elite-markets.net/eddn/shipyard/2',
'test': 'http://schemas.elite-markets.net/eddn/shipyard/2/test',
'production': 'https://eddn.edcd.io/schemas/shipyard/2',
'test': 'https://eddn.edcd.io/schemas/shipyard/2/test',
}

_outfitting_schemas = {
'production': 'http://schemas.elite-markets.net/eddn/outfitting/2',
'test': 'http://schemas.elite-markets.net/eddn/outfitting/2/test',
'production': 'https://eddn.edcd.io/schemas/outfitting/2',
'test': 'https://eddn.edcd.io/schemas/outfitting/2/test',
}

_debug = True
Expand Down Expand Up @@ -405,6 +412,7 @@ class ImportPlugin(plugins.ImportPluginBase):
'save': 'Save the API response (tmp/profile.YYYYMMDD_HHMMSS.json).',
'test': 'Test the plugin with a json file (test=[FILENAME]).',
'warn': 'Ask for station update if a API<->DB diff is encountered.',
'login': 'Ask for login credentials.',
}

cookieFile = "edapi.cookies"
Expand Down Expand Up @@ -651,7 +659,11 @@ def run(self):
"JSON-file '{}' not found.".format(str(proPath))
)
else:
api = EDAPI(cookiefile=str(self.cookiePath))
api = EDAPI(
cookiefile=str(self.cookiePath),
login=self.getOption('login'),
debug=tdenv.debug,
)
self.edAPI = api

# Sanity check that the commander is docked. Otherwise we will get a
Expand Down Expand Up @@ -910,7 +922,7 @@ def commodity_int(key):
):
eddn_modules = []
for module in api.profile['lastStarport']['modules'].values():
# see: https://github.com/jamesremuscat/EDDN/wiki
# see: https://github.com/EDSM-NET/EDDN/wiki
addModule = False
if module['name'].startswith(('Hpt_', 'Int_')) or module['name'].find('_Armour_') > 0:
if module.get('sku', None) in (
Expand Down

0 comments on commit 4c82de7

Please sign in to comment.