Skip to content

Commit

Permalink
Merge pull request #180 from aberges-SLAC/getPVAlias
Browse files Browse the repository at this point in the history
ENH: add getPVAliases and grep_more_ioc scripts
  • Loading branch information
ZLLentz authored May 23, 2024
2 parents 3f52634 + be4e07e commit da49912
Show file tree
Hide file tree
Showing 6 changed files with 1,025 additions and 3 deletions.
57 changes: 54 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,23 @@ usage: get_lastRun options<br/>
</td>
</tr>

<tr>
<td>getPVAliases</td>
<td>
usage: gatherPVAliases [-h] [-d] patt hutch <br/>
positional arguments: <br/>
patt | Regex pattern to match IOCs with.<br/>
-->Can match anything in the IOC procmanager object. e.g. "lm2k2" or "mcs2" or "ek9000"<br>
hutch | 3 letter hutch code. Use "all" to search through all hutches.<br/>
-->Valid arguments: all, aux, cxi, det, hpl, icl, kfe, las, lfe, mec,<br/>
mfx, rix, rrl, thz, tmo, tst, txi, ued, xcs, xpp, xrt<br/>

optional arguments:<br/>
-h, --help | show this help message and exit<br/>
-d, --dry_run | Forces a dry run for the script. No files are saved.<br/>

</tr>

<tr>
<td>grep_ioc</td>
<td>
Expand All @@ -245,6 +262,39 @@ usage: grep_ioc KEYWORD [hutch]<br/>
</td>
</tr>

<tr>
<td>grep_more_ioc</td>
<td>
usage: grep_more_ioc [-h] [-d] patt hutch {print,search} <br/>
positional arguments: <br/>
patt Regex str to search through iocmanager.cfg<br/>
e.g. 'mcs2', 'lm2k2-atm.*', 'ek9000', 'gige.*'<br/>
hutch 3 letter hutch code to search through.<br/>
Use 'all' to search through all hutches.<br/>
Valid arguments: all, aux, cxi, det, hpl, icl, kfe,<br/>
las, lfe, mec, mfx, rix, rrl, thz, tmo, tst, txi, ued,<br/>
xcs, xpp, xrt<br/>
-h, --help Show help message and exit<br/>
-d, --ignore_disabled Exclude IOCs based on disabled state <br/>
Necessary subcommands.<br/>
Use: grep_more_ioc . all [subcommand] --help for more information
{print, search}<br/>
print | Prints all the matching IOCs in a dataframe<br/>
usage: grep_more_ioc patt hutch print [-h] [-c] [-r] [-s] [-y]<br/>
-h, --help | Show help message and exit<br/>
-c, --skip_comments | Prints IOC.cfg file with comments skipped<br/>
-r, --release | Includes the parent IOC release in the dataframe<br/>
-s, --print_dirs | Dump child & parent directors to the terminal<br/>
-y, --print_history | Dump child IOC's history to terminal, if it exists<br/>
search | Regex-like search of child IOCs<br/>
usage: grep_more_ioc patt hutch search [-h] [-q] [-o] PATT<br/>
PATT | The regex str to use in the search<br/>
-h, --help | Show help message and exit<br/>
-q, --quiet | Surpresses file warning for paths that do not exist<br/>
-o, --only_search | Skip printing dataframe, only print search results<br/>
</td>
</tr>

<tr>
<td>grep_pv</td>
<td>
Expand Down Expand Up @@ -308,7 +358,8 @@ usage: ioctool &lt;ioc&gt;|&lt;pv&gt; [option]<br/>
telnet : starts a telnet session with the ioc<br/>
pvs : opens the IOC.pvlist file in less<br/>
</td>
</tr>

</tr>

<tr>
<td>ipmConfigEpics</td>
Expand Down Expand Up @@ -640,9 +691,9 @@ Optional arguments:<br/>

<tr>
<td> set_gem_timing</td>
<td>
<td>
Usage: set_gem_timing [SC or NC]
</td>
</tr>

</table>
</table>
26 changes: 26 additions & 0 deletions scripts/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""
Constants used in grep_more_ioc and getPVAliases
"""
###############################################################################
# %% Imports
###############################################################################

import glob as gb

###############################################################################
# %% Constants
###############################################################################

# Check the directories for the iocmanager config file
VALID_HUTCH = sorted([d for d in gb.glob('/cds/group/pcds/pyps/config'
+ '/*/')
if gb.glob(d + 'iocmanager.cfg')])
# Trim to 3 letter hutch code, include 'all' = '*'
VALID_HUTCH = ['all'] + [s.rsplit(r'/', maxsplit=2)[-2] for s in VALID_HUTCH]

# Keys from iocmanager. Found in /cds/group/pcds/config/*/iocmanager/utils.py
# Update this as needed
DEF_IMGR_KEYS = ['procmgr_config', 'hosts', 'dir', 'id', 'cmd',
'flags', 'port', 'host', 'disable', 'history',
'delay', 'alias', 'hard']
6 changes: 6 additions & 0 deletions scripts/getPVAliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/bash

# execute python script
THIS_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"

/cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.2/bin/python "${THIS_DIR}/getPVAliases.py" "$@"
Loading

0 comments on commit da49912

Please sign in to comment.