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
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/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/s/c/scrapy-HEAD/scrapy/contrib/feedexport.py scrapy(Download)
""" import sys, os, posixpath from tempfile import TemporaryFile from datetime import datetime from urlparse import urlparse from ftplib import FTP
def open_spider(self, spider):
file = TemporaryFile(prefix='feed-')
exp = self._get_exporter(file)
exp.start_exporting()
self.slots[spider] = SpiderSlot(file, exp)
def close_spider(self, spider):
src/w/e/webrpc-HEAD/webrpc.py webrpc(Download)
import msgpack from Cookie import SimpleCookie from tempfile import TemporaryFile from traceback import format_exc from urllib import quote as urlquote from urlparse import urlunsplit, urljoin
if 'bottle.body' not in self.environ:
maxread = max(0, self.content_length)
stream = self.environ['wsgi.input']
body = BytesIO() if maxread < MEMFILE_MAX else TemporaryFile(mode='w+b')
while maxread > 0:
part = stream.read(min(maxread, MEMFILE_MAX))
if not part: #TODO: Wrong content_length. Error? Do nothing?
src/p/y/pytoaster-HEAD/third-party/lib/common/bottle.py pytoaster(Download)
import time from Cookie import SimpleCookie from tempfile import TemporaryFile from traceback import format_exc from urllib import quote as urlquote from urlparse import urlunsplit, urljoin
if maxread < MEMFILE_MAX:
self._body = BytesIO()
else:
self._body = TemporaryFile(mode='w+b')
while maxread > 0:
part = stream.read(min(maxread, MEMFILE_MAX))
if not part: #TODO: Wrong content_length. Error? Do nothing?
src/s/c/Scrapy-0.10.3/scrapy/contrib/feedexport.py Scrapy(Download)
""" import sys, os, posixpath from tempfile import TemporaryFile from datetime import datetime from urlparse import urlparse from ftplib import FTP
def open_spider(self, spider):
file = TemporaryFile(prefix='feed-')
exp = self._get_exporter(file)
exp.start_exporting()
self.slots[spider] = SpiderSlot(file, exp)
def close_spider(self, spider):
src/t/s/ts3bot-HEAD/trunk/src/bottle.py ts3bot(Download)
import tempfile from Cookie import SimpleCookie from tempfile import TemporaryFile from traceback import format_exc from urllib import quote as urlquote from urlparse import urlunsplit, urljoin
if 'bottle.body' not in self.environ:
maxread = max(0, self.content_length)
stream = self.environ['wsgi.input']
body = BytesIO() if maxread < MEMFILE_MAX else TemporaryFile(mode='w+b')
while maxread > 0:
part = stream.read(min(maxread, MEMFILE_MAX))
if not part: #TODO: Wrong content_length. Error? Do nothing?
src/l/o/logilab-mtconverter-0.8.0/transforms/odt2text.py logilab-mtconverter(Download)
""" from zipfile import ZipFile from lxml import etree from tempfile import TemporaryFile as tmpfile from logilab.mtconverter.transform import Transform
def _convert(self, trdata):
data = trdata.data
# XXX ZipFile should also accept a string
# however, there is some bug within
# so we feed it a file
if isinstance(data, str):
tmp = tmpfile(mode='w+b')
src/m/u/multipart-HEAD/multipart.py multipart(Download)
__version__ = '0.1' __license__ = 'MIT' from tempfile import TemporaryFile from wsgiref.headers import Headers import re, sys try:
raise MultipartError('Size of body exceeds Content-Length header.')
if self.size > self.memfile_limit and isinstance(self.file, BytesIO):
# TODO: What about non-file uploads that exceed the memfile_limit?
self.file, old = TemporaryFile(mode='w+b'), self.file
old.seek(0)
copy_file(old, self.file, self.size, self.buffer_size)
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next