astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v1.1.1 »
- Virtual Observatory Access (`astropy.vo`) »
- SAMP (Simple Application Messaging Protocol (`astropy.vo.samp`) »
- SAMPHubServer

# SAMPHubServer

class `astropy.vo.samp.``SAMPHubServer`(secret=None, addr=None, port=0, lockfile=None, timeout=0, client_timeout=0, mode=u'single', label=u'', https=False, key_file=None, cert_file=None, cert_reqs=0, ca_certs=None, ssl_version=None, web_profile=True, web_profile_dialog=None, web_port=21012, pool_size=20)

  Bases: `object`

  SAMP Hub Server.

  The SSL parameters are usable only if Python has been compiled with SSL support and/or ssl module is installed (available by default since Python 2.6).

  Parameters:

  secret : str, optional

  > The secret code to use for the SAMP lockfile. If none is is specified, the `uuid.uuid1()` function is used to generate one.

  addr : str, optional

  > Listening address (or IP). This defaults to 127.0.0.1 if the internet is not reachable, otherwise it defaults to the host name.

  port : int, optional

  > Listening XML-RPC server socket port. If left set to 0 (the default), the operating system will select a free port.

  lockfile : str, optional

  > Custom lockfile name.

  timeout : int, optional

  > Hub inactivity timeout. If `timeout > 0` then the Hub automatically stops after an inactivity period longer than `timeout` seconds. By default `timeout` is set to 0 (Hub never expires).

  client_timeout : int, optional

  > Client inactivity timeout. If `client_timeout > 0` then the Hub automatically unregisters the clients which result inactive for a period longer than `client_timeout` seconds. By default `client_timeout` is set to 0 (clients never expire).

  mode : str, optional

  > Defines the Hub running mode. If `mode` is `'single'` then the Hub runs using the standard `.samp` lock-file, having a single instance for user desktop session. Otherwise, if `mode` is `'multiple'`, then the Hub runs using a non-standard lock-file, placed in `.samp-1` directory, of the form `samp-hub-<UUID>`, where `<UUID>` is a unique UUID assigned to the hub.

  label : str, optional

  > A string used to label the Hub with a human readable name. This string is written in the lock-file assigned to the `hub.label` token.

  https : bool, optional

  > Set the Hub running on a Secure Sockets Layer connection (HTTPS). By default SSL is disabled.

  key_file : str, optional

  > The path to a file containing the private key for SSL connections. If the certificate file (`cert_file`) contains the private key, then `key_file` can be omitted.

  cert_file : str, optional

  > The path to a file containing a certificate to be used to identify the local side of the secure connection.

  cert_reqs : int, optional

  > The parameter `cert_reqs` specifies whether a certificate is required from the client side of the connection, and whether it will be validated if provided. It must be one of the three values `ssl.CERT_NONE` (certificates ignored), `ssl.CERT_OPTIONAL` (not required, but validated if provided), or `ssl.CERT_REQUIRED` (required and validated). If the value of this parameter is not `ssl.CERT_NONE`, then the `ca_certs` parameter must point to a file of CA certificates.

  ca_certs : str, optional

  > The path to a file containing a set of concatenated “Certification Authority” certificates, which are used to validate the certificate passed from the Hub end of the connection.

  ssl_version : int, optional

  > The `ssl_version` option specifies which version of the SSL protocol to use. Typically, the server chooses a particular protocol version, and the client must adapt to the server’s choice. Most of the versions are not interoperable with the other versions. If not specified, the default SSL version is taken from the default in the installed version of the Python standard `ssl` library. See the `ssl` documentation for more information.

  web_profile : bool, optional

  > Enables or disables the Web Profile support.

  web_profile_dialog : class, optional

  > Allows a class instance to be specified using `web_profile_dialog` to replace the terminal-based message with e.g. a GUI pop-up. Two `queue.Queue` instances will be added to the instance as attributes `queue_request` and `queue_result`. When a request is received via the `queue_request` queue, the pop-up should be displayed, and a value of `True` or `False` should be added to `queue_result` depending on whether the user accepted or refused the connection.

  web_port : int, optional

  > The port to use for web SAMP. This should not be changed except for testing purposes, since web SAMP should always use port 21012.

  pool_size : int, optional

  > The number of socket connections opened to communicate with the clients.

  Attributes Summary

  `id` | The unique hub ID.
  `is_running` | Return an information concerning the Hub running status.
  `params` | The hub parameters (which are written to the logfile)

  Methods Summary

  `get_mtype_subtypes`(mtype) | Return a list containing all the possible wildcarded subtypes of MType.
  `start`([wait]) | Start the current SAMP Hub instance and create the lock file.
  `stop`() | Stop the current SAMP Hub instance and delete the lock file.

  Attributes Documentation

  `id`

    The unique hub ID.

  `is_running`

    Return an information concerning the Hub running status.

    Returns:

    running : bool

    > Is the hub running?

  `params`

    The hub parameters (which are written to the logfile)

  Methods Documentation

  static `get_mtype_subtypes`(mtype)

    Return a list containing all the possible wildcarded subtypes of MType.

    Parameters:

    mtype : str

    > MType to be parsed.

    Returns:

    types : list

    > List of subtypes

    Examples

        >>> from astropy.vo.samp import SAMPHubServer
        >>> SAMPHubServer.get_mtype_subtypes("samp.app.ping")
        ['samp.app.ping', 'samp.app.*', 'samp.*', '*']

  `start`(wait=False)

    Start the current SAMP Hub instance and create the lock file. Hub start-up can be blocking or non blocking depending on the `wait` parameter.

    Parameters:

    wait : bool

    > If `True` then the Hub process is joined with the caller, blocking the code flow. Usually `True` option is used to run a stand-alone Hub in an executable script. If `False` (default), then the Hub process runs in a separated thread. `False` is usually used in a Python shell.

  `stop`()

    Stop the current SAMP Hub instance and delete the lock file.