-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckup.py
executable file
·49 lines (38 loc) · 1.15 KB
/
checkup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
'''
print descriptions for all motors defined in pvlist.xml
Uses PyEpics
usage::
/APSshare/anaconda/x86_64/bin/python ./checkup.py pvlist.xml | more
'''
# $Id$
from xml.etree import ElementTree
import epics
import pyRestTable
# XML_FILE = 'test.xml'
# XML_FILE = 'pvlist_2011-09-09.xml'
XML_FILE = 'pvlist.xml'
tree = ElementTree.parse(XML_FILE)
def basePVname(pv):
'''' return the base part of the PV name '''
return pv.split(".")[0]
d = {}
for key in tree.findall(".//EPICS_PV"):
if key.get("_ignore_", "false").lower() == "true":
continue
pv = key.get("PV")
base = basePVname(pv)
if pv == base + ".RBV":
rtyp = epics.caget(base + ".RTYP")
if rtyp not in ("motor", ):
continue
mne = key.get("mne")
desc = key.get("description")
#fmt = key.get("display_format", "%s") # default format
text = epics.caget(base + ".DESC")
d[mne.lower()] = (rtyp, base, mne, text, desc)
t = pyRestTable.Table()
t.labels = ( "RTYP", "EPICS PV", "mnemonic", "pv.DESC", "pvlist.xml description" )
for mne in sorted(d.keys()):
t.rows.append( d[mne] )
print t.reST()