Skip to content

Commit

Permalink
clean up SwiftFacility.submit_observation
Browse files Browse the repository at this point in the history
  • Loading branch information
phycodurus committed Oct 17, 2023
1 parent af5649e commit be8a758
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions tom_swift/swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,42 +739,26 @@ def submit_observation(self, observation_payload) -> [()]:
#for property in too_status_properties:
# logger.debug(f'submit_observation - too.status.{property}: {getattr(self.swift_api.too.status, property)}')

too_id = None
if self.swift_api.too.status.status == 'Accepted':
too_id = self.swift_api.too.status.too_id
# this was a successful submission
logger.info(f'submit_observation - too.status.status: {self.swift_api.too.status.status}')
logger.info(f'submit_observation - too.status.too_id: {self.swift_api.too.status.too_id}')
logger.info(f'submit_observation - too_id: {too_id}')

# lets examine the TOO created
# TODO: move this code into swift_api.py
# see https://www.swift.psu.edu/too_api/index.php?md=Swift TOO Request Example Notebook.ipynb

if self.swift_api.too.debug:
# this was a debug submission and thus, no TOO was made and
# the too_id returned in the too.status is points to nothing.
pass
logger.info((f'submit_observation - DEBUG submission - too_id'
f' {self.swift_api.too.status.too_id} is not real.'))
else:
# TODO: it's unclear if we really need to ask for the TOORequests object
# for this too at this point....

# configure the request object
self.swift_api.too_request.username = self.swift_api.too.username
self.swift_api.too_request.shared_secret = self.swift_api.too.shared_secret
self.swift_api.too_request.detail = True
self.swift_api.too_request.too_id = self.swift_api.too.status.too_id
too_request_response = self.swift_api.too_request.submit()

if too_request_response:
logger.debug(f'submit_observation - too_request[0]: {self.swift_api.too_request[0]}')
else:
logger.error(f'submit_observation - too_request_response: {too_request_response}')
logger.warning((f'submit_observation - DEBUG submission - too_id: {too_id} is not real.'))
else:
logger.error(f'submit_observation - too.status.status: {self.swift_api.too.status.status}')

# TODO: remove this -- it is only for debugging/development
#self.swift_api.too.status.too_id = 19529 # an actual NCG1566 TOO

return [self.swift_api.too.status.too_id]
return [too_id]


0 comments on commit be8a758

Please sign in to comment.