1 from rox
import g
, saving
4 from rox
import processes
7 def shell_escape(text
):
8 """Return text with \ and ' escaped"""
9 return text
.replace("\\", "\\\\").replace("'", "\\'")
11 def Tmp(mode
= 'w+b'):
12 "Create a seekable, randomly named temp file (deleted automatically after use)."
15 return tempfile
.NamedTemporaryFile(mode
, suffix
= '-archive')
17 # python2.2 doesn't have NamedTemporaryFile...
21 name
= tempfile
.mktemp(`random
.randint(1, 1000000)`
+ '-archive')
23 fd
= os
.open(name
, os
.O_RDWR|os
.O_CREAT|os
.O_EXCL
, 0700)
24 tmp
= tempfile
.TemporaryFileWrapper(os
.fdopen(fd
, mode
), name
)
29 fcntl
.fcntl(fd
, fcntl
.F_SETFD
, 0)