E3-615: Replace `iocsh` shell script with python script
Rewrite iocsh
, our wrapper for EPICS base's softIocPVA
in Python (3.6), using only standard library modules.
I have modified features: partly to work better with python (and more standardised argument handling), and partly to remove less-used features. This can be modified based on feedback from users.
Comparison of iocsh -h
Previous
USAGE: iocsh [startup files]
Start the ESS iocsh and load startup scripts.
Options:
-?, -h, --help Show this page and exit.
-v, --version Show version and exit.
-rt Execute in realtime mode.
(Also -RT, -realtime, --realtime)
-c 'cmd args' Ioc shell command.
-s 'prog m=v' Sequencer program (and arguments), run with 'seq'.
This forces an 'iocInit' before running the program.
-i Do not add iocInit. This option does not override
a valid iocInit in the startup script.
(Also -noinit, --noinit)
-r module[,ver] Module (optionally with version) loaded via 'require'.
-l 'cell path' Run Ioc with a cell path.
-dg [--dgarg='gdb-options'] Run with debugger gdb with user selected options or default option.
-dv [--dvarg='valgrind-options'] Run with valgrind with user selected options or default option.
-n Run with 'nice --10' (requires sudo).
@file More arguments are read from file.
Supported filetypes:
*.db, *.dbt, *.template loaded via 'dbLoadRecords'
*.subs, *.subst loaded via 'dbLoadTemplate'
*.dbd loaded via 'dbLoadDatabase'
*.so loaded via 'dlload'
All other files are executed as startup scripts by the EPICS shell.
After a file you can specify substitutions like m1=v1 m2=v1 for that file.
Examples:
iocsh st.cmd
iocsh my_database.template P=XY M=3
iocsh -r my_module,version -c 'initModule()'
iocsh -c 'var requireDebug 1' st.cmd
iocsh -i st.cmd
iocsh -dv --dvarg='--vgdb=full'
iocsh -dv st.cmd
New
usage: IOC shell for e3 [-h] [-V] [-r MODULE] [-c COMMAND] [-d DATABASE]
[-l PATH] [-rt | -dg [ARGUMENT] | -dv [ARGUMENT]] [-i]
[file]
ESS EPICS environment (e3) wrapper for softIocPVA
positional arguments:
file path to startup script
optional arguments:
-h, --help show this help message and exit
-V, --version print version and exit
-r MODULE, --require MODULE
load module(s), optionally with version using the
syntax `module,version`
-c COMMAND, --command COMMAND
execute command(s)
-d DATABASE, --database DATABASE
load database file(s) (`dbLoadRecord`)
-l PATH, --cell-path PATH
path(s) to cell(s)
-rt, --realtime
-dg [ARGUMENT], --gdb [ARGUMENT]
run with gdb
-dv [ARGUMENT], --valgrind [ARGUMENT]
run with valgrind
-i, --no-init
Comparison of startup
Previous
Warning: environment variable IOCNAME is not set.
███████╗██████╗ ██╗ ██████╗ ██████╗ ███████╗██╗ ██╗███████╗██╗ ██╗
██╔════╝╚════██╗ ██║██╔═══██╗██╔════╝ ██╔════╝██║ ██║██╔════╝██║ ██║
█████╗ █████╔╝ ██║██║ ██║██║ ███████╗███████║█████╗ ██║ ██║
██╔══╝ ╚═══██╗ ██║██║ ██║██║ ╚════██║██╔══██║██╔══╝ ██║ ██║
███████╗██████╔╝ ██║╚██████╔╝╚██████╗ ███████║██║ ██║███████╗███████╗███████╗
╚══════╝╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝
# Start at "2023-W39-Sep26-0928-48-CEST"
# European Spallation Source ERIC : iocsh (5.0.0-PID-10573)
#
############################################################################
## Shell and environment variables
############################################################################
# PWD = "/home/anderslindh/repos/e3-require-bk"
# USER = "anderslindh"
# LOGNAME = "anderslindh"
# PATH = "/epics/base-7.0.7/require/5.0.0/bin:/epics/base-7.0.7/bin/linux-x86_64:/opt/conda/condabin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/var/lib/snapd/snap/bin:/home/anderslindh/.local/bin:/home/anderslindh/bin"
#
############################################################################
## EPICS variables
############################################################################
# EPICS_BASE = "/epics/base-7.0.7"
# EPICS_HOST_ARCH = "linux-x86_64"
# EPICS_DRIVER_PATH = "/epics/base-7.0.7/require/5.0.0/siteMods"
# EPICS_CA_AUTO_ADDR_LIST = ""
# EPICS_CA_ADDR_LIST = ""
# EPICS_PVA_AUTO_ADDR_LIST = ""
# EPICS_PVA_ADDR_LIST = ""
#
############################################################################
## e3-specific variables
############################################################################
# E3_REQUIRE_VERSION = "5.0.0"
# E3_REQUIRE_LOCATION = "/epics/base-7.0.7/require/5.0.0"
# E3_REQUIRE_BIN = "/epics/base-7.0.7/require/5.0.0/bin"
# E3_REQUIRE_DB = "/epics/base-7.0.7/require/5.0.0/db"
# E3_REQUIRE_DBD = "/epics/base-7.0.7/require/5.0.0/dbd"
# E3_REQUIRE_INC = "/epics/base-7.0.7/require/5.0.0/include"
# E3_REQUIRE_LIB = "/epics/base-7.0.7/require/5.0.0/lib"
#
############################################################################
## IOC startup commands
############################################################################
# // Set REQUIRE_IOC for its internal PVs
epicsEnvSet REQUIRE_IOC "REQMOD:ics-alo-vm-10573"
#
# // Set E3_IOCSH_TOP for the absolute path where iocsh is executed.
epicsEnvSet E3_IOCSH_TOP "/home/anderslindh/repos/e3-require-bk"
#
# // Load require module, version 5.0.0
#
dlload /epics/base-7.0.7/require/5.0.0/lib/linux-x86_64/librequire.so
dbLoadDatabase /epics/base-7.0.7/require/5.0.0/dbd/require.dbd
require_registerRecordDeviceDriver
Loading module info records for require
#
# // Set the IOC Prompt String
epicsEnvSet IOCSH_PS1 "10573 > "
#
iocInit
Starting iocInit
############################################################################
## EPICS R7.0.7-E3-7.0.7-patch
## Rev. 2023-01-30T16:37+0000
## Rev. Date build date/time:
############################################################################
iocRun: All initialization complete
New
,----. ,--. ,-----. ,-----. ,--. ,--.,--.
,---. '.-. | | |' .-. '' .--./ ,---. | ,---. ,---. | || |
| .-. : .' < | || | | || | ( .-' | .-. || .-. :| || |
\ --./'-' | | |' '-' '' '--'\ .-' `)| | | |\ --.| || |
`----'`----' `--' `-----' `-----' `----' `--' `--' `----'`--'`--'
Starting e3 IOC shell version 5.0.0-rc15
WARNING: Environment variable IOCNAME is not set.
DEBUG: PID for iocsh 28515
DEBUG: Script path is /opt/epics/base-7.0.7post1/require/5.0.0-rc15/bin/iocsh
DEBUG: Executed from /home/anderslindh/repos/e3-require
DEBUG: Temporary startup script at /tmp/tmp34royaja
DEBUG: Running command `/opt/epics/base-7.0.7post1/bin/linux-x86_64/softIocPVA -D /opt/epics/base-7.0.7post1/dbd/softIocPVA.dbd /tmp/tmp34royaja`
epicsEnvSet REQUIRE_IOC "TEST:anderslindh-28515"
epicsEnvSet IOCSH_TOP "/home/anderslindh/repos/e3-require"
epicsEnvSet IOCSH_PS1 "ics-alo-vm-28515 > "
dlload /opt/epics/base-7.0.7post1/require/5.0.0-rc15/lib/linux-x86_64/librequire.so
dbLoadDatabase /opt/epics/base-7.0.7post1/require/5.0.0-rc15/dbd/require.dbd
require_registerRecordDeviceDriver
Loading module info records for require
iocInit
Starting iocInit
############################################################################
## EPICS R7.0.7-E3-7.0.7post1-patch
## Rev. 2023-09-21T11:22+0200
## Rev. Date build date/time:
############################################################################
iocRun: All initialization complete
Comparison of IOC prompt
Previous
10573 >
New
ics-alo-vm-11037 >
Comparison of fallback prefix
Previous
REQMOD:ics-alo-vm-10573:BaseVersion
New
TEST:anderslindh-11037:BaseVersion
See CHANGELOG for descriptions of functional changes.
Edited by Anders Lindh Olsson