Here's a handy tip for those of you that use zendmd and also happen to
use TextMate...
To run a zendmd script in textmate and have the output sent to an HTML
window, do the following:
1) In the textmate menu, click Bundles > Bundle Editor > Edit
Commands...
2) Open/Disclose the Python bundle from the list of available bundles
3) Select "Run Script (PyMate) and click the double-plus (duplicate)
button at the bottom of the bundle editor window to copy this command.
4) Rename the new command "Run Script (zendmd)".
5) Change the Key Equivalent from Command+R to Command+Z
6) Paste the following script into the command script field:
#!/bin/bash
[[ -z "$TM_FILEPATH" ]] && TM_TMPFILE=$(mktemp -t pythonInTerm)
: "${TM_FILEPATH:=$TM_TMPFILE}"; cat >"$TM_FILEPATH"
env -i
source $HOME/.bashrc
cd ${TM_DIRECTORY}
TPY=${ZENHOME}/bin/zendmd
echo "<PRE>"
${TPY} <${TM_FILEPATH}
echo "</PRE>"
rm -rf ${TM_TMPFILE}
7) Note the line "source $HOME/.bashrc". My .bashrc happens to be
where I set my zenoss environment variables -- adjust yours accordingly:
export ZENHOME="$HOME/Library/zenoss"
export PYTHON="ZENHOME/bin/python"
export PYTHONPATH="$ZENHOME/lib/python"
export PATH="$ZENHOME/bin:$PATH"
8) Create a new script document with the following code and name it
"dmd-test.py"
for d in dmd.Devices.getSubDevices():
print d.id
9) Press Command+Z -- the script should execute and its output should
go to an HTML window within textmate.
10) Enjoy!
~explosiv0SX
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users