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 <
[email protected] >
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 20
20
@echo " website - build web version of docs"
21
21
@echo " installwebsite - deploy web version of docs"
22
22
@echo " develop - install development version"
23
+ @echo " test - run the test suite"
23
24
24
25
25
26
.PHONY : sdist
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ setUp () {
23
23
}
24
24
25
25
test_tempfile () {
26
- filename=$( virtualenvwrapper_tempfile)
26
+ filename=$( virtualenvwrapper_tempfile hook )
27
27
rm -f $filename
28
28
assertSame " $TMPDIR " " $( dirname $filename ) /"
29
29
assertTrue " echo $filename | grep virtualenvwrapper"
@@ -32,11 +32,11 @@ test_tempfile () {
32
32
test_no_python () {
33
33
old=$VIRTUALENVWRAPPER_PYTHON
34
34
VIRTUALENVWRAPPER_PYTHON=false
35
- filename=$( virtualenvwrapper_tempfile)
35
+ filename=$( virtualenvwrapper_tempfile hook )
36
36
VIRTUALENVWRAPPER_PYTHON=$old
37
37
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.$$ "
40
40
}
41
41
42
42
. " $test_dir /shunit2"
Original file line number Diff line number Diff line change @@ -76,11 +76,14 @@ virtualenvwrapper_verify_workon_home () {
76
76
77
77
# Use Python's tempfile module to create a temporary file
78
78
# with a unique and not-likely-to-be-predictable name.
79
+ # Expects 1 argument, the suffix for the new file.
79
80
virtualenvwrapper_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 " ]
82
83
then
83
- echo " ${TMPDIR:-/ tmp} /virtualenvwrapper.$$ .` date +%s` "
84
+ echo " ${TMPDIR:-/ tmp} /virtualenvwrapper.$$ .` date +%s` .$1 "
85
+ else
86
+ echo " $base .$1 "
84
87
fi
85
88
}
86
89
@@ -89,7 +92,7 @@ virtualenvwrapper_run_hook () {
89
92
# First anything that runs directly from the plugin
90
93
" $VIRTUALENVWRAPPER_PYTHON " -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION " $@ "
91
94
# Now anything that wants to run inside this shell
92
- hook_script=$( virtualenvwrapper_tempfile)
95
+ hook_script=" $( virtualenvwrapper_tempfile hook ) "
93
96
" $VIRTUALENVWRAPPER_PYTHON " -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \
94
97
--source " $@ " >> " $hook_script "
95
98
source " $hook_script "
You can’t perform that action at this time.
0 commit comments