Update api.py, commander.py and one other file

This commit is contained in:
Richard Bronkhorst 2023-06-17 23:07:53 +02:00
parent 9987481848
commit c2a1f787a2
3 changed files with 19 additions and 4 deletions

View File

@ -244,11 +244,11 @@ class Api:
else:
raise e
ship.update(data)
return ship
return data
def survey(self, ship):
data = self.request('post', f'my/ships/{ship}/survey')
ship.update(data)
result = self.store.update_list('Survey', mg(data, 'surveys'))
return result

View File

@ -261,4 +261,15 @@ class Commander(CommandLine):
def do_survey(self):
if not self.has_ship(): return
r = self.api.survey(self.ship)
pprint(r)
pprint(r)
def do_extract(self, survey_str=''):
if not self.has_ship(): return
survey = None
if survey_str != '':
survey = self.resolve('Survey', survey_str)
result = self.api.extract(self.ship, survey)
symbol = mg(result,'extraction.yield.symbol')
units = mg(result,'extraction.yield.units')
print(units, symbol)

View File

@ -25,10 +25,14 @@ class Survey(SystemMember):
def is_expired(self):
return time() > self.expires or self.exhausted
def waypoint(self):
p = self.symbol.split('-')
return '-'.join(p[:3])
def api_dict(self):
return {
'signature': self.symbol,
'symbol': str(self.waypoint),
'symbol': self.waypoint(),
'deposits': [{'symbol': d} for d in self.deposits],
'expiration': self.expires_str,
'size': size_names[self.size]