pvaccesslist 0.0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Electron-Ion Collider
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.5
2
+ Name: pvaccesslist
3
+ Version: 0.0.5
4
+ Summary: List active EPICS PVAccess PVs by querying discovered PVA servers
5
+ Project-URL: Homepage, https://github.com/eicorg/scripts/tree/main/pvaccesslist
6
+ Author-email: Andrey Sukhanov <sukhanov@bnl.gov>
7
+ License-Expression: BSD-3-Clause
8
+ License-File: LICENSE
9
+ Classifier: Operating System :: POSIX :: Linux
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+
14
+ # pvaccesslist
15
+
16
+ List all active EPICS PVAccess PVs.
17
+
18
+ The script works as follows:
19
+ 1. Runs `pvlist` with no arguments to discover PVAccess servers.
20
+ 2. From each discovered line, extracts the first `ip:port` token after `tcp@[`.
21
+ 3. Runs `pvlist <ip:port>` for each extracted endpoint.
22
+ 4. Writes command output to stdout.
23
+
24
+ ## Requirements
25
+
26
+ - EPICS `pvlist` must be available in `PATH`.
27
+ - Python 3.7+
28
+
29
+ ## Usage
30
+
31
+ - Show help:
32
+ - `python3 -m pvaccesslist.pvaccesslist -h`
33
+ - List PVs to terminal:
34
+ - `python3 -m pvaccesslist.pvaccesslist`
35
+ - Save PV list to file:
36
+ - `python3 -m pvaccesslist.pvaccesslist > pvs.txt`
37
+
38
+ ## Notes
39
+
40
+ - If `pvlist` is missing, the script exits with an error message.
41
+ - Server discovery diagnostics are printed to stderr; PV names are printed to stdout.
@@ -0,0 +1,28 @@
1
+ # pvaccesslist
2
+
3
+ List all active EPICS PVAccess PVs.
4
+
5
+ The script works as follows:
6
+ 1. Runs `pvlist` with no arguments to discover PVAccess servers.
7
+ 2. From each discovered line, extracts the first `ip:port` token after `tcp@[`.
8
+ 3. Runs `pvlist <ip:port>` for each extracted endpoint.
9
+ 4. Writes command output to stdout.
10
+
11
+ ## Requirements
12
+
13
+ - EPICS `pvlist` must be available in `PATH`.
14
+ - Python 3.7+
15
+
16
+ ## Usage
17
+
18
+ - Show help:
19
+ - `python3 -m pvaccesslist.pvaccesslist -h`
20
+ - List PVs to terminal:
21
+ - `python3 -m pvaccesslist.pvaccesslist`
22
+ - Save PV list to file:
23
+ - `python3 -m pvaccesslist.pvaccesslist > pvs.txt`
24
+
25
+ ## Notes
26
+
27
+ - If `pvlist` is missing, the script exits with an error message.
28
+ - Server discovery diagnostics are printed to stderr; PV names are printed to stdout.
@@ -0,0 +1,9 @@
1
+ Create a python script pvaccesslist.py which lists all active EPICS PVAccess PVs.
2
+ To get a list of available PVAccess servers use pvlist program from EPICS without arguments. Output of the pvlist looks like this:
3
+
4
+ GUID 0x24397204572FF765D5482C55 version 2: tcp@[ 130.199.104.35:39303 192.168.50.202:39303 192.168.122.1:39303 ]
5
+ GUID 0xF8EC8C9CD38DBB6B9F0EA5C6 version 2: tcp@[ 130.199.104.35:5075 192.168.50.202:5075 192.168.122.1:5075 ]
6
+
7
+ For each line extract first IP_Port token which comes after 'tcp@['
8
+
9
+ For each IP_port execute 'pvlist IP_port' and write output to stdout.
@@ -0,0 +1,4 @@
1
+ from .pvaccesslist import main
2
+
3
+ raise SystemExit(main())
4
+
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env python3
2
+ """List active EPICS PVAccess PVs by querying discovered PVA servers."""
3
+ __version__ = 'v0.0.1 2026-08-18'# created
4
+ import re
5
+ import subprocess
6
+ import sys
7
+
8
+ FIRST_TCP_ENDPOINT_RE = re.compile(r"tcp@\[\s*([^\s\]]+)")
9
+
10
+ def print_usage() -> None:
11
+ """Print usage information."""
12
+ print(
13
+ "Description:\n"
14
+ " List active EPICS PVAccess PVs by discovering PVA servers with 'pvlist'\n"
15
+ " and running 'pvlist <ip:port>' for each discovered server.\n"
16
+ "Usage:\n"
17
+ " pvaccesslist.py\n"
18
+ " pvaccesslist.py > pvs.txt\n"
19
+ " python3 -m pvaccesslist.pvaccesslist\n"
20
+ )
21
+
22
+ def run_pvlist(args: list[str]) -> subprocess.CompletedProcess[str]:
23
+ """Run `pvlist` and return completed process with captured text output."""
24
+ try:
25
+ return subprocess.run(
26
+ ["pvlist", *args],
27
+ text=True,
28
+ capture_output=True,
29
+ check=False,
30
+ )
31
+ except FileNotFoundError as exc:
32
+ raise RuntimeError(
33
+ "Could not find 'pvlist' in PATH. "
34
+ "Load your EPICS environment or add pvAccess/bin/... to PATH."
35
+ ) from exc
36
+
37
+ def discover_endpoints() -> list[str]:
38
+ """Return unique first tcp@[ ... ] endpoint from each discovered server line."""
39
+ result = run_pvlist([])
40
+ if result.returncode != 0:
41
+ if result.stderr:
42
+ print(result.stderr, end="", file=sys.stderr)
43
+ raise RuntimeError(f"pvlist failed with code {result.returncode}")
44
+
45
+ endpoints: list[str] = []
46
+ seen: set[str] = set()
47
+ for line in result.stdout.splitlines():
48
+ match = FIRST_TCP_ENDPOINT_RE.search(line)
49
+ if not match:
50
+ continue
51
+ endpoint = match.group(1)
52
+ if endpoint not in seen:
53
+ seen.add(endpoint)
54
+ endpoints.append(endpoint)
55
+ return endpoints
56
+
57
+ def main() -> int:
58
+ if "-h" in sys.argv[1:] or "--help" in sys.argv[1:]:
59
+ print_usage()
60
+ return 0
61
+
62
+ try:
63
+ endpoints = discover_endpoints()
64
+ print(f"Discovered {len(endpoints)} PVA servers.", file=sys.stderr)
65
+ except RuntimeError as exc:
66
+ print(f"Error: {exc}", file=sys.stderr)
67
+ return 1
68
+
69
+ for endpoint in endpoints:
70
+ result = run_pvlist([endpoint])
71
+ print(f"--- {endpoint} ---", file=sys.stderr)
72
+ if result.stdout:
73
+ sys.stdout.write(result.stdout)
74
+ if not result.stdout.endswith("\n"):
75
+ sys.stdout.write("\n")
76
+ if result.stderr:
77
+ print(result.stderr, end="", file=sys.stderr)
78
+
79
+ return 0
80
+
81
+ if __name__ == "__main__":
82
+ raise SystemExit(main())
@@ -0,0 +1,22 @@
1
+ [project]
2
+ name = "pvaccesslist"
3
+ version = "0.0.5"
4
+ license = "BSD-3-Clause"
5
+ authors = [
6
+ { name="Andrey Sukhanov", email="sukhanov@bnl.gov" },
7
+ ]
8
+ description = "List active EPICS PVAccess PVs by querying discovered PVA servers"
9
+ readme = "README.md"
10
+ requires-python = ">=3.7"
11
+ classifiers = [
12
+ "Programming Language :: Python :: 3",
13
+ "Operating System :: POSIX :: Linux",
14
+ ]
15
+ dependencies = []
16
+
17
+ [build-system]
18
+ requires = ["hatchling"]
19
+ build-backend = "hatchling.build"
20
+
21
+ [project.urls]
22
+ "Homepage" = "https://github.com/eicorg/scripts/tree/main/pvaccesslist"