On 2-nov-2006, at 6:32, Bill Bumgarner wrote:
[...] There are three major features that I'd like to have right about now:
(1) be able to trigger pymate (scriptmate or whatever the new thing is called) to run a sort of "designated driver script" at the root level of a project directory. Specifically: I'm editing a unit test in my testsuite/ subdirectory and I want to hit a single command sequence to cause the run-tests.py script (found in the top level "project" directory -- top level directory resulting from a 'mate .' at the command line) to be executed.
At least your first wish-feature can easily be done.
I just finished a (global) command, "attached" to my project, which does something remotely connected.
It only runs if there is a special project variable saying so. It restarts Apache and after that's been successful, it loads (or refreshes) a "designated" test url.
It uses a project variable ($MY_SITE_TEST ) to check whether it actually should do it's thing. And then, if there is no project variable $MY_SITE_TEST_URL given, it runs TextMateTestUrl.py, which just outputs a url to test. I like to get that url from this python script, for this allows me to add extra clauses (when to test what) and lets me add comments to these test urls.
writing this script was fairly easy. The hardest part was to check on the stopping and starting of Apache.
I'm not sure if this helps any to the discussion, but I thought it was related, and I thought I share.
Below is the complete script, if this is usefull for anybody
best
dirk
if [[ "$MY_SITE_TEST" == 1 ]]; then
if [[ "$MY_SITE_TEST_RESTART_APACHE" == 1 ]]; then
#
# For restarting apache we need to first stop it
# and wait till all processes has been halted and
# then restart it again.
# We assume here that Apache has 4 (httpd) processes running
# when fully functional and active
#
"${TM_BUNDLE_SUPPORT}/apachectlUsingKeychain.sh" stop
for (( i = 0; i < 50 && $(echo $(ps -ax | grep [h]ttpd | wc -l)) > 0; i++ )); do
sleep .2;
done
if [ $(ps -ax | grep [h]ttpd | wc -l) == 0 ]; then
echo Apache has stopped
"${TM_BUNDLE_SUPPORT}/apachectlUsingKeychain.sh" start
for (( i = 0; i < 50 && $(echo $(ps -ax | grep [h]ttpd | wc -l)) < 4; i++ )); do
sleep .2;
done
if [ $(ps -ax | grep [h]ttpd | wc -l) == 4 ]; then
echo Apache has started again
else
echo "$(date +%Y-%m-%d\ %H:%M:%S): Apache not yet fully running. Run test aborted."
exit
fi
else
echo "$(date +%Y-%m-%d\ %H:%M:%S): Apache is still running. Relaunch aborted."
exit
fi
fi
if [[ $MY_SITE_TEST_URL ]]; then
echo From the Project Preferences
T_URL=$MY_SITE_TEST_URL
else
echo From the TextMateTestUrl script
TPY=${TM_PYTHON:-pythonw}
T_URL=$(echo $("$TPY" "$TM_PROJECT_DIRECTORY/TextMateTestUrl.py"))
fi
osascript -e "tell app \"Safari\" to open location \"$T_URL\""
fi