microscope.deviceserver module

A class for serving microscope components.

This module provides a server to make microscope control objects available over Pyro. When called from the command line, this module will serve devices defined in a specified config file.

class microscope.deviceserver.DeviceServer(device_def, id_to_host, id_to_port, exit_event=None)[source]

Bases: multiprocessing.context.Process


Create new instance with same settings.

This is useful to restart a device server.


Method to be run in sub-process; can be overridden in sub-class

class microscope.deviceserver.Filter[source]

Bases: logging.Filter


Pass, aggregate or suppress consecutive repetitions of a log message.


Serve devices from a console process.


Serve devices via Pyro.

To run in the terminal, use:

deviceserver CONFIG

To configure and run as a Windows service use:

deviceserver [install,remove,update,start,stop,restart,status] CONFIG

CONFIG is a .py file that exports DEVICES = [device(...), ...]


Configure and control a Windows service to serve devices.

microscope.deviceserver._create_log_formatter(name: str)[source]

Create a logging.Formatter for the device server.

Each device is served on its own process and each device has its own log file. But the logs from all device servers also appear on stderr where it will be difficult to figure out from which device server a log message comes. This creates a logging.Formatter which includes the device server name.

Parameters:name (str) – device name to be used on the log output.
microscope.deviceserver.serve_devices(devices, exit_event=None)[source]