From e525fd38fb1517ceae8f2e3af3f851d0dc477a35 Mon Sep 17 00:00:00 2001 From: Josh Stillerman Date: Fri, 25 Jun 2021 10:22:07 -0400 Subject: [PATCH] Docs: Fix name of TreeShrHook.py example The distributed TreeHook.py.example is old and would not be called if put in place. This new one will work if enabled. --- deploy/packaging/debian/kernel.noarch | 2 +- deploy/packaging/redhat/kernel.noarch | 2 +- tdi/treeshr/TreeHook.example | 19 --------- tdi/treeshr/TreeShrHook.py.example | 57 +++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 21 deletions(-) delete mode 100644 tdi/treeshr/TreeHook.example create mode 100755 tdi/treeshr/TreeShrHook.py.example diff --git a/deploy/packaging/debian/kernel.noarch b/deploy/packaging/debian/kernel.noarch index 6e5af350c3..c46dfa4717 100644 --- a/deploy/packaging/debian/kernel.noarch +++ b/deploy/packaging/debian/kernel.noarch @@ -225,7 +225,6 @@ ./usr/local/mdsplus/tdi/treeshr/TreeFlushReset.fun ./usr/local/mdsplus/tdi/treeshr/TreeGetCurrentShot.fun ./usr/local/mdsplus/tdi/treeshr/TreeGetRecord.fun -./usr/local/mdsplus/tdi/treeshr/TreeHook.example ./usr/local/mdsplus/tdi/treeshr/TreeOpen.fun ./usr/local/mdsplus/tdi/treeshr/TreeOpenEdit.fun ./usr/local/mdsplus/tdi/treeshr/TreeOpenNew.fun @@ -236,6 +235,7 @@ ./usr/local/mdsplus/tdi/treeshr/TreeSetDbiItm.fun ./usr/local/mdsplus/tdi/treeshr/TreeSetDefault.fun ./usr/local/mdsplus/tdi/treeshr/TreeSetNciItm.fun +./usr/local/mdsplus/tdi/treeshr/TreeShrHook.py.example ./usr/local/mdsplus/tdi/treeshr/TreeTurnOff.fun ./usr/local/mdsplus/tdi/treeshr/TreeTurnOn.fun ./usr/local/mdsplus/tdi/treeshr/TreeWrite.fun diff --git a/deploy/packaging/redhat/kernel.noarch b/deploy/packaging/redhat/kernel.noarch index 8d1aad760f..838a8198ae 100644 --- a/deploy/packaging/redhat/kernel.noarch +++ b/deploy/packaging/redhat/kernel.noarch @@ -257,7 +257,6 @@ ./usr/local/mdsplus/tdi/treeshr/TreeFlushReset.fun ./usr/local/mdsplus/tdi/treeshr/TreeGetCurrentShot.fun ./usr/local/mdsplus/tdi/treeshr/TreeGetRecord.fun -./usr/local/mdsplus/tdi/treeshr/TreeHook.example ./usr/local/mdsplus/tdi/treeshr/TreeOpen.fun ./usr/local/mdsplus/tdi/treeshr/TreeOpenEdit.fun ./usr/local/mdsplus/tdi/treeshr/TreeOpenNew.fun @@ -268,6 +267,7 @@ ./usr/local/mdsplus/tdi/treeshr/TreeSetDbiItm.fun ./usr/local/mdsplus/tdi/treeshr/TreeSetDefault.fun ./usr/local/mdsplus/tdi/treeshr/TreeSetNciItm.fun +./usr/local/mdsplus/tdi/treeshr/TreeShrHook.py.example ./usr/local/mdsplus/tdi/treeshr/TreeTurnOff.fun ./usr/local/mdsplus/tdi/treeshr/TreeTurnOn.fun ./usr/local/mdsplus/tdi/treeshr/TreeWrite.fun diff --git a/tdi/treeshr/TreeHook.example b/tdi/treeshr/TreeHook.example deleted file mode 100644 index bf67a921eb..0000000000 --- a/tdi/treeshr/TreeHook.example +++ /dev/null @@ -1,19 +0,0 @@ -/* FOR INTERNAL USE ONLY */ -public fun TreeHook(in _mode, in _tree, in _shot, in _nid) -{ - switch(_mode) - { - case (0) Write(*,"Open tree: ",_tree," ",_shot); break; - case (1) Write(*,"Open tree edit: ",_tree," ",_shot); break; - case (2) Write(*,"Retrieve tree: ",_tree," ",_shot); break; - case (3) Write(*,"Write tree: ",_tree," ",_shot); break; - case (4) Write(*,"Close tree: ",_tree," ",_shot); break; - case (5) Write(*,"Open NCI file for write:",_tree," ",_shot); break; - case (6) Write(*,"Open DataFile for write:",_tree," ",_shot); break; - case (7) _node = getnci(_nid,"FULLPATH"); Write(*,"Get data for node:",_node," ",_tree," ",_shot);break; - case (8) _node = getnci(_nid,"FULLPATH"); Write(*,"Get characteristics for node:",_node," ",_tree," ",_shot);break; - case (9) _node = getnci(_nid,"FULLPATH"); Write(*,"Put data for node:",_node," ",_tree," ",_shot);break; - case (10) _node = getnci(_nid,"FULLPATH"); Write(*,"put characteristics for node:",_node," ",_tree," ",_shot);break; - } - return(1); -} diff --git a/tdi/treeshr/TreeShrHook.py.example b/tdi/treeshr/TreeShrHook.py.example new file mode 100755 index 0000000000..99f3f4ae3c --- /dev/null +++ b/tdi/treeshr/TreeShrHook.py.example @@ -0,0 +1,57 @@ +# +# Copyright (c) 2017, Massachusetts Institute of Technology All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# Redistributions in binary form must reproduce the above copyright notice, this +# list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + + +def TreeShrHook(args): + """ + This example TreeShrHook will print out the incomming dictionary (args) + for enabled hooks. To use: + + copy this file to someplace in your MDS_PATH, removing the .example extension + + cp /usr/local/mdsplus/tdi/treeshr/TreeShrHook.py.example /usr/site/tdi/TreeShrHook.py + + define TreeHooks environment variable to a comma separated list of + hooks you want to enable + + export TREE_HOOKS OpenTree,CloseTree + + Then open a tree and see the calls logged on stdout: + + jas@mfews05:~$ mdstcl + TCL> set tree RF/shot=-1 + Dict(, "tree","RF", "type","OpenTree", "shot",-1) + Dict(, "tree","RF_FAST", "type","OpenTree", "shot",-1) + TCL> close + Dict(, "tree","RF", "type","CloseTree", "shot",-1) + Dict(, "tree","RF_FAST", "type","CloseTree", "shot",-1) + TCL> exit + + NOTE: For local, distributed, and thick clients this routine runs in the user's context and + on the user's computer. It would have to be installed on all client computers to gather + useful information. + + """ + print(args)