mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-20 02:47:39 +03:00
Use new Beta universe Companion API server.
This commit is contained in:
parent
7ebd71b127
commit
efc1cb33b6
4
EDMC.py
4
EDMC.py
@ -84,9 +84,9 @@ try:
|
|||||||
session = companion.Session()
|
session = companion.Session()
|
||||||
if config.get('cmdrs'):
|
if config.get('cmdrs'):
|
||||||
username = config.get('fdev_usernames')[0]
|
username = config.get('fdev_usernames')[0]
|
||||||
session.login(username, config.get_password(username))
|
session.login(username, config.get_password(username), False)
|
||||||
else: # <= 2.25 not yet migrated
|
else: # <= 2.25 not yet migrated
|
||||||
session.login(config.get('username'), config.get('password'))
|
session.login(config.get('username'), config.get('password'), False)
|
||||||
querytime = int(time())
|
querytime = int(time())
|
||||||
data = session.query()
|
data = session.query()
|
||||||
config.set('querytime', querytime)
|
config.set('querytime', querytime)
|
||||||
|
@ -301,7 +301,7 @@ class AppWindow:
|
|||||||
# Migration from <= 2.25
|
# Migration from <= 2.25
|
||||||
if not config.get('cmdrs') and config.get('username') and config.get('password'):
|
if not config.get('cmdrs') and config.get('username') and config.get('password'):
|
||||||
try:
|
try:
|
||||||
self.session.login(config.get('username'), config.get('password'))
|
self.session.login(config.get('username'), config.get('password'), False)
|
||||||
data = self.session.query()
|
data = self.session.query()
|
||||||
prefs.migrate(data['commander']['name'])
|
prefs.migrate(data['commander']['name'])
|
||||||
except:
|
except:
|
||||||
@ -374,7 +374,7 @@ class AppWindow:
|
|||||||
raise companion.CredentialsError()
|
raise companion.CredentialsError()
|
||||||
idx = config.get('cmdrs').index(monitor.cmdr)
|
idx = config.get('cmdrs').index(monitor.cmdr)
|
||||||
username = config.get('fdev_usernames')[idx]
|
username = config.get('fdev_usernames')[idx]
|
||||||
self.session.login(username, config.get_password(username))
|
self.session.login(username, config.get_password(username), monitor.is_beta)
|
||||||
self.status['text'] = ''
|
self.status['text'] = ''
|
||||||
except companion.VerificationRequired:
|
except companion.VerificationRequired:
|
||||||
return prefs.AuthenticationDialog(self.w, partial(self.verify, self.login))
|
return prefs.AuthenticationDialog(self.w, partial(self.verify, self.login))
|
||||||
@ -403,8 +403,8 @@ class AppWindow:
|
|||||||
play_sound = (auto_update or int(event.type) == self.EVENT_VIRTUAL) and not config.getint('hotkey_mute')
|
play_sound = (auto_update or int(event.type) == self.EVENT_VIRTUAL) and not config.getint('hotkey_mute')
|
||||||
play_bad = False
|
play_bad = False
|
||||||
|
|
||||||
if not monitor.cmdr or not monitor.mode or monitor.is_beta or monitor.captain:
|
if not monitor.cmdr or not monitor.mode or monitor.captain:
|
||||||
return # In CQC, Beta or on crew - do nothing
|
return # In CQC or on crew - do nothing
|
||||||
|
|
||||||
if auto_update and monitor.carrying_rares():
|
if auto_update and monitor.carrying_rares():
|
||||||
# https://github.com/Marginal/EDMarketConnector/issues/92
|
# https://github.com/Marginal/EDMarketConnector/issues/92
|
||||||
@ -522,18 +522,18 @@ class AppWindow:
|
|||||||
if not old_status:
|
if not old_status:
|
||||||
self.status['text'] = _('Sending data to EDDN...')
|
self.status['text'] = _('Sending data to EDDN...')
|
||||||
self.w.update_idletasks()
|
self.w.update_idletasks()
|
||||||
self.eddn.export_commodities(data)
|
self.eddn.export_commodities(data, monitor.is_beta)
|
||||||
self.eddn.export_outfitting(data)
|
self.eddn.export_outfitting(data, monitor.is_beta)
|
||||||
if has_shipyard and not data['lastStarport'].get('ships'):
|
if has_shipyard and not data['lastStarport'].get('ships'):
|
||||||
# API is flakey about shipyard info - silently retry if missing (<1s is usually sufficient - 5s for margin).
|
# API is flakey about shipyard info - silently retry if missing (<1s is usually sufficient - 5s for margin).
|
||||||
self.w.after(int(SERVER_RETRY * 1000), self.retry_for_shipyard)
|
self.w.after(int(SERVER_RETRY * 1000), self.retry_for_shipyard)
|
||||||
else:
|
else:
|
||||||
self.eddn.export_shipyard(data)
|
self.eddn.export_shipyard(data, monitor.is_beta)
|
||||||
if not old_status:
|
if not old_status:
|
||||||
self.status['text'] = ''
|
self.status['text'] = ''
|
||||||
|
|
||||||
# Update credits and ship info and send to EDSM
|
# Update credits and ship info and send to EDSM
|
||||||
if config.getint('output') & config.OUT_SYS_EDSM:
|
if not monitor.is_beta and config.getint('output') & config.OUT_SYS_EDSM:
|
||||||
try:
|
try:
|
||||||
if data['commander'].get('credits') is not None:
|
if data['commander'].get('credits') is not None:
|
||||||
monitor.state['Credits'] = data['commander']['credits']
|
monitor.state['Credits'] = data['commander']['credits']
|
||||||
@ -544,8 +544,8 @@ class AppWindow:
|
|||||||
self.edsm.updateship(monitor.state['ShipID'],
|
self.edsm.updateship(monitor.state['ShipID'],
|
||||||
monitor.state['ShipType'],
|
monitor.state['ShipType'],
|
||||||
[
|
[
|
||||||
('linkToCoriolis', coriolis.url(data)),
|
('linkToCoriolis', coriolis.url(data, monitor.is_beta)),
|
||||||
('linkToEDShipyard', edshipyard.url(data)),
|
('linkToEDShipyard', edshipyard.url(data, monitor.is_beta)),
|
||||||
])
|
])
|
||||||
self.edsm.lastship = ship
|
self.edsm.lastship = ship
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -591,7 +591,7 @@ class AppWindow:
|
|||||||
if __debug__:
|
if __debug__:
|
||||||
print 'Retry for shipyard - ' + (data['commander'].get('docked') and (data['lastStarport'].get('ships') and 'Success' or 'Failure') or 'Undocked!')
|
print 'Retry for shipyard - ' + (data['commander'].get('docked') and (data['lastStarport'].get('ships') and 'Success' or 'Failure') or 'Undocked!')
|
||||||
if data['commander'].get('docked'): # might have undocked while we were waiting for retry in which case station data is unreliable
|
if data['commander'].get('docked'): # might have undocked while we were waiting for retry in which case station data is unreliable
|
||||||
self.eddn.export_shipyard(data)
|
self.eddn.export_shipyard(data, monitor.is_beta)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -624,8 +624,7 @@ class AppWindow:
|
|||||||
else:
|
else:
|
||||||
self.cmdr['text'] = monitor.cmdr and monitor.group and ('%s / %s' % (monitor.cmdr, monitor.group)) or monitor.cmdr or ''
|
self.cmdr['text'] = monitor.cmdr and monitor.group and ('%s / %s' % (monitor.cmdr, monitor.group)) or monitor.cmdr or ''
|
||||||
self.ship_label['text'] = _('Ship') + ':' # Main window
|
self.ship_label['text'] = _('Ship') + ':' # Main window
|
||||||
self.ship.configure(state = monitor.is_beta and tk.DISABLED or tk.NORMAL,
|
self.ship.configure(text = monitor.state['ShipName'] or companion.ship_map.get(monitor.state['ShipType'], monitor.state['ShipType']) or '',
|
||||||
text = monitor.state['ShipName'] or companion.ship_map.get(monitor.state['ShipType'], monitor.state['ShipType']) or '',
|
|
||||||
url = self.shipyard_url)
|
url = self.shipyard_url)
|
||||||
|
|
||||||
self.station['text'] = monitor.station or (EDDB.system(monitor.system) and self.STATION_UNDOCKED or '')
|
self.station['text'] = monitor.station or (EDDB.system(monitor.system) and self.STATION_UNDOCKED or '')
|
||||||
@ -686,7 +685,7 @@ class AppWindow:
|
|||||||
self.edsmpoll()
|
self.edsmpoll()
|
||||||
|
|
||||||
# Companion login - do this after EDSM so any EDSM errors don't mask login errors
|
# Companion login - do this after EDSM so any EDSM errors don't mask login errors
|
||||||
if entry['event'] in [None, 'StartUp', 'NewCommander', 'LoadGame'] and monitor.cmdr and not monitor.is_beta:
|
if entry['event'] in [None, 'StartUp', 'NewCommander', 'LoadGame'] and monitor.cmdr:
|
||||||
if config.get('cmdrs') and monitor.cmdr in config.get('cmdrs'):
|
if config.get('cmdrs') and monitor.cmdr in config.get('cmdrs'):
|
||||||
prefs.make_current(monitor.cmdr)
|
prefs.make_current(monitor.cmdr)
|
||||||
self.login()
|
self.login()
|
||||||
@ -712,7 +711,7 @@ class AppWindow:
|
|||||||
plug.notify_system_changed(timegm(strptime(entry['timestamp'], '%Y-%m-%dT%H:%M:%SZ')), monitor.system, monitor.coordinates)
|
plug.notify_system_changed(timegm(strptime(entry['timestamp'], '%Y-%m-%dT%H:%M:%SZ')), monitor.system, monitor.coordinates)
|
||||||
|
|
||||||
# Auto-Update after docking
|
# Auto-Update after docking
|
||||||
if station_changed and monitor.mode and not monitor.is_beta and not config.getint('output') & config.OUT_MKT_MANUAL and config.getint('output') & config.OUT_STATION_ANY:
|
if station_changed and monitor.mode and not config.getint('output') & config.OUT_MKT_MANUAL and config.getint('output') & config.OUT_STATION_ANY:
|
||||||
self.w.after(int(SERVER_RETRY * 1000), self.getandsend)
|
self.w.after(int(SERVER_RETRY * 1000), self.getandsend)
|
||||||
|
|
||||||
# Send interesting events to EDDN
|
# Send interesting events to EDDN
|
||||||
@ -779,8 +778,8 @@ class AppWindow:
|
|||||||
|
|
||||||
def shipyard_url(self, shipname=None):
|
def shipyard_url(self, shipname=None):
|
||||||
|
|
||||||
if not monitor.cmdr or not monitor.mode or monitor.is_beta:
|
if not monitor.cmdr or not monitor.mode:
|
||||||
return False # In CQC or Beta - do nothing
|
return False # In CQC - do nothing
|
||||||
|
|
||||||
self.status['text'] = _('Fetching data...')
|
self.status['text'] = _('Fetching data...')
|
||||||
self.w.update_idletasks()
|
self.w.update_idletasks()
|
||||||
@ -807,9 +806,9 @@ class AppWindow:
|
|||||||
else:
|
else:
|
||||||
self.status['text'] = ''
|
self.status['text'] = ''
|
||||||
if config.getint('shipyard') == config.SHIPYARD_EDSHIPYARD:
|
if config.getint('shipyard') == config.SHIPYARD_EDSHIPYARD:
|
||||||
return edshipyard.url(data)
|
return edshipyard.url(data, monitor.is_beta)
|
||||||
elif config.getint('shipyard') == config.SHIPYARD_CORIOLIS:
|
elif config.getint('shipyard') == config.SHIPYARD_CORIOLIS:
|
||||||
return coriolis.url(data)
|
return coriolis.url(data, monitor.is_beta)
|
||||||
else:
|
else:
|
||||||
assert False, config.getint('shipyard')
|
assert False, config.getint('shipyard')
|
||||||
return False
|
return False
|
||||||
|
30
companion.py
30
companion.py
@ -17,9 +17,11 @@ from config import config
|
|||||||
holdoff = 60 # be nice
|
holdoff = 60 # be nice
|
||||||
timeout = 10 # requests timeout
|
timeout = 10 # requests timeout
|
||||||
|
|
||||||
URL_LOGIN = 'https://companion.orerve.net/user/login'
|
SERVER_LIVE = 'https://companion.orerve.net'
|
||||||
URL_CONFIRM = 'https://companion.orerve.net/user/confirm'
|
SERVER_BETA = 'https://pts-companion.orerve.net'
|
||||||
URL_QUERY = 'https://companion.orerve.net/profile'
|
URL_LOGIN = '/user/login'
|
||||||
|
URL_CONFIRM = '/user/confirm'
|
||||||
|
URL_QUERY = '/profile'
|
||||||
|
|
||||||
|
|
||||||
# Map values reported by the Companion interface to names displayed in-game
|
# Map values reported by the Companion interface to names displayed in-game
|
||||||
@ -189,19 +191,20 @@ class Session:
|
|||||||
if platform=='win32' and getattr(sys, 'frozen', False):
|
if platform=='win32' and getattr(sys, 'frozen', False):
|
||||||
os.environ['REQUESTS_CA_BUNDLE'] = join(dirname(sys.executable), 'cacert.pem')
|
os.environ['REQUESTS_CA_BUNDLE'] = join(dirname(sys.executable), 'cacert.pem')
|
||||||
|
|
||||||
def login(self, username=None, password=None):
|
def login(self, username, password, is_beta):
|
||||||
if (not username or not password):
|
if (not username or not password):
|
||||||
if not self.credentials:
|
if not self.credentials:
|
||||||
raise CredentialsError()
|
raise CredentialsError()
|
||||||
else:
|
else:
|
||||||
credentials = self.credentials
|
credentials = self.credentials
|
||||||
else:
|
else:
|
||||||
credentials = { 'email' : username, 'password' : password }
|
credentials = { 'email' : username, 'password' : password, 'beta' : is_beta }
|
||||||
|
|
||||||
if self.credentials == credentials and self.state == Session.STATE_OK:
|
if self.credentials == credentials and self.state == Session.STATE_OK:
|
||||||
return # already logged in
|
return # already logged in
|
||||||
|
|
||||||
if not self.credentials or self.credentials['email'] != credentials['email']: # changed account
|
if not self.credentials or self.credentials['email'] != credentials['email'] or self.credentials['beta'] != credentials['beta']:
|
||||||
|
# changed account
|
||||||
self.close()
|
self.close()
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
self.session.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257'
|
self.session.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257'
|
||||||
@ -214,10 +217,11 @@ class Session:
|
|||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
self.server = credentials['beta'] and SERVER_BETA or SERVER_LIVE
|
||||||
self.credentials = credentials
|
self.credentials = credentials
|
||||||
self.state = Session.STATE_INIT
|
self.state = Session.STATE_INIT
|
||||||
try:
|
try:
|
||||||
r = self.session.post(URL_LOGIN, data = self.credentials, timeout=timeout)
|
r = self.session.post(self.server + URL_LOGIN, data = self.credentials, timeout=timeout)
|
||||||
except:
|
except:
|
||||||
if __debug__: print_exc()
|
if __debug__: print_exc()
|
||||||
raise ServerError()
|
raise ServerError()
|
||||||
@ -225,10 +229,10 @@ class Session:
|
|||||||
if r.status_code != requests.codes.ok or 'server error' in r.text:
|
if r.status_code != requests.codes.ok or 'server error' in r.text:
|
||||||
self.dump(r)
|
self.dump(r)
|
||||||
raise ServerError()
|
raise ServerError()
|
||||||
elif r.url == URL_LOGIN: # would have redirected away if success
|
elif r.url == self.server + URL_LOGIN: # would have redirected away if success
|
||||||
self.dump(r)
|
self.dump(r)
|
||||||
raise CredentialsError()
|
raise CredentialsError()
|
||||||
elif r.url == URL_CONFIRM: # redirected to verification page
|
elif r.url == self.server + URL_CONFIRM: # redirected to verification page
|
||||||
self.state = Session.STATE_AUTH
|
self.state = Session.STATE_AUTH
|
||||||
raise VerificationRequired()
|
raise VerificationRequired()
|
||||||
else:
|
else:
|
||||||
@ -238,8 +242,8 @@ class Session:
|
|||||||
def verify(self, code):
|
def verify(self, code):
|
||||||
if not code:
|
if not code:
|
||||||
raise VerificationRequired()
|
raise VerificationRequired()
|
||||||
r = self.session.post(URL_CONFIRM, data = {'code' : code}, timeout=timeout)
|
r = self.session.post(self.server + URL_CONFIRM, data = {'code' : code}, timeout=timeout)
|
||||||
if r.status_code != requests.codes.ok or r.url == URL_CONFIRM: # would have redirected away if success
|
if r.status_code != requests.codes.ok or r.url == self.server + URL_CONFIRM: # would have redirected away if success
|
||||||
raise VerificationRequired()
|
raise VerificationRequired()
|
||||||
self.session.cookies.save() # Save cookies now for use by command-line app
|
self.session.cookies.save() # Save cookies now for use by command-line app
|
||||||
self.login()
|
self.login()
|
||||||
@ -252,12 +256,12 @@ class Session:
|
|||||||
elif self.state == Session.STATE_AUTH:
|
elif self.state == Session.STATE_AUTH:
|
||||||
raise VerificationRequired()
|
raise VerificationRequired()
|
||||||
try:
|
try:
|
||||||
r = self.session.get(URL_QUERY, timeout=timeout)
|
r = self.session.get(self.server + URL_QUERY, timeout=timeout)
|
||||||
except:
|
except:
|
||||||
if __debug__: print_exc()
|
if __debug__: print_exc()
|
||||||
raise ServerError()
|
raise ServerError()
|
||||||
|
|
||||||
if r.status_code == requests.codes.forbidden or r.url == URL_LOGIN:
|
if r.status_code == requests.codes.forbidden or r.url == self.server + URL_LOGIN:
|
||||||
# Start again - maybe our session cookie expired?
|
# Start again - maybe our session cookie expired?
|
||||||
self.state = Session.STATE_INIT
|
self.state = Session.STATE_INIT
|
||||||
return self.query()
|
return self.query()
|
||||||
|
@ -239,14 +239,14 @@ def export(data, filename=None):
|
|||||||
|
|
||||||
|
|
||||||
# Return a URL for the current ship
|
# Return a URL for the current ship
|
||||||
def url(data):
|
def url(data, is_beta):
|
||||||
|
|
||||||
string = json.dumps(companion.ship(data), ensure_ascii=False, sort_keys=True, separators=(',', ':')) # most compact representation
|
string = json.dumps(companion.ship(data), ensure_ascii=False, sort_keys=True, separators=(',', ':')) # most compact representation
|
||||||
|
|
||||||
out = StringIO.StringIO()
|
out = StringIO.StringIO()
|
||||||
with gzip.GzipFile(fileobj=out, mode='w') as f:
|
with gzip.GzipFile(fileobj=out, mode='w') as f:
|
||||||
f.write(string)
|
f.write(string)
|
||||||
return 'https://coriolis.edcd.io/import?data=' + base64.urlsafe_b64encode(out.getvalue()).replace('=', '%3D')
|
return (is_beta and 'http://beta.coriolis.edcd.io/import?data=' or 'https://coriolis.edcd.io/import?data=') + base64.urlsafe_b64encode(out.getvalue()).replace('=', '%3D')
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
12
eddn.py
12
eddn.py
@ -139,7 +139,7 @@ class EDDN:
|
|||||||
|
|
||||||
self.parent.w.after(self.REPLAYPERIOD, self.sendreplay)
|
self.parent.w.after(self.REPLAYPERIOD, self.sendreplay)
|
||||||
|
|
||||||
def export_commodities(self, data):
|
def export_commodities(self, data, is_beta):
|
||||||
commodities = []
|
commodities = []
|
||||||
for commodity in data['lastStarport'].get('commodities') or []:
|
for commodity in data['lastStarport'].get('commodities') or []:
|
||||||
if category_map.get(commodity['categoryname'], True): # Check marketable
|
if category_map.get(commodity['categoryname'], True): # Check marketable
|
||||||
@ -159,7 +159,7 @@ class EDDN:
|
|||||||
# Don't send empty commodities list - schema won't allow it
|
# Don't send empty commodities list - schema won't allow it
|
||||||
if commodities:
|
if commodities:
|
||||||
self.send(data['commander']['name'], {
|
self.send(data['commander']['name'], {
|
||||||
'$schemaRef' : 'http://schemas.elite-markets.net/eddn/commodity/3',
|
'$schemaRef' : 'http://schemas.elite-markets.net/eddn/commodity/3' + (is_beta and '/test' or ''),
|
||||||
'message' : {
|
'message' : {
|
||||||
'systemName' : data['lastSystem']['name'],
|
'systemName' : data['lastSystem']['name'],
|
||||||
'stationName' : data['lastStarport']['name'],
|
'stationName' : data['lastStarport']['name'],
|
||||||
@ -167,11 +167,11 @@ class EDDN:
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
def export_outfitting(self, data):
|
def export_outfitting(self, data, is_beta):
|
||||||
# Don't send empty modules list - schema won't allow it
|
# Don't send empty modules list - schema won't allow it
|
||||||
if data['lastStarport'].get('modules'):
|
if data['lastStarport'].get('modules'):
|
||||||
self.send(data['commander']['name'], {
|
self.send(data['commander']['name'], {
|
||||||
'$schemaRef' : 'http://schemas.elite-markets.net/eddn/outfitting/2',
|
'$schemaRef' : 'http://schemas.elite-markets.net/eddn/outfitting/2' + (is_beta and '/test' or ''),
|
||||||
'message' : {
|
'message' : {
|
||||||
'systemName' : data['lastSystem']['name'],
|
'systemName' : data['lastSystem']['name'],
|
||||||
'stationName' : data['lastStarport']['name'],
|
'stationName' : data['lastStarport']['name'],
|
||||||
@ -179,11 +179,11 @@ class EDDN:
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
def export_shipyard(self, data):
|
def export_shipyard(self, data, is_beta):
|
||||||
# Don't send empty ships list - shipyard data is only guaranteed present if user has visited the shipyard.
|
# Don't send empty ships list - shipyard data is only guaranteed present if user has visited the shipyard.
|
||||||
if data['lastStarport'].get('ships'):
|
if data['lastStarport'].get('ships'):
|
||||||
self.send(data['commander']['name'], {
|
self.send(data['commander']['name'], {
|
||||||
'$schemaRef' : 'http://schemas.elite-markets.net/eddn/shipyard/2',
|
'$schemaRef' : 'http://schemas.elite-markets.net/eddn/shipyard/2' + (is_beta and '/test' or ''),
|
||||||
'message' : {
|
'message' : {
|
||||||
'systemName' : data['lastSystem']['name'],
|
'systemName' : data['lastSystem']['name'],
|
||||||
'stationName' : data['lastStarport']['name'],
|
'stationName' : data['lastStarport']['name'],
|
||||||
|
@ -152,11 +152,11 @@ def export(data, filename=None):
|
|||||||
|
|
||||||
|
|
||||||
# Return a URL for the current ship
|
# Return a URL for the current ship
|
||||||
def url(data):
|
def url(data, is_beta):
|
||||||
|
|
||||||
string = json.dumps(companion.ship(data), ensure_ascii=False, sort_keys=True, separators=(',', ':')) # most compact representation
|
string = json.dumps(companion.ship(data), ensure_ascii=False, sort_keys=True, separators=(',', ':')) # most compact representation
|
||||||
|
|
||||||
out = StringIO.StringIO()
|
out = StringIO.StringIO()
|
||||||
with gzip.GzipFile(fileobj=out, mode='w') as f:
|
with gzip.GzipFile(fileobj=out, mode='w') as f:
|
||||||
f.write(string)
|
f.write(string)
|
||||||
return 'http://www.edshipyard.com/#/I=' + base64.urlsafe_b64encode(out.getvalue()).replace('=', '%3D')
|
return (is_beta and 'http://www.edshipyard.com/beta/#/I=' or 'http://www.edshipyard.com/#/I=') + base64.urlsafe_b64encode(out.getvalue()).replace('=', '%3D')
|
||||||
|
18
prefs.py
18
prefs.py
@ -111,7 +111,7 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
self.cmdr_text.grid(row=10, column=1, padx=PADX, pady=PADY, sticky=tk.W)
|
self.cmdr_text.grid(row=10, column=1, padx=PADX, pady=PADY, sticky=tk.W)
|
||||||
self.username = nb.Entry(credframe)
|
self.username = nb.Entry(credframe)
|
||||||
self.username.grid(row=11, column=1, padx=PADX, pady=PADY, sticky=tk.EW)
|
self.username.grid(row=11, column=1, padx=PADX, pady=PADY, sticky=tk.EW)
|
||||||
if not monitor.is_beta and monitor.cmdr:
|
if monitor.cmdr:
|
||||||
self.username.focus_set()
|
self.username.focus_set()
|
||||||
self.password = nb.Entry(credframe, show=u'•')
|
self.password = nb.Entry(credframe, show=u'•')
|
||||||
self.password.grid(row=12, column=1, padx=PADX, pady=PADY, sticky=tk.EW)
|
self.password.grid(row=12, column=1, padx=PADX, pady=PADY, sticky=tk.EW)
|
||||||
@ -400,7 +400,7 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
self.edsm_apikey.insert(0, config.get('edsm_apikey') or '')
|
self.edsm_apikey.insert(0, config.get('edsm_apikey') or '')
|
||||||
self.cmdr = monitor.cmdr
|
self.cmdr = monitor.cmdr
|
||||||
|
|
||||||
cmdr_state = not monitor.is_beta and monitor.cmdr and tk.NORMAL or tk.DISABLED
|
cmdr_state = monitor.cmdr and tk.NORMAL or tk.DISABLED
|
||||||
self.cred_label['state'] = self.cmdr_label['state'] = self.username_label['state'] = self.password_label['state'] = cmdr_state
|
self.cred_label['state'] = self.cmdr_label['state'] = self.username_label['state'] = self.password_label['state'] = cmdr_state
|
||||||
self.cmdr_text['state'] = self.username['state'] = self.password['state'] = cmdr_state
|
self.cmdr_text['state'] = self.username['state'] = self.password['state'] = cmdr_state
|
||||||
|
|
||||||
@ -410,20 +410,20 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
logdir = self.logdir.get()
|
logdir = self.logdir.get()
|
||||||
logvalid = logdir and exists(logdir)
|
logvalid = logdir and exists(logdir)
|
||||||
|
|
||||||
self.out_label['state'] = self.out_csv_button['state'] = self.out_td_button['state'] = self.out_ship_button['state'] = not monitor.is_beta and tk.NORMAL or tk.DISABLED
|
self.out_label['state'] = self.out_csv_button['state'] = self.out_td_button['state'] = self.out_ship_button['state'] = tk.NORMAL or tk.DISABLED
|
||||||
local = not monitor.is_beta and (self.out_td.get() or self.out_csv.get() or self.out_ship.get())
|
local = self.out_td.get() or self.out_csv.get() or self.out_ship.get()
|
||||||
self.out_auto_button['state'] = local and logvalid and tk.NORMAL or tk.DISABLED
|
self.out_auto_button['state'] = local and logvalid and tk.NORMAL or tk.DISABLED
|
||||||
self.outdir_label['state'] = local and tk.NORMAL or tk.DISABLED
|
self.outdir_label['state'] = local and tk.NORMAL or tk.DISABLED
|
||||||
self.outbutton['state'] = local and tk.NORMAL or tk.DISABLED
|
self.outbutton['state'] = local and tk.NORMAL or tk.DISABLED
|
||||||
self.outdir_entry['state'] = local and 'readonly' or tk.DISABLED
|
self.outdir_entry['state'] = local and 'readonly' or tk.DISABLED
|
||||||
|
|
||||||
self.eddn_station_button['state'] = not monitor.is_beta and tk.NORMAL or tk.DISABLED
|
self.eddn_station_button['state'] = tk.NORMAL or tk.DISABLED
|
||||||
self.eddn_auto_button['state'] = self.eddn_station.get() and logvalid and not monitor.is_beta and tk.NORMAL or tk.DISABLED
|
self.eddn_auto_button['state'] = self.eddn_station.get() and logvalid and tk.NORMAL or tk.DISABLED
|
||||||
self.eddn_system_button['state']= logvalid and tk.NORMAL or tk.DISABLED
|
self.eddn_system_button['state']= logvalid and tk.NORMAL or tk.DISABLED
|
||||||
self.eddn_delay_button['state'] = logvalid and eddn.replayfile and self.eddn_system.get() and tk.NORMAL or tk.DISABLED
|
self.eddn_delay_button['state'] = logvalid and eddn.replayfile and self.eddn_system.get() and tk.NORMAL or tk.DISABLED
|
||||||
|
|
||||||
self.edsm_log_button['state'] = logvalid and not monitor.is_beta and tk.NORMAL or tk.DISABLED
|
self.edsm_log_button['state'] = logvalid and tk.NORMAL or tk.DISABLED
|
||||||
edsm_state = logvalid and monitor.cmdr and not monitor.is_beta and self.edsm_log.get() and tk.NORMAL or tk.DISABLED
|
edsm_state = logvalid and monitor.cmdr and self.edsm_log.get() and tk.NORMAL or tk.DISABLED
|
||||||
self.edsm_label['state'] = self.edsm_cmdr_label['state'] = self.edsm_user_label['state'] = self.edsm_apikey_label['state'] = edsm_state
|
self.edsm_label['state'] = self.edsm_cmdr_label['state'] = self.edsm_user_label['state'] = self.edsm_apikey_label['state'] = edsm_state
|
||||||
self.edsm_cmdr_text['state'] = self.edsm_user['state'] = self.edsm_apikey['state'] = edsm_state
|
self.edsm_cmdr_text['state'] = self.edsm_user['state'] = self.edsm_apikey['state'] = edsm_state
|
||||||
|
|
||||||
@ -555,7 +555,7 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
|
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
if self.cmdr and not monitor.is_beta:
|
if self.cmdr:
|
||||||
if self.password.get().strip():
|
if self.password.get().strip():
|
||||||
config.set_password(self.username.get().strip(), self.password.get().strip()) # Can fail if keyring not unlocked
|
config.set_password(self.username.get().strip(), self.password.get().strip()) # Can fail if keyring not unlocked
|
||||||
else:
|
else:
|
||||||
|
4
stats.py
4
stats.py
@ -176,8 +176,8 @@ class StatsDialog():
|
|||||||
self.showstats()
|
self.showstats()
|
||||||
|
|
||||||
def showstats(self):
|
def showstats(self):
|
||||||
if not monitor.cmdr or monitor.is_beta:
|
if not monitor.cmdr:
|
||||||
return # In Beta - do nothing
|
return
|
||||||
|
|
||||||
self.status['text'] = _('Fetching data...')
|
self.status['text'] = _('Fetching data...')
|
||||||
self.parent.update_idletasks()
|
self.parent.update_idletasks()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user