All Samples(2586) | Call(2384) | Derive(0) | Import(202)
Create and return a temporary file. Arguments: 'prefix', 'suffix', 'dir' -- as for mkstemp. 'mode' -- the mode argument to os.fdopen (default "w+b"). 'bufsize' -- the buffer size argument to os.fdopen (default -1). The file is created as mkstemp() would do it. Returns an object with a file-like interface. The file has no name, and will cease to exist when it is closed.
def TemporaryFile(mode='w+b', bufsize=-1, suffix="",
prefix=template, dir=None):
"""Create and return a temporary file.
Arguments:
'prefix', 'suffix', 'dir' -- as for mkstemp.
'mode' -- the mode argument to os.fdopen (default "w+b").
'bufsize' -- the buffer size argument to os.fdopen (default -1).
The file is created as mkstemp() would do it.
Returns an object with a file-like interface. The file has no
name, and will cease to exist when it is closed.
"""
if dir is None:
dir = gettempdir()
if 'b' in mode:
flags = _bin_openflags
else:
flags = _text_openflags
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
try:
_os.unlink(name)
return _os.fdopen(fd, mode, bufsize)
except:
_os.close(fd)
raise
if self._singleInstance:
# create shared memory temporary file
if wx.Platform == '__WXMSW__':
tfile = tempfile.TemporaryFile(prefix="ag", suffix="tmp")
fno = tfile.fileno()
self._sharedMemory = mmap.mmap(fno, 1024, "shared_memory")
else:
src/r/o/roreditor-HEAD/lib_windows/wx/lib/pydocview.py roreditor(Download)
if self._singleInstance:
# create shared memory temporary file
if wx.Platform == '__WXMSW__':
tfile = tempfile.TemporaryFile(prefix="ag", suffix="tmp")
fno = tfile.fileno()
self._sharedMemory = mmap.mmap(fno, 1024, "shared_memory")
else:
src/s/c/scipy-HEAD/scipy/weave/catalog.py scipy(Download)
# appends 6 random chars to this prefix).
prefix = 'dummy_%s_%s_' % (socket.gethostname(),os.getpid())
try:
tmp = tempfile.TemporaryFile(prefix=prefix,dir=dir)
except OSError:
return False
# The underlying file is destroyed upon closing the file object (under
src/s/l/Slipy-Tractograhpy-HEAD/weave-local/catalog.py Slipy-Tractograhpy(Download)
# appends 6 random chars to this prefix).
prefix = 'dummy_%s_%s_' % (socket.gethostname(),os.getpid())
try:
tmp = tempfile.TemporaryFile(prefix=prefix,dir=dir)
except OSError:
return False
# The underlying file is destroyed upon closing the file object (under
src/a/p/apycotbot-1.10.0/utils.py apycotbot(Download)
import stat import logging from subprocess import PIPE, STDOUT, Popen from tempfile import TemporaryFile from Pyro import errors
def run(self):
"""actually run the task by spawning a subprocess"""
os.environ['LC_ALL'] = 'fr_FR.UTF-8' # XXX force utf-8
outfile = TemporaryFile(mode='w+', bufsize=0)
if self.parsed_content == 'merged':
errfile = STDOUT
else:
errfile = TemporaryFile(mode='w+', bufsize=0)
src/a/p/apycotbot-1.10.0/server.py apycotbot(Download)
import logging from os.path import exists, join, normpath from subprocess import Popen from tempfile import TemporaryFile from threading import Thread, Lock, Timer from traceback import format_exc from datetime import datetime, timedelta
def _run_command(self, command, pacname):
"""actually run the task by spawning a subprocess"""
outfile = TemporaryFile(mode='w+', bufsize=0)
errfile = TemporaryFile(mode='w+', bufsize=0)
self.info(' '.join(command))
cmd = Popen(command, bufsize=0, stdout=outfile, stderr=errfile)
if self['max-time']:
src/b/l/bleachbit-HEAD/bleachbit/FileUtilities.py bleachbit(Download)
i = 0
while True:
try:
f = tempfile.TemporaryFile(dir = pathname, suffix = __random_string(maxlen))
break
except OSError, e:
if e.errno == 36:
# OSError: [Errno 36] File name too long
if maxlen > 10:
maxlen -= 10
i += 1
if i > 100:
f = tempfile.TemporaryFile(dir = pathname)
src/s/c/scipy-0.8.0/scipy/weave/catalog.py scipy(Download)
# appends 6 random chars to this prefix).
prefix = 'dummy_%s_%s_' % (socket.gethostname(),os.getpid())
try:
tmp = tempfile.TemporaryFile(prefix=prefix,dir=dir)
except OSError:
return False
# The underlying file is destroyed upon closing the file object (under
src/a/p/apycot-2.0.3/_apycotlib/__init__.py apycot(Download)
import stat from os.path import exists, join, dirname from subprocess import STDOUT, Popen from tempfile import TemporaryFile from logilab.common.textutils import splitstrip
def run(self):
"""actually run the task by spawning a subprocess"""
outfile = TemporaryFile(mode='w+', bufsize=0)
if self.parsed_content == 'merged':
errfile = STDOUT
else:
errfile = TemporaryFile(mode='w+', bufsize=0)
src/a/s/asciiporn-2009.05.01/asciiporn/weave/catalog.py asciiporn(Download)
# appends 6 random chars to this prefix).
prefix = 'dummy_%s_%s_' % (socket.gethostname(),os.getpid())
try:
tmp = tempfile.TemporaryFile(prefix=prefix,dir=dir)
except OSError:
return False
# The underlying file is destroyed upon closing the file object (under
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next