Experimental asyncio
API¶
Warning
The asyncio
API is not thoroughly unit tested, use with caution. Please
report issues on GitHub.
-
class
spacetrack.aio.
AsyncSpaceTrackClient
(identity, password, base_url='https://www.space-track.org/', rush_store=None, rush_key_prefix='')[source]¶ Bases:
spacetrack.base.SpaceTrackClient
Asynchronous SpaceTrack client class.
This class should be considered experimental.
It must be closed by calling
close()
. Alternatively, instances of this class can be used as a context manager.Parameters: - identity – Space-Track username.
- password – Space-Track password.
- base_url – May be overridden to use e.g. https://testing.space-track.org/
For more information, refer to the Space-Track documentation.
-
session
¶ aiohttp.ClientSession
instance.
-
authenticate
()[source]¶ Authenticate with Space-Track.
Raises: spacetrack.base.AuthenticationError
– Incorrect login details.Note
This method is called automatically when required.
-
generic_request
(class_, iter_lines=False, iter_content=False, controller=None, parse_types=False, **kwargs)[source]¶ Generic Space-Track query coroutine.
The request class methods use this method internally; the public API is as follows:
st.tle_publish(*args, **st) st.basicspacedata.tle_publish(*args, **st) st.file(*args, **st) st.fileshare.file(*args, **st) st.spephemeris.file(*args, **st)
They resolve to the following calls respectively:
st.generic_request('tle_publish', *args, **st) st.generic_request('tle_publish', *args, controller='basicspacedata', **st) st.generic_request('file', *args, **st) st.generic_request('file', *args, controller='fileshare', **st) st.generic_request('file', *args, controller='spephemeris', **st)
Parameters: - class – Space-Track request class name
- iter_lines – Yield result line by line
- iter_content – Yield result in 100 KiB chunks.
- controller – Optionally specify request controller to use.
- parse_types – Parse string values in response according to type given
in predicate information, e.g.
'2017-01-01'
->datetime.date(2017, 1, 1)
. - **kwargs –
These keywords must match the predicate fields on Space-Track. You may check valid keywords with the following snippet:
spacetrack = AsyncSpaceTrackClient(...) await spacetrack.tle.get_predicates() # or await spacetrack.get_predicates('tle')
See
_stringify_predicate_value()
for which Python objects are converted appropriately.
Yields: Lines—stripped of newline characters—if
iter_lines=True
Yields: 100 KiB chunks if
iter_content=True
Returns: Parsed JSON object, unless
format
keyword argument is passed.Warning
Passing
format='json'
will return the JSON unparsed. Do not setformat
if you want the parsed JSON object returned!