API Reference
- class flexlogger.automation.Application(server_port=None)[source]
Represents the FlexLogger application.
- __init__(server_port=None)[source]
Connect to an already running instance of FlexLogger.
- Parameters
server_port (
Optional
[int
]) – The port that the automation server is listening to. Omit this argument or pass None to detect the port of a running FlexLogger automatically.- Raises
FlexLoggerError – if connecting fails.
- close()[source]
Close the application and disconnect from the automation server.
Further calls to this object will fail.
- Return type
None
- disconnect()[source]
Disconnect from the automation server, but leave the application running.
Further calls to this object will fail.
- Return type
None
- get_active_project()[source]
Gets the currently active (open) project.
- Return type
Optional
[Project
]- Returns
The active project, or None if a project is not currently open.
- Raises
FlexLoggerError – if getting the active project fails.
- classmethod launch(*, timeout=40, path=None)[source]
Launch a new instance of FlexLogger.
Note that if this method is used to initialize a “with” statement, when the Application goes out of scope FlexLogger will be closed. To prevent this, call
disconnect()
.- Parameters
timeout (
float
) – The length of time, in seconds, to wait for FlexLogger to launch before raising an exception. Defaults to 40.path (
Union
[str
,pathlib.Path
,None
]) – The path to the FlexLogger executable to launch. Defaults to None, meaning the latest installed version will be launched.
- Return type
- Returns
The created Application object
- Raises
FlexLoggerError – if launching FlexLogger or connecting to it fails.
- open_project(path)[source]
Open a project.
- Parameters
path (
Union
[str
,pathlib.Path
]) – The path to the project you want to open.- Return type
- Returns
The opened project.
- Raises
FlexLoggerError – if opening the project fails.
- property server_port: int
The port that the automation server is listening to.
- Return type
int
- class flexlogger.automation.ChannelDataPoint(name, value, timestamp)[source]
The value for a channel at the specified timestamp.
- property name: str
The name of the channel.
- Return type
str
- property timestamp: datetime.datetime
The timestamp when the value occurred.
- Return type
datetime.datetime
- property value: float
The value of the channel.
- Return type
float
- class flexlogger.automation.ChannelSpecificationDocument(channel, raise_if_application_closed, identifier)[source]
Represents the document that describes data channels.
Do not create this class directly; instead, use the return value of
Project.open_channel_specification_document()
.- get_channel_names()[source]
Get all the channel names in the document.
- Raises
FlexLoggerError – if getting the channel names fails.
- Return type
List
[str
]
- get_channel_value(channel_name)[source]
Get the current value of the specified channel.
- Parameters
channel_name (
str
) – The name of the channel.- Raises
FlexLoggerError – if getting the channel value fails.
- Return type
- is_channel_enabled(channel_name)[source]
Get the current enabled state of the specified channel.
- Parameters
channel_name (
str
) – The name of the channel.- Raises
FlexLoggerError – if getting the channel value fails.
- Return type
bool
- set_channel_enabled(channel_name, channel_enabled)[source]
Enable or disable the specified channel.
- Parameters
channel_name (
str
) – The name of the channel.channel_enabled (
bool
) – The channel enabled state: true to enable the channel, false to disable it.
- Raises
FlexLoggerError – if enabling or disabling the channel fails.
- Return type
None
- set_channel_value(channel_name, channel_value)[source]
Set the current value of the specified channel.
- Parameters
channel_name (
str
) – The name of the channel.channel_value (
float
) – The value to set the channel to.
- Raises
FlexLoggerError – if setting the channel value fails.
- Return type
None
- exception flexlogger.automation.FlexLoggerError(message)[source]
Represents errors that occur when calling FlexLogger APIs.
- __init__(message)[source]
Initialize an exception.
- Parameters
message (
str
) – The message describing the error.
- property message: str
The error message.
- Return type
str
- with_traceback()
Exception.with_traceback(tb) – set self.to tb and return self.
- class flexlogger.automation.LoggingSpecificationDocument(channel, raise_if_application_closed, identifier)[source]
Represents a document that describes how data is logged.
Do not create this class directly; instead, use the return value of
Project.open_logging_specification_document()
.- get_log_file_base_path()[source]
Get the log file base path.
- Return type
str
- Returns
The base path for the log file.
- Raises
FlexLoggerError – if getting the log file base path fails.
- get_log_file_name()[source]
Get the log file name.
- Return type
str
- Returns
The file name that will be logged to.
- Raises
FlexLoggerError – if getting the log file name fails.
- get_resolved_log_file_base_path()[source]
Get the resolved log file base path.
- Return type
str
- Returns
The resolved base path for the log file. The resolved base path will have any placeholders replaced with actual values. Note that time sourced placeholders such as {Second} are resolved at the time of the call, and may resolve to a different time on a subsequent call or when a log file is created.
- Raises
FlexLoggerError – if getting the resolved log file base path fails.
- get_resolved_log_file_name()[source]
Get the resolved log file name.
- Return type
str
- Returns
The resolved file name that will be logged to. The resolved file name will have any placeholders replaced with actual values. Note that time sourced placeholders such as {Second} are resolved at the time of the call, and may resolve to a different time on a subsequent call or when a log file is created.
- Raises
FlexLoggerError – if getting the resolved log file name fails.
- get_test_properties()[source]
Get all test properties.
- Return type
List
[TestProperty
]- Returns
A list of the test properties on this document.
- Raises
FlexLoggerError – if getting the test properties fails.
- get_test_property(test_property_name)[source]
Get the test property with the specified name.
Throws a
FlexLoggerError
if a property with the specified name does not exist.- Parameters
test_property_name (
str
) – The name of the test property.- Return type
- Returns
The
TestProperty
with the specified name.- Raises
FlexLoggerError – if a property with the specified name does not exist, or if getting the property fails.
- remove_test_property(test_property_name)[source]
Removes the test property with the specified name.
- Parameters
test_property_name (
str
) – The name of the test property.- Raises
FlexLoggerError – if a property with the specified name does not exist, or if removing the property fails.
- Return type
None
- set_log_file_base_path(log_file_base_path)[source]
Set the log file base path.
- Parameters
log_file_base_path (
str
) – The log file base path.- Raises
FlexLoggerError – if setting the log file base path fails.
- Return type
None
- set_log_file_name(log_file_name)[source]
Set the log file name.
- Parameters
log_file_name (
str
) – The log file name.- Raises
FlexLoggerError – if setting the log file name fails.
- Return type
None
- set_test_property(property_name, property_value, prompt_on_start=False)[source]
Set the information for a test property.
Use this method to add a new test property or to modify an existing test property.
- Parameters
property_name (
str
) – The name of the test property. If a test property already exists with the samename
, that test property will be updated with the new information passed to this method. Otherwise, a new test property will be created to reflect the specified test information.property_value (
str
) – The property value to set.prompt_on_start (
bool
) – Whether this property should be set when the test session starts. Defaults to False. If this is set to True, the operator should be prompted to define this property when the test session starts.
- Raises
FlexLoggerError – if setting the property fails.
- Return type
None
- class flexlogger.automation.Project(channel, raise_if_application_closed, identifier)[source]
Represents a FlexLogger project.
Do not create this class directly; instead, use the return value of
Application.open_project()
.- close()[source]
Close the project.
- Raises
FlexLoggerError – if closing the project fails.
- Return type
None
- open_channel_specification_document()[source]
Open the channel specification document in the project.
- Return type
- Returns
The opened document.
- Raises
FlexLoggerError – if opening the document fails.
- open_logging_specification_document()[source]
Open the logging specification document in the project.
- Return type
- Returns
The opened document.
- Raises
FlexLoggerError – if opening the document fails.
- open_screen_document(filename)[source]
Open the specified screen document in the project.
- Parameters
filename (
str
) – The name of the screen document to open. Including the .flxscr extension in this argument is optional.- Return type
- Returns
The opened document.
- Raises
FlexLoggerError – if a screen document of the specified name does not exist, or if opening the document fails.
- open_test_specification_document()[source]
Open the test specification document in the project.
- Return type
- Returns
The opened document.
- Raises
FlexLoggerError – if opening the document fails.
- property project_file_path: Optional[pathlib.Path]
Get the project file path on disk
Returns: The saved project file path if it exists, None otherwise
- Return type
Optional
[pathlib.Path
]
- property test_session: flexlogger.automation._test_session.TestSession
Get the test session for the project.
- Return type
- class flexlogger.automation.ScreenDocument(channel, raise_if_application_closed, identifier)[source]
Represents a document that displays data.
Do not create this class directly; instead, use the return value of
Project.open_screen_document()
.Note that this class currently has no functionality; more functionality may be added in the future.
- class flexlogger.automation.TestProperty(name, value, prompt_on_start)[source]
Information about a test property.
- __init__(name, value, prompt_on_start)[source]
Create a new TestProperty.
- Parameters
name (
str
) – The name of the property.value (
str
) – The value of the property.prompt_on_start (
bool
) – Whether the operator should be prompted to define this property when the test session starts.
- property name: str
The name of the property.
- Return type
str
- property prompt_on_start: bool
Whether this property should be set when the test session starts.
If this is set to true, the operator should be prompted to define this property when the test session starts.
- Return type
bool
- property value: str
The value of the property.
- Return type
str
- class flexlogger.automation.TestSession(channel, raise_if_application_closed)[source]
Represents a test session for a project.
Do not create this class directly; instead, use the property
Project.test_session
.- add_note(note)[source]
Add a note to the current log file.
This method requires the test session to be in the
TestSessionState.RUNNING
state.- Parameters
note (
str
) – The note to add to the log file.- Raises
FlexLoggerError – if the test session is not in the
TestSessionState.RUNNING
state, or if adding the note fails.- Return type
None
- property elapsed_test_time: datetime.timedelta
Queries the elapsed test time
- Return type
datetime.timedelta
- Returns
The current tests’s elapsed time if a test is running or paused, the most recent test’s elapsed time if a test has been run and stopped.
- Raises
FlexLoggerError – if no test has ever been run since the project was loaded
- pause()[source]
Pauses the test session, if possible.
- Return type
bool
- Returns
True if the test was paused, otherwise False.
- Raises
FlexLoggerError – if pausing the test session fails.
- resume()[source]
Resumes the test session, if possible.
- Return type
bool
- Returns
True if the test was resumed, otherwise False.
- Raises
FlexLoggerError – if resuming the test session fails.
- start()[source]
Start the test session, if possible.
- Return type
bool
- Returns
True if the test was started, otherwise False.
- Raises
FlexLoggerError – if starting the test session fails.
- property state: flexlogger.automation._test_session_state.TestSessionState
Get the current state of the test session.
- Raises
FlexLoggerError – if getting the current state fails.
- Return type
- stop()[source]
Stop the test session, if possible.
- Return type
bool
- Returns
True if the test was stopped, otherwise False.
- Raises
FlexLoggerError – if stopping the test session fails.
- class flexlogger.automation.TestSessionState(value)[source]
An enumeration describing the possible states of a
TestSession
.- IDLE = 1
The
TestSession
is idle and not running.Configuration changes can occur during this state.
- INVALID_CONFIGURATION = 3
The project has a configuration error.
- NO_VALID_LOGGED_CHANNELS = 4
No channels have been configured, or all channels are disabled or not available.
- PAUSED = 5
The
TestSession
is paused.Logging and events are not active while the test session is paused.
Configuration changes are not allowed when the test session is paused.
- RUNNING = 2
The
TestSession
is running.Logging and events are active while the test session is running.
Configuration changes are not allowed when the test session is running.
- class flexlogger.automation.TestSpecificationDocument(channel, raise_if_application_closed, identifier)[source]
Represents a document that describes a test.
Do not create this class directly; instead, use the return value of
Project.open_test_specification_document()
.Note that this class currently has no functionality; more functionality may be added in the future.