Experimental asyncio API

Note

This page isn’t rendered on readthedocs since it requires Python 3.5. The rendered page can be found here.

Warning

The asyncio API is not thoroughly unit tested, use with caution. Please report issues on GitHub.

class spacetrack.aio.AsyncSpaceTrackClient(identity, password)[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.

For more information, refer to the Space-Track documentation.

close()[source]

Close aiohttp session.

generic_request(class_, iter_lines=False, iter_content=False, **kwargs)[source]

Generic Space-Track query coroutine.

The request class methods use this method internally; the following two lines are equivalent:

await spacetrack.tle_publish(*args, **kwargs)
await spacetrack.generic_request('tle_publish', *args, **kwargs)
Parameters:
  • class – Space-Track request class name
  • iter_lines – Yield result line by line
  • iter_content – Yield result in 100 KiB chunks.
  • **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 set format if you want the parsed JSON object returned!

get_predicates(class_)[source]

Get full predicate information for given request class, and cache for subsequent calls.