pykit.wpilog package

Submodules

pykit.wpilog.wpilogconstants module

pykit.wpilog.wpilogreader module

class pykit.wpilog.wpilogreader.WPILOGReader(filename: str)[source]

Bases: LogReplaySource

Reads a .wpilog file and provides the data as a replay source for the logger.

Initializes the WPILOGReader.

Parameters:

filename – The path to the .wpilog file.

start() None[source]

Initializes the reader by opening the log file and preparing to read records.

timestamp: int | None
updateTable(table: LogTable) bool[source]

Updates a LogTable with the next record from the log file.

This method iterates through the log records, populating the provided LogTable with data corresponding to a single timestamp.

Parameters:

table – The LogTable to update.

Returns:

True if the table was updated and there may be more data, False if the end of the log was reached.

pykit.wpilog.wpilogreader.safeNext(val: Iterator[T]) None | T[source]

Safely gets the next item from an iterator, returning None if the iterator is exhausted.

Parameters:

val – The iterator.

Returns:

The next item or None.

pykit.wpilog.wpilogwriter module

class pykit.wpilog.wpilogwriter.WPILOGWriter(filename: str | None = None, path: str | None = None)[source]

Bases: LogDataReciever

A data receiver that writes log data to a .wpilog file.

This class handles the creation and writing of log files in the standard WPILib format, including automatic file naming and handling of data types.

Initializes the WPILOGWriter.

Parameters:
  • filename – The path to the .wpilog file. If None, a default path is used, and the file is named with a random identifier.

  • path – The directory to save the log file. If None, a default path is used based on whether it’s running in simulation or on the robot.

in the event that both a filename and a path are provided, the combination of the path and the filename will be used in determining the location of where to put the log file

autoRename: bool
defaultPathRio: str = '/U/logs'
defaultPathSim: str = 'pyLogs'
dsAttachedTime: int = 0
end() None[source]

Closes the log file and performs cleanup. In simulation, it can also trigger AdvantageScope to open the log.

entryIds: dict[str, int]
entryTypes: dict[str, LoggableType]
entryUnits: dict[str, str]
filename: str
folder: str
isOpen: bool = False
lastTable: LogTable
log: DataLog
logDate: datetime | None
logMatchText: str
putTable(table: LogTable) None[source]

Writes a LogTable to the .wpilog file.

This method handles automatic file renaming, writing timestamp and data entries, and ensures that data is only written when it changes.

Parameters:

table – The LogTable to write.

randomIdentifier: str
start() None[source]

Initializes the writer by creating the log file and preparing to write data.

timestampId: int