Publishers (pyobs.utils.publisher)

class Publisher(vfs: VirtualFileSystem | dict[str, Any] | None = None, comm: Comm | dict[str, Any] | None = None, timezone: str | datetime.tzinfo | None = 'utc', location: str | dict[str, Any] | EarthLocation | None = None, observer: Observer | None = None, **kwargs: Any)[source]

Bases: Object

Note

Objects must always be opened and closed using open() and close(), respectively.

This class provides a VirtualFileSystem, a timezone and a location. From the latter two, an observer object is automatically created.

Object also adds support for easily adding threads using the add_background_task() method as well as a watchdog thread that automatically restarts threads, if requested.

Using add_child_object(), other objects can be (created an) attached to this object, which then automatically handles calls to open() and close() on those objects.

Parameters:
  • vfs – VFS to use (either object or config)

  • comm – Comm object to use

  • timezone – Timezone at observatory.

  • location – Location of observatory, either a name or a dict containing latitude, longitude, and elevation.

class CsvPublisher(filename: str, **kwargs: Any)[source]

Bases: Publisher

Initialize new CSV publisher.

Parameters:

filename – Name of file to log in.

async data() DataFrame[source]

Return data that has so far been published.

class LogPublisher(level: str = 'info', **kwargs: Any)[source]

Bases: Publisher

Initialize new log publisher.

Parameters:

level – Level to log on.

class MultiPublisher(publishers: List[Publisher | Dict[str, Any]] | None = None, **kwargs: Any)[source]

Bases: Publisher

Forwards a message to multiple publishers.

Initialize new multi publisher.

Parameters:

publishers – Publishers to forward messages to.