本文整理汇总了Python中tempfile.gettempprefix函数的典型用法代码示例。如果您正苦于以下问题:Python gettempprefix函数的具体用法?Python gettempprefix怎么用?Python gettempprefix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gettempprefix函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
# The filename for our temporary xar file
self.archive = os.path.join(tempfile.gettempdir(), "%sxar%sxar" %
(tempfile.gettempprefix(), os.extsep))
# A test subdoc object
self.test_subdoc = xarfile.XarSubdoc("testdoc", subdoc)
# A single file to xar up
self.test_file = makeTestFile(dir = os.path.join(os.sep,
tempfile.gettempprefix()))
# A non-existent filename
self.test_dne = os.path.join(tempfile.gettempprefix(), "dne" + \
str(random.random()))
# Create a few temporary files in a directory to xar up recursively
# XXX: Robustify this to include multiple levels of directories
self.test_dir = tempfile.mkdtemp()
self.test_files = []
for i in xrange(2):
self.test_files.append(makeTestFile(dir = self.test_dir))
self.test_members = self.test_files + \
[tempfile.gettempprefix(), self.test_dir, self.test_file]
self.test_members = map(lambda m: m.lstrip(os.sep), self.test_members)
开发者ID:JackieXie168,项目名称:xar,代码行数:25,代码来源:test_xarfile.py
示例2: setUp
def setUp(self):
# Does our output director exist? If not, create it
if not os.path.isdir('KEGG'):
os.mkdir('KEGG')
# Define some data to work with as a list of tuples:
# (infilename, outfilename, (entry_count, ortholog_count,
# compound_count, map_counts), pathway_image,
# show_image_map)
self.data = [PathwayData(os.path.join("KEGG", "ko01100.xml"),
tempfile.gettempprefix() + ".ko01100.kgml",
(3628, 1726, 1746, 149),
os.path.join("KEGG", "map01100.png")),
PathwayData(os.path.join("KEGG", "ko03070.xml"),
tempfile.gettempprefix() + ".ko03070.kgml",
(81, 72, 8, 1),
os.path.join("KEGG", "map03070.png"),
True)]
# A list of KO IDs that we're going to use to modify pathway
# appearance. These are KO IDs for reactions that take part in ko00020,
# the TCA cycle
self.ko_ids = \
set(['ko:K00239', 'ko:K00240', 'ko:K00241', 'ko:K00242', 'ko:K00244',
'ko:K00245', 'ko:K00246', 'ko:K00247', 'ko:K00174', 'ko:K00175',
'ko:K00177', 'ko:K00176', 'ko:K00382', 'ko:K00164', 'ko:K00164',
'ko:K00658', 'ko:K01902', 'ko:K01903', 'ko:K01899', 'ko:K01900',
'ko:K01899', 'ko:K01900', 'ko:K00031', 'ko:K00030', 'ko:K00031',
'ko:K01648', 'ko:K00234', 'ko:K00235', 'ko:K00236', 'ko:K00237',
'ko:K01676', 'ko:K01677', 'ko:K01678', 'ko:K01679', 'ko:K01681',
'ko:K01682', 'ko:K01681', 'ko:K01682', 'ko:K01647', 'ko:K00025',
'ko:K00026', 'ko:K00024', 'ko:K01958', 'ko:K01959', 'ko:K01960',
'ko:K00163', 'ko:K00161', 'ko:K00162', 'ko:K00163', 'ko:K00161',
'ko:K00162', 'ko:K00382', 'ko:K00627', 'ko:K00169', 'ko:K00170',
'ko:K00172', 'ko:K00171', 'ko:K01643', 'ko:K01644', 'ko:K01646',
'ko:K01610', 'ko:K01596'])
开发者ID:HuttonICS,项目名称:biopython,代码行数:34,代码来源:test_KGML_nographics.py
示例3: empty_temp_dir
def empty_temp_dir():
""" Create a sub directory in the temp directory for use in tests
"""
import tempfile
d = catalog.default_dir()
for i in range(10000):
new_d = os.path.join(d,tempfile.gettempprefix()[1:-1]+`i`)
if not os.path.exists(new_d):
os.mkdir(new_d)
break
return new_d
开发者ID:151706061,项目名称:Slicer,代码行数:11,代码来源:weave_test_utils.py
示例4: ontimer
def ontimer(self):
if not self.afterOpened:
return
while 1:
eventType,data = self.camera.waitForEvent(timeout=0)
if eventType == constants.GPEvent.TIMEOUT:
return
if self.hasCaptureEvents is None:
if (eventType == constants.GPEvent.UNKNOWN and data.startswith('PTP Property')) or eventType == constants.GPEvent.FILE_ADDED or eventType == constants.GPEvent.CAPTURE_COMPLETE:
### TEMP: if we get any valid event we guess that the camera supports PTP end capture events -- not ideal!
self.hasCaptureEvents = True
if not eventType == constants.GPEvent.UNKNOWN and data.startswith('PTP Property'):
# log everything except timeouts and PTP property change events
log.debug('%s %r'%(EVENTTYPE_TO_NAME[eventType],data))
if eventType == constants.GPEvent.UNKNOWN and data.startswith('PTP Property'):
changed = self.configurationFromCamera()
if not changed:
continue
changedProperties = [self.getPropertyByName(widget['name']) for widget in changed]
event = interface.PropertiesChangedEvent(self,changedProperties)
self.propertiesChanged.emit(event)
elif eventType == constants.GPEvent.FILE_ADDED:
path,fn = data
tempFn = os.path.join(tempfile.gettempdir(),tempfile.gettempprefix()+fn)
self.camera.downloadFile(path,fn,tempFn)
self.capturedAuxFiles.append(tempFn)
elif eventType == constants.GPEvent.CAPTURE_COMPLETE:
e = interface.CaptureCompleteEvent(self,data=self.capturedData,auxFiles=self.capturedAuxFiles)
self.capturedAuxFiles = []
self.captureComplete.emit(e)
开发者ID:BackupGGCode,项目名称:scan-manager,代码行数:32,代码来源:wrapper.py
示例5: CreateTempFile
def CreateTempFile(FilePath):
TempPath = os.path.join(
tempfile.gettempdir(),
tempfile.gettempprefix() + "-" + os.path.basename(FilePath) + ".tmp"
)
TempFile = open(TempPath, 'w')
return TempFile
开发者ID:gartung,项目名称:larsoft,代码行数:7,代码来源:SerialSubstitution.py
示例6: gen_args
def gen_args ( args, infile_path, outfile ) :
"""
Return the argument list generated from 'args' and the infile path
requested.
Arguments :
args ( string )
Keyword or arguments to use in the call of Consense, excluding
infile and outfile arguments.
infile_path ( string )
Input alignment file path.
outfile ( string )
Consensus tree output file.
Returns :
list
List of arguments (excluding binary file) to call Consense.
"""
if ( outfile ) :
outfile_path = get_abspath(outfile)
else :
# Output files will be saved in temporary files to retrieve the
# consensus tree
outfile_path = os.path.join(tempfile.gettempdir(),
tempfile.gettempprefix() + \
next(tempfile._get_candidate_names()))
# Create full command line list
argument_list = [infile_path, outfile_path]
return ( argument_list )
开发者ID:JAlvarezJarreta,项目名称:MEvoLib,代码行数:29,代码来源:_Consense.py
示例7: _update
def _update (self, lang, po_file_n, cmd, pot_file, pot_file_n) :
print ("Update catalog `%s` based on `%s`" % (po_file_n, pot_file_n))
po_file = TFL.Babel.PO_File.load (po_file_n, locale = lang)
po_file.update (pot_file, cmd.no_fuzzy)
tmpname = os.path.join\
( os.path.dirname (po_file_n)
, "%s%s.po" % (tempfile.gettempprefix (), lang)
)
try :
po_file.save \
( tmpname
, ignore_obsolete = cmd.ignore_obsolete
, include_previous = cmd.previous
, sort = cmd.sort
)
except :
os.remove (tmpname)
raise
try :
os.rename (tmpname, po_file_n)
except OSError:
# We're probably on Windows, which doesn't support atomic
# renames, at least not through Python
# If the error is in fact due to a permissions problem, that
# same error is going to be raised from one of the following
# operations
os.remove (po_file_n)
shutil.copy (tmpname, po_file_n)
os.remove (tmpname)
开发者ID:Tapyr,项目名称:tapyr,代码行数:29,代码来源:Babel.py
示例8: safe_write_po
def safe_write_po(self, catalog, filepath, **kwargs):
"""
Safely write a PO file
This means that the PO file is firstly created in a temporary file, so
if it fails it does not overwrite the previous one, if success the
temporary file is moved over the previous one.
Some part of code have been stealed from babel.messages.frontend
"""
tmpname = os.path.join(os.path.dirname(filepath), tempfile.gettempprefix() + os.path.basename(filepath))
tmpfile = open(tmpname, 'w')
try:
try:
write_po(tmpfile, catalog, **kwargs)
finally:
tmpfile.close()
except:
os.remove(tmpname)
raise
try:
os.rename(tmpname, filepath)
except OSError:
# We're probably on Windows, which doesn't support atomic
# renames, at least not through Python
# If the error is in fact due to a permissions problem, that
# same error is going to be raised from one of the following
# operations
os.remove(filepath)
shutil.copy(tmpname, filepath)
os.remove(tmpname)
开发者ID:Meodudlye,项目名称:Optimus,代码行数:32,代码来源:i18n.py
示例9: transform_command_with_value
def transform_command_with_value(command, value, notification_timestamp):
python_download_script = 'zk_download_data.py'
if len(value) > _LONG_VALUE_THRESHOLD:
# If the value is too long (serverset is too large), OSError may be thrown.
# Instead of passing it in command line, write to a temp file and
# let zk_download_data read from it.
value = value.replace("\n", "").replace("\r", "")
md5digest = zk_util.get_md5_digest(value)
tmp_filename = 'zk_update_largefile_' + md5digest + '_' + str(notification_timestamp)
tmp_dir = tempfile.gettempprefix()
tmp_filepath = os.path.join('/', tmp_dir, tmp_filename)
log.info("This is a long value, write it to temp file %s", tmp_filepath)
try:
with open(tmp_filepath, 'w') as f:
f.write(value + '\n' + md5digest)
except Exception as e:
log.exception(
"%s: Failed to generate temp file %s for storing large size values"
% (e.message, tmp_filepath))
return (None, None)
finally:
f.close()
transformed_command = command.replace(
python_download_script, "%s -l %s" % (
python_download_script, tmp_filepath))
return transformed_command, tmp_filepath
else:
transformed_command = command.replace(
python_download_script, "%s -v '%s'" % (
python_download_script, value))
return transformed_command, None
开发者ID:lilida,项目名称:kingpin,代码行数:33,代码来源:zk_update_monitor.py
示例10: get_path_for_file
def get_path_for_file(self, filename):
"""
given the filename, get the path for the temporary file
"""
prefix = tempfile.gettempprefix()
tempdir = tempfile.gettempdir()
return '%s/%s%s'% (tempdir, prefix, filename)
开发者ID:zvoase,项目名称:formish,代码行数:7,代码来源:filehandler.py
示例11: draw_image
def draw_image(self, x, y, im, bbox):
filename = os.path.join (tempfile.gettempdir(),
tempfile.gettempprefix() + '.png'
)
verbose.report ('Writing image file for include: %s' % filename)
# im.write_png() accepts a filename, not file object, would be
# good to avoid using files and write to mem with StringIO
# JDH: it *would* be good, but I don't know how to do this
# since libpng seems to want a FILE* and StringIO doesn't seem
# to provide one. I suspect there is a way, but I don't know
# it
im.flipud_out()
h,w = im.get_size_out()
y = self.height-y-h
im.write_png(filename)
imfile = file (filename, 'r')
image64 = base64.b64encode (imfile.read())
imfile.close()
os.remove(filename)
lines = [image64[i:i+76] for i in range(0, len(image64), 76)]
self._svgwriter.write (
'<image x="%f" y="%f" width="%f" height="%f" '
'xlink:href="data:image/png;base64,\n%s" />\n'
% (x, y, w+1, h+1, '\n'.join(lines))
)
# unflip
im.flipud_out()
开发者ID:pv,项目名称:matplotlib-cvs,代码行数:34,代码来源:backend_svg.py
示例12: delete_file
def delete_file(self, filename):
"""
remove the tempfile
"""
prefix = tempfile.gettempprefix()
tempdir = tempfile.gettempdir()
filename = '%s/%s%s'% (tempdir, prefix, filename)
os.remove(filename)
开发者ID:zvoase,项目名称:formish,代码行数:8,代码来源:filehandler.py
示例13: __init__
def __init__(self, vim):
self.vim = vim
self.pvs_command = "pvs-studio-analyzer analyze"
self.ans_cmmmand = "plog-converter -a %s -t errorfile PVS-Studio.log"
self.tidy_command = 'clang-tidy -format-style=file -p {} -checks={} {}'
self.oclint_command = 'oclint -p {} {}'
self.tempFile = join(tempfile.gettempdir(), tempfile.gettempprefix() + "_analysis")
self.buildDir = ''
开发者ID:wow2006,项目名称:My-Vim-Config,代码行数:8,代码来源:analysis_neovim.py
示例14: get_tempfile_path
def get_tempfile_path () :
"""
Returns :
string
Path of a new temporary file name (without creating it).
"""
return ( os.path.join(tempfile.gettempdir(), tempfile.gettempprefix() +\
next(tempfile._get_candidate_names())) )
开发者ID:JAlvarezJarreta,项目名称:MEvoLib,代码行数:8,代码来源:_utils.py
示例15: _setup_scratch_area
def _setup_scratch_area(self):
self.scratch_dir = "%s/%sipkg" % (tempfile.gettempdir(),
tempfile.gettempprefix())
self.file_dir = "%s/files" % (self.scratch_dir)
self.meta_dir = "%s/meta" % (self.scratch_dir)
os.mkdir(self.scratch_dir)
os.mkdir(self.file_dir)
os.mkdir(self.meta_dir)
开发者ID:alfmep,项目名称:Utumno-distribution,代码行数:9,代码来源:ipkg.py
示例16: test_name
def test_name(self):
f = TextTempFile()
self.assertIsInstance(f.name, unicode, "file name not unicode string")
name_prefix = os.path.join(tempfile.gettempdir(),
tempfile.gettempprefix())
self.assertTrue(f.name.startswith(name_prefix),
"file name does not start with '{}'".format(name_prefix))
with self.assertRaises(AttributeError):
f.name = "new_name"
开发者ID:alex-marty,项目名称:utils,代码行数:9,代码来源:test_texttempfile.py
示例17: draw_image
def draw_image(self, x, y, im, bbox):
trans = [1,0,0,1,0,0]
transstr = ''
if rcParams['svg.image_noscale']:
trans = list(im.get_matrix())
if im.get_interpolation() != 0:
trans[4] += trans[0]
trans[5] += trans[3]
trans[5] = -trans[5]
transstr = 'transform="matrix(%s %s %s %s %s %s)" '%tuple(trans)
assert trans[1] == 0
assert trans[2] == 0
numrows,numcols = im.get_size()
im.reset_matrix()
im.set_interpolation(0)
im.resize(numcols, numrows)
h,w = im.get_size_out()
if rcParams['svg.image_inline']:
filename = os.path.join (tempfile.gettempdir(),
tempfile.gettempprefix() + '.png'
)
verbose.report ('Writing temporary image file for inlining: %s' % filename)
# im.write_png() accepts a filename, not file object, would be
# good to avoid using files and write to mem with StringIO
# JDH: it *would* be good, but I don't know how to do this
# since libpng seems to want a FILE* and StringIO doesn't seem
# to provide one. I suspect there is a way, but I don't know
# it
im.flipud_out()
im.write_png(filename)
im.flipud_out()
imfile = file (filename, 'rb')
image64 = base64.encodestring (imfile.read())
imfile.close()
os.remove(filename)
hrefstr = 'data:image/png;base64,\n' + image64
else:
self._imaged[self.basename] = self._imaged.get(self.basename,0) + 1
filename = '%s.image%d.png'%(self.basename, self._imaged[self.basename])
verbose.report( 'Writing image file for inclusion: %s' % filename)
im.flipud_out()
im.write_png(filename)
im.flipud_out()
hrefstr = filename
self._svgwriter.write (
'<image x="%s" y="%s" width="%s" height="%s" '
'xlink:href="%s" %s/>\n'%(x/trans[0], (self.height-y)/trans[3]-h, w, h, hrefstr, transstr)
)
开发者ID:gkliska,项目名称:razvoj,代码行数:56,代码来源:backend_svg.py
示例18: cleanup_temporary_files
def cleanup_temporary_files(self):
"""
cleanup_temporary_files will remove all the files created by the show
method.
"""
temp_dir = tempfile.gettempdir()
file_list = os.listdir(temp_dir)
file_names = filter(lambda s: s.startswith(tempfile.gettempprefix()),
file_list)
map(lambda fn: os.remove(os.path.join(temp_dir, fn)), file_names)
开发者ID:BennettRand,项目名称:Solar-Circuit,代码行数:10,代码来源:chart.py
示例19: get_mimetype
def get_mimetype(self, filename):
"""
use python-magic to guess the mimetype or use application/octet-stream
if no guess
"""
prefix = tempfile.gettempprefix()
tempdir = tempfile.gettempdir()
mimetype = magic.from_file('%s/%s%s'% \
(tempdir,prefix,filename),mime=True)
return mimetype or 'application/octet-stream'
开发者ID:zvoase,项目名称:formish,代码行数:10,代码来源:filehandler.py
示例20: gettempprefix
def gettempprefix():
"""
Returns:
`fsnative`
Like :func:`python3:tempfile.gettempprefix`, but always returns a
`fsnative` path
"""
return path2fsn(tempfile.gettempprefix())
开发者ID:2216288075,项目名称:meiduo_project,代码行数:10,代码来源:_temp.py
注:本文中的tempfile.gettempprefix函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论