SAMP (pyvo.samp)

SAMP, the Simple Application Messaging Protocol, lets you send and receive tables, datasets, or points of interest between various clients on a desktop.

While the main SAMP support still resides in astropy (it might be moved over to pyvo in later versions), there are a few wrapper functions in pyvo that make a few common SAMP tasks simpler or more robust.

Most importantly, pyvo lets you manage the SAMP connection in a context manager, which means you will not have to remember to close your connections to avoid ugly artefacts in the SAMP hub.

In addition, there are convenience functions for sending out data; in all cases, you can pass a client_name to only send a message to the specific client; a simple way to obtain client names is to inspect TOPCAT’s SAMP status if you use TOPCAT’s built-in SAMP hub. If, on the other hand, you pass None as client_name (or omit the parameter), you will send a broadcast.

Sending tables has the additional difficulty over sending other datasets that you will have to make the table data accessible to the receiving client. The solution chosen by pyvo.samp at this time will only work if the sending and receiving applications share a file system. This seems a reasonable expectation and saves a bit of a potential security headache.

Using pyvo.samp, sending an astropy table t to TOPCAT would look like this:

import pyvo

with pyvo.samp.connection(client_name="pyvo magic") as conn:
  pyvo.samp.send_table_to(
    conn,
    t,
    name="my-results",
    client_name="topcat")

Reference/API

pyvo.samp Package

This subpackage provides classes to communicate with other applications via the Simple Application Messaging Protocol (SAMP).

Before integration into Astropy it was known as SAMPy, and was developed by Luigi Paioro (INAF - Istituto Nazionale di Astrofisica).

Functions

accessible_table(table)

a context manager making astropy_table available under a (file) URL for the controlled section.

connection([client_name, description])

a context manager to give the controlled block a SAMP connection.

find_client_id(conn, name)

returns the SAMP id of the client with samp.name samp_name.

safe_xmlrpc_loads(data[, use_datetime, ...])

A secure replacement for xmlrpc.client.loads that prevents XXE.

send_image_to(conn, url[, client_name, name])

asks an image client to open a remote image via SAMP.

send_product_to(conn, url, mtype[, ...])

sends SAMP messages to load data.

send_spectrum_to(conn, url[, client_name, name])

asks a spectrum client to open a remote spectrum via SAMP.

send_table_to(conn, table[, client_name, name])

sends astropy_table via SAMP.

Classes

Conf()

Configuration parameters for pyvo.samp.

SAMPClient(hub[, name, description, ...])

Utility class which provides facilities to create and manage a SAMP compliant XML-RPC server that acts as SAMP callable client application.

SAMPClientError

SAMP Client exceptions.

SAMPHubError

SAMP Hub exception.

SAMPHubProxy()

Proxy class to simplify the client interaction with a SAMP hub (via the standard profile).

SAMPHubServer([secret, addr, port, ...])

SAMP Hub Server.

SAMPIntegratedClient([name, description, ...])

A Simple SAMP client.

SAMPMsgReplierWrapper(cli)

Function decorator that allows to automatically grab errors and returned maps (if any) from a function bound to a SAMP call (or notify).

SAMPProxyError(faultCode, faultString, **extra)

SAMP Proxy Hub exception.

SAMPWarning

SAMP-specific Astropy warning class.

SAMPXXEServerProxy(uri, *args, **kwargs)

An XML-RPC server proxy that uses a safe transport to prevent XXE.

WebProfileDialog()

A base class to make writing Web Profile GUI consent dialogs easier.