Contains the NICOS session classes, which contain all low-level global state of the NICOS runtime.
Only for internal usage by functions and methods.
Bases: object
The Session class provides all low-level routines needed for NICOS operations and keeps the global state: devices, configuration, loggers.
Within one NICOS process, there is only one singleton session object that is always importable using
from nicos import session
There are several specialized subclasses of Session; one of them will always be used in concrete applications.
Add a new logging handler to the list of handlers for all NICOS loggers.
Allow breaking or stopping the script at a well-defined time.
level can be 1 to indicate a breakpoint “after current scan” or 2 to indicate a breakpoint “after current step”.
alias of CacheClient
Check if the current user fulfills the requirements given in the required dictionary. Raise AccessError if check failed.
This is called by the requires decorator.
Reset experiment-specific data.
This method is called when the user executes a simple command. It should return a compiled code object that is then executed instead of the command.
Bases: object
Singleton for settings potentially overwritten later.
Create device given by a device name.
If device exists and recreate is true, destroy and create it again. If explicit is true, the device is added to the list of “explicitly created devices”.
Shutdown a device and remove it from the list of created devices.
Mark the end of a multi-create.
Export an object obj into the NICOS namespace with given name.
Return a device dev from the current setup.
If dev is a string, the corresponding device will be looked up or created, if necessary.
cls gives a class, or tuple of classes, that dev needs to be an instance of.
Return an iterable of all objects exported to the NICOS namespace.
Return a new NICOS logger for the specified device name.
Return information about all existing setups.
This is a dictionary mapping setup name to another dictionary. The keys of that dictionary are those present in the setup files: ‘description’, ‘group’, ‘sysconfig’, ‘includes’, ‘excludes’, ‘modules’, ‘devices’, ‘startupcode’, ‘extended’.
Return the current setup path.
Determine which setup to load, and try to become master.
Called by sessions during startup.
Load one or more setup modules given in setupnames and set up devices accordingly.
If allow_special is true, special setups (with group “special”) are allowed, otherwise ConfigurationError is raised. If raise_failed is true, errors when creating devices are re-raised (otherwise, they are reported as warnings).
Log an unhandled exception (occurred during user scripts).
The exception is logged using the originating device’s logger, if that information is available.
The current execution mode of the session.
Send a notification unconditionally.
Send a notification if the current runtime exceeds the configured minimum runtimer for notifications.
Read information of all existing setups, and validate them.
Setup modules are looked for in the directory given by the “setups_path” entry in nicos.conf, or by “control_path”/setups.
Set a new mode for the session.
This raises ModeError if the new mode cannot be switched to at the moment (for example, if switching to master mode, but another master is already active).
Set the namespace to export commands and devices into.
Set the path to the setup files.
Normally, the setup path is given in nicos.conf and does not need to be set explicitly.
Shut down the session: unload the setup and give up master mode.
Store devices that fail to create so that they are not tried again and again during one setup process.
Unexport the object with name from the NICOS namespace.
Unload the current setup.
This shuts down all created devices and clears the NICOS namespace.
Send new live data to clients.
The parameters are:
Session class for console interface.
Bases: nicos.sessions.Session
Bases: Session
Subclass of Session that configures the logging system for interactive interpreter usage: it adds a console handler with colored output, and an exception hook that reports unhandled exceptions via the logging system.
Run an interactive console, and exit after it is finished.
Bases: code.InteractiveConsole
Bases: InteractiveConsole
This class provides a console similar to the standard Python interactive console, with the difference that input and output are logged to the NICOS logger and will therefore appear in the logfiles.
Mostly copied from code.InteractiveInterpreter, but added the logging call for exceptions.
Mostly copied from code.InteractiveInterpreter, but added the logging call before runcode().
Bases: exceptions.BaseException
Bases: BaseException
This exception is raised when the user requests a stop.
Session class used with the NICOS daemon.
Bases: nicos.sessions.simple.NoninteractiveSession
Bases: NoninteractiveSession
Subclass of Session that configures the logging system for running under the execution daemon: it adds the special daemon handler and installs a standard output stream that logs stray output.
alias of DaemonCacheClient
Session classes for simple and noninteractive use.
Bases: nicos.sessions.Session
Bases: Session
Subclass of Session that configures the logging system for simple noninteractive usage.
Bases: nicos.sessions.Session
Bases: Session
Subclass of Session that allows for batch execution of scripts.
Bases: nicos.sessions.simple.NoninteractiveSession
Bases: NoninteractiveSession
Utilities for the session classes.
Bases: object
Standard output stream replacement that tees output to a logger.
Bases: rlcompleter.Completer
Bases: Completer
This is a Completer subclass that doesn’t show private attributes when completing attribute access.
Bases: dict
Bases: dict
A dict subclass that has a list of identifiers that cannot be set, except using the setForbidden() method.
Bases: object
Simulation clock.
Try to guess the command that was meant by source.
Will do a fuzzy match in all usercommands in the top level namespace and tries to find attributes if attribute is true.
Create a unique identifier for the current session.
Return a string with information gathered from the session id.
Session used for the NICOS web interface.
Bases: nicos.sessions.Session
Bases: Session
Subclass of Session that configures the logging system for usage in a web application environment.