Skip to content

serverinfo

Defines the basic server management api.

Attributes

DATAFILE_ID = 'serverinfo' module-attribute

mlogger = get_logger(__name__) module-attribute

Classes

RoutesServerInfo(host, version, process_id, server_host, server_port)

Bases: object

Routes server info.

Source code in pyrevitlib/pyrevit/routes/server/serverinfo.py
def __init__(self,
             host, version, process_id,
             server_host, server_port):
    # host app info
    self.host = host
    self.version = version
    self.process_id = process_id
    # server info
    self.server_host = server_host
    self.server_port = server_port

Attributes

host = host instance-attribute
version = version instance-attribute
process_id = process_id instance-attribute
server_host = server_host instance-attribute
server_port = server_port instance-attribute

Functions

get_cache_data()

Get json string of this instance.

Source code in pyrevitlib/pyrevit/routes/server/serverinfo.py
def get_cache_data(self):
    """Get json string of this instance."""
    data_dict = OrderedDict()
    for key in sorted(self.__dict__.keys()):
        data_dict[key] = self.__dict__[key]
    return data_dict

Functions

get_registered_servers()

Get all registered servers on this machine.

Returns:

Type Description
list[RoutesServerInfo]

list of registered servers

Source code in pyrevitlib/pyrevit/routes/server/serverinfo.py
def get_registered_servers():
    """Get all registered servers on this machine.

    Returns:
        (list[RoutesServerInfo]): list of registered servers
    """
    return _get_all_serverinfo()

register()

Register host:port for this host instance.

Source code in pyrevitlib/pyrevit/routes/server/serverinfo.py
def register():
    """Register host:port for this host instance."""
    data_file = _get_host_serverinfo_file()
    if op.exists(data_file):
        return _read_serverinfo(data_file)
    else:
        return _get_new_serverinfo(data_file)

unregister()

Remove registered server host:port for this host instance.

Source code in pyrevitlib/pyrevit/routes/server/serverinfo.py
def unregister():
    """Remove registered server host:port for this host instance."""
    data_file = _get_host_serverinfo_file()
    if op.exists(data_file):
        appdata.garbage_data_file(data_file)