Other features ============== Electronic logbook ------------------ `IcatClient` can be used to send messages and images to beamline and experiment session logbooks. 1. Getting an `IcatClient` instance From the current BLISS session: .. code-block:: python from bliss import current_session icat_client = current_session.scan_saving.icat_client or create an `IcatClient`: .. code-block:: python from pyicat_plus.client.main import IcatClient API_KEY = "" # Replace with your API key ENDPOINT_URL = "https://icatplus.esrf.fr" client = IcatClient(elogbook_url=ENDPOINT_URL, elogbook_token=API_KEY) 2. Send a message to the beamline logbook .. code-block:: python BEAMLINE = "ID00" TAGS = ["test"] # Send a text message client.send_message( msg="This is a message to the beamline logbook", beamline=BEAMLINE, beamline_only=True, tags=TAGS, ) # Send an image or a file client.send_binary_file( filename="/path/to/file.png", # Replace with your file beamline=BEAMLINE, beamline_only=True, tags=TAGS, ) 3. Send a message to the experiment session logbook .. code-block:: python PROPOSAL = "id002510" # Send a text message client.send_message( msg="This is a message to the experiment session logbook", beamline=BEAMLINE, proposal=PROPOSAL, tags=TAGS, ) # Send an image or a file client.send_binary_file( filename="/path/to/file.png", # Replace with your file beamline=BEAMLINE, proposal=PROPOSAL, tags=TAGS, ) To log to the electronic logbook from BLISS, see the `BLISS documentation `_. Authenticated access -------------------- Using SSO: .. code-block:: python from pyicat_plus.client.main import IcatClient URL = "https://icatplus.esrf.fr/" sso_token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." icatClient = IcatClient(icatplus_restricted_url=URL) icatClient.do_log_in(sso_token) Using another authentication plugin: .. code-block:: python from pyicat_plus.client.main import IcatClient URL = "https://icatplus.esrf.fr/" icatClient = IcatClient(icatplus_restricted_url=URL) icatClient.do_log_in(password="****", username="daiquiri", plugin="db") Example: retrieve sample metadata .. code-block:: python from datetime import date metadata = icatClient.get_sample_metadata_by( proposal="hg237", beamline="id13", session_start_date=date(2025, 7, 24) ) print(metadata)