Python package for communication with CS Studio save-and-restore service
Project description
save-and-restore-api
save-and-restore-api is a Python library for communicating with Save-and-Restore service
(CS Studio Phoebus). The package provides syncronous (thread-based) and asynchronous (asyncio)
versions of the API functions.
How to Use the Library
The following example code creates a folder node named "My Folder" under the root node:
from save_and_restore_api import SaveRestoreAPI
with SaveRestoreAPI(base_url="http://localhost:8080/save-restore") as SR:
SR.auth_set(username="user", password="user_password")
root_folder_uid = SR.ROOT_NODE_UID
node={"name": "My Folder", "nodeType": "FOLDER"}
folder = SR.node_add(root_folder_uid, node=node)
print(f"Created folder metadata: {folder}")
Here is an async version of the same code:
from save_and_restore_api.aio import SaveRestoreAPI
async with SaveRestoreAPI(base_url="http://localhost:8080/save-restore") as SR:
await SR.auth_set(username="user", password="user_password")
root_folder_uid = SR.ROOT_NODE_UID
node={"name": "My Folder", "nodeType": "FOLDER"}
folder = await SR.node_add(root_folder_uid, node=node)
print(f"Created folder metadata: {folder}")
save-and-restore CLI Tool
save-and-restore CLI tool is installed with the package. The tool allows performing
a limited set of basic operations on the nodes of the Save-and-Restore service.
The currently selected set of operations:
-
LOGIN: test login credentials;
-
CONFIG ADD: create configuration node based on a list of PVs read from a file;
-
CONFIG UPDATE: update an existing configuration node based on a list of PVs read from a file;
-
CONFIG GET: get information about an existing configuration node, including the list of PVs.
The tool was primarily developed for adding snapshot configurations to Save-and-Restore
based on lists of PVs loaded from local files. Typical use case is to create a configuration
based on a list of PVs read from an autosave (.sav) file saved by an IOC. Currently only
autosave files are supported, but support for other formats can be added if needed.
The list of supported functions can also be extended.
How to use save-and-restore CLI Tool
Check login credentials. User password is requested interactively. Alternatively, the password can be passed using environment variable `SAVE_AND_RESTORE_API_USER_PASSWORD``.
save-and-restore --base-url http://localhost:8080/save-restore --user-name=user LOGIN
Read the configuration node named 'eiger_config'. Print the full configuration data (the list of PVs):
save-and-restore --base-url http://localhost:8080/save-restore \
CONFIG GET --config-name /detectors/imaging/eiger_config --show-data=ON
Create a new configuration node named 'eiger_config'. Load the list of PVs from
file eiger_pvs.sav. Automatically create any missing parent folders in
the path:
save-and-restore --base-url=http://localhost:8080/save-restore --user-name=user \
--create-folders=ON CONFIG ADD --config-name=/detectors/imaging/eiger_config \
--file-name=eiger_pvs.sav --file-format=autosave
Update the existing configuration node named 'eiger_config'. Load the list of PVs
from the file eiger_pvs.sav:
save-and-restore --base-url http://localhost:8080/save-restore --user-name=user \
CONFIG UPDATE --config-name /detectors/imaging/eiger_config \
--file-name eiger_pvs.sav --file-format autosave
Add new or update the existing configuration node named 'eiger_config'. Load the list of PVs
from the file eiger_pvs.sav:
save-and-restore --base-url http://localhost:8080/save-restore --user-name=user \
CONFIG ADD-OR-UPDATE --config-name /detectors/imaging/eiger_config \
--file-name eiger_pvs.sav --file-format autosave
Print full list of options:
save-and-restore -h
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file save_and_restore_api-0.1.0.tar.gz.
File metadata
- Download URL: save_and_restore_api-0.1.0.tar.gz
- Upload date:
- Size: 49.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38c868640fd6fc90a450a98bb0c7cd1ed3ecba61f17379bfb7c8b0d471f8ad93
|
|
| MD5 |
9782d84d4c7287d2e84fe9a3563fcdb3
|
|
| BLAKE2b-256 |
831a8074ea00a4bbfb99f6dd697098b922c60a02b7ae83ec1f9836f5618b28b2
|
File details
Details for the file save_and_restore_api-0.1.0-py3-none-any.whl.
File metadata
- Download URL: save_and_restore_api-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65971ebf822181fd66e2aef601167c8bf473ddf03830c948da26a18f4e256552
|
|
| MD5 |
4eadf63e092b38375eb44a360f7c106a
|
|
| BLAKE2b-256 |
1e68c6c96aee551bc4bcb77e100da32b9b79b0d57504d4740ed9bf1b7b3613dd
|