SAMPHubServer¶
-
class
astropy.samp.
SAMPHubServer
(secret=None, addr=None, port=0, lockfile=None, timeout=0, client_timeout=0, mode='single', label='', web_profile=True, web_profile_dialog=None, web_port=21012, pool_size=20)[source]¶ Bases:
object
SAMP Hub Server.
- Parameters
- secretstr, optional
The secret code to use for the SAMP lockfile. If none is is specified, the
uuid.uuid1()
function is used to generate one.- addrstr, 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.
- portint, optional
Listening XML-RPC server socket port. If left set to 0 (the default), the operating system will select a free port.
- lockfilestr, optional
Custom lockfile name.
- timeoutint, optional
Hub inactivity timeout. If
timeout > 0
then the Hub automatically stops after an inactivity period longer thantimeout
seconds. By defaulttimeout
is set to 0 (Hub never expires).- client_timeoutint, optional
Client inactivity timeout. If
client_timeout > 0
then the Hub automatically unregisters the clients which result inactive for a period longer thanclient_timeout
seconds. By defaultclient_timeout
is set to 0 (clients never expire).- modestr, 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, ifmode
is'multiple'
, then the Hub runs using a non-standard lock-file, placed in.samp-1
directory, of the formsamp-hub-<UUID>
, where<UUID>
is a unique UUID assigned to the hub.- labelstr, 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.- web_profilebool, optional
Enables or disables the Web Profile support.
- web_profile_dialogclass, 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. Twoqueue.Queue
instances will be added to the instance as attributesqueue_request
andqueue_result
. When a request is received via thequeue_request
queue, the pop-up should be displayed, and a value ofTrue
orFalse
should be added toqueue_result
depending on whether the user accepted or refused the connection.- web_portint, 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_sizeint, optional
The number of socket connections opened to communicate with the clients.
Attributes Summary
The unique hub ID.
Return an information concerning the Hub running status.
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
(self[, wait])Start the current SAMP Hub instance and create the lock file.
stop
(self)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
- runningbool
Is the hub running?
-
params
¶ The hub parameters (which are written to the logfile)
Methods Documentation
-
static
get_mtype_subtypes
(mtype)[source]¶ Return a list containing all the possible wildcarded subtypes of MType.
- Parameters
- mtypestr
MType to be parsed.
- Returns
- typeslist
List of subtypes
Examples
>>> from astropy.samp import SAMPHubServer >>> SAMPHubServer.get_mtype_subtypes("samp.app.ping") ['samp.app.ping', 'samp.app.*', 'samp.*', '*']