File tree Expand file tree Collapse file tree 4 files changed +17
-8
lines changed
Expand file tree Collapse file tree 4 files changed +17
-8
lines changed Original file line number Diff line number Diff line change 1+ 2010-04-26 Doug Hellmann <dhellmann@racemi.com>
2+
3+ * virtualenvwrapper.sh (virtualenvwrapper_tempfile): Add a suffix
4+ to the tempfile name so we know the tempfile module isn't going to
5+ erase it.
Original file line number Diff line number Diff line change 2020 @echo " website - build web version of docs"
2121 @echo " installwebsite - deploy web version of docs"
2222 @echo " develop - install development version"
23+ @echo " test - run the test suite"
2324
2425
2526.PHONY : sdist
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ setUp () {
2323}
2424
2525test_tempfile () {
26- filename=$( virtualenvwrapper_tempfile)
26+ filename=$( virtualenvwrapper_tempfile hook )
2727 rm -f $filename
2828 assertSame " $TMPDIR " " $( dirname $filename ) /"
2929 assertTrue " echo $filename | grep virtualenvwrapper"
@@ -32,11 +32,11 @@ test_tempfile () {
3232test_no_python () {
3333 old=$VIRTUALENVWRAPPER_PYTHON
3434 VIRTUALENVWRAPPER_PYTHON=false
35- filename=$( virtualenvwrapper_tempfile)
35+ filename=$( virtualenvwrapper_tempfile hook )
3636 VIRTUALENVWRAPPER_PYTHON=$old
3737 rm -f $filename
38- assertSame " $TMPDIR " " $( dirname $filename ) /"
39- assertTrue " echo $filename | grep virtualenvwrapper.$$ "
38+ assertSame " TMPDIR and path not the same for $filename . " " $TMPDIR " " $( dirname $filename ) /"
39+ assertTrue " virtualenvwrapper and pid not in filename. " " echo $filename | grep virtualenvwrapper.$$ "
4040}
4141
4242. " $test_dir /shunit2"
Original file line number Diff line number Diff line change @@ -76,11 +76,14 @@ virtualenvwrapper_verify_workon_home () {
7676
7777# Use Python's tempfile module to create a temporary file
7878# with a unique and not-likely-to-be-predictable name.
79+ # Expects 1 argument, the suffix for the new file.
7980virtualenvwrapper_tempfile () {
80- $ VIRTUALENVWRAPPER_PYTHON -c " import tempfile; print tempfile.NamedTemporaryFile(prefix='virtualenvwrapper.').name"
81- if [ $? -ne 0 ]
81+ typeset base= $( " $ VIRTUALENVWRAPPER_PYTHON" -c " import tempfile; print tempfile.NamedTemporaryFile(prefix='virtualenvwrapper.').name" )
82+ if [ -z " $base " ]
8283 then
83- echo " ${TMPDIR:-/ tmp} /virtualenvwrapper.$$ .` date +%s` "
84+ echo " ${TMPDIR:-/ tmp} /virtualenvwrapper.$$ .` date +%s` .$1 "
85+ else
86+ echo " $base .$1 "
8487 fi
8588}
8689
@@ -89,7 +92,7 @@ virtualenvwrapper_run_hook () {
8992 # First anything that runs directly from the plugin
9093 " $VIRTUALENVWRAPPER_PYTHON " -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION " $@ "
9194 # Now anything that wants to run inside this shell
92- hook_script=$( virtualenvwrapper_tempfile)
95+ hook_script=" $( virtualenvwrapper_tempfile hook ) "
9396 " $VIRTUALENVWRAPPER_PYTHON " -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \
9497 --source " $@ " >> " $hook_script "
9598 source " $hook_script "
You can’t perform that action at this time.
0 commit comments