psi.core package

Subpackages

Submodules

psi.core.api module

psi.core.app_id module

Taskbar identity for psi programs.

Deliberately free of enaml, atom and Qt imports so that a program can call set_app_id from the very top of its main, before the GUI machinery is loaded.

psi.core.app_id.set_app_id(app_id)[source]

Give this process its own identity on the Windows taskbar.

Windows groups taskbar buttons by AppUserModelID, and a Python GUI that never sets one inherits the interpreter’s. Without this every psi program shares a single taskbar button showing Python’s icon (or the console-script wrapper’s), no matter what icon its windows carry.

psivideo keeps its own copy of this (it does not depend on psi). Keep the two in sync.

Parameters:

app_id (string) – Dotted identifier, by convention psi.<program> (e.g., psi.cftscal, psi.noise-exp). psi itself claims psi.psi, leaving the launchers that spawn it free to claim their own so that a launcher and its experiments get separate taskbar buttons.

Notes

Call this from the program’s entry point before the Qt application is created. Once a window exists Windows has already bound the process to the default ID and this has no effect.

No-op off Windows, and fails soft: a mis-grouped taskbar button is cosmetic and shouldn’t keep the program from starting.

psi.core.console module

Console setup for psi’s command-line entry points.

Deliberately free of enaml, atom and Qt imports, so that a command which needs no GUI (psi-config) does not load it just to configure the console.

psi.core.console.disable_quick_edit()[source]
psi.core.console.setup_windows_console()[source]

Disable Windows quick-edit mode so that clicking in the console does not accidentally pause the application. Called from the CLI entry points; importing this module has no side effects.

psi.core.exceptions module

Exception hierarchy for psiexperiment.

Catching PSIException distinguishes errors raised (and understood) by the framework from arbitrary programming errors.

exception psi.core.exceptions.ActionError(message, action=None, event=None)[source]

Bases: PSIException

Raised when an ExperimentAction’s command or callback fails.

The original exception is available as __cause__.

action

The ExperimentActionBase instance that failed.

event

Name of the event that triggered the action.

exception psi.core.exceptions.PSIException[source]

Bases: Exception

Base class for all exceptions raised by psiexperiment itself.

psi.core.experiment_action module

class psi.core.experiment_action.EventLogger(parent=None, **kwargs)[source]

Bases: Declarative

Defines a command that is invoked whenever an event occurs

command

A value of type str.

By default, bytes will NOT be promoted to strings. Pass strict=False to the constructor to enable loose string checking.

class psi.core.experiment_action.ExperimentAction(parent=None, **kwargs)[source]

Bases: ExperimentActionBase

command

Command to invoke

class psi.core.experiment_action.ExperimentActionBase(parent=None, **kwargs)[source]

Bases: Declarative

allow_unregistered

If True, the controller’s startup validation will not require the names referenced by event to be registered events or state flags. Only set this for events that are generated dynamically at runtime.

delay

Should action be delayed? If nonzero, this may cause some timing issues. Use with caution.

dependencies

A member which allows list values.

Assigning to a list creates a copy. The orginal list will remain unmodified. This is similar to the semantics of the assignment operator on the C++ STL container classes.

event

A value of type str.

By default, bytes will NOT be promoted to strings. Pass strict=False to the constructor to enable loose string checking.

invocations

Number of times the command was invoked

invoke(core, **kwargs)[source]
kwargs

Arguments to pass to command by keyword

match

A value which is callable.

weight

Defines order of invocation. Less than 100 invokes before default. Higher than 100 invokes after default. Note that if concurrent is True, then order of execution is not guaranteed.

class psi.core.experiment_action.ExperimentCallback(parent=None, **kwargs)[source]

Bases: ExperimentActionBase

callback

Callback to invoke

class psi.core.experiment_action.ExperimentEvent(parent=None, **kwargs)[source]

Bases: Declarative

associated_state

A value which allows objects of a given type or types.

Values will be tested using the PyObject_TypeCheck C API call. This call is equivalent to type(obj) in cls.mro(). It is less flexible but can be faster than Instance. Use Instance when allowing you need a tuple of types or (abstract) types relying on custom __isinstancecheck__ and Typed when the value type is explicit.

If optional is True, the value of a Typed may be set to None, otherwise None is not considered as a valid value.

name

Export the ‘name’ attribute as a declarative member.

class psi.core.experiment_action.ExperimentState(parent=None, **kwargs)[source]

Bases: Declarative

Allows for indication of a state (e.g., experiment_active, iti_active). Automatically contributes the start/end events associataed with the state (e.g., experiment_start, experiment_end).

events = ['prepare', 'start', 'end']
name

Export the ‘name’ attribute as a declarative member.

psi.core.experiment_action.eval_match(code, context, ignore_missing=False)[source]
psi.core.experiment_action.simple_match(key, context, ignore_missing=False)[source]

psi.core.metadata_item module

psi.core.preferences module

class psi.core.preferences.ItemPreferences(parent=None, **kwargs)[source]

Bases: _AutoPreferences

get_object(workbench)[source]
item

A member class which supports value initialization.

A plain Value provides support for default values and factories, but does not perform any type checking or validation. It serves as a useful base class for scalar members and can be used for cases where type checking is not needed (like private attributes).

class psi.core.preferences.PluginPreferences(parent=None, **kwargs)[source]

Bases: _AutoPreferences

get_object(workbench)[source]
plugin_id

A value of type str.

By default, bytes will NOT be promoted to strings. Pass strict=False to the constructor to enable loose string checking.

class psi.core.preferences.Preferences(parent=None, **kwargs)[source]

Bases: Declarative

get_object(workbench)[source]
get_preferences(workbench)[source]
name

Export the ‘name’ attribute as a declarative member.

set_preferences(workbench, preferences)[source]

psi.core.status_item module

Module contents