Utils

class streamlit_pyvista.helpers.utils.ServerItem(host, type=None, last_init=None, path=None)[source]

Bases: object

A class used to represent servers that managers instantiate

Attributes: host (str): The host of the server. type (str): The type of the server. Default is None. path (str): The path of the server. Default is None.

host: str
type: str = None
last_init: str = None
path: str = None
__init__(host, type=None, last_init=None, path=None)
streamlit_pyvista.helpers.utils.with_lock(lock)[source]
streamlit_pyvista.helpers.utils.is_localhost(url)[source]

Check if the url is localhost or is remote :type url: str :param url: the url to check :type url: str

Returns:

True if the url is a localhost url, False otherwise

Return type:

bool

streamlit_pyvista.helpers.utils.replace_host(url, new_host)[source]

Replace the host in a given URL with a new host.

Parameters:
  • url (str) – The original URL.

  • new_host (str) – The new host to replace the old host.

Returns:

The URL with the host replaced.

Return type:

str

Check if the input is a link :type string: str :param string: string to check :type string: str

Returns:

True if the string is a url, False otherwise

Return type:

bool

streamlit_pyvista.helpers.utils.find_free_port()[source]

Find a free port on the local machine

Returns:

A free port

Return type:

int

streamlit_pyvista.helpers.utils.is_free_port(port, host='localhost')[source]

Check if a given port is free or not

Parameters:
  • port (int) – The port to check.

  • host (str) – The host. By default, “localhost”.

Returns:

True if the port is free, False otherwise.

Return type:

bool

streamlit_pyvista.helpers.utils.is_server_available(server)[source]

Check if the server is available by checking if the number of clients connected to the server is 0

Parameters:

server (ServerItem) – The server to check

Returns:

True if the server is available, False otherwise

Return type:

bool

streamlit_pyvista.helpers.utils.is_server_alive(server_url, timeout=10)[source]

Check if the server is alive by making a request to the server

Parameters:
  • server_url (ServerItem) – The server to check

  • timeout (float) – The timeout for the request. Default is 0.5.

Returns:

True if the server is alive, False otherwise

Return type:

bool

streamlit_pyvista.helpers.utils.wait_for_server_alive(server_url, timeout=2)[source]
streamlit_pyvista.helpers.utils.get_local_ip()[source]
streamlit_pyvista.helpers.utils.is_notebook()[source]

Detect if the code is being run in a jupyter notebook :returns: True if the code is currently run in a juypter notebook, False otherwise :rtype: bool