本文整理汇总了Python中os.tmpnam方法的典型用法代码示例。如果您正苦于以下问题:Python os.tmpnam方法的具体用法?Python os.tmpnam怎么用?Python os.tmpnam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os
的用法示例。
在下文中一共展示了os.tmpnam方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_for_traj
# 需要导入模块: import os [as 别名]
# 或者: from os import tmpnam [as 别名]
def send_for_traj(mod=None, modfunc=None, filename_arg='filename', **kwargs):
if modfunc is None:
raise ValueError('modfunc must be passed!')
if filename_arg not in kwargs:
kwargs[filename_arg] = os.tmpnam()
if mod is None:
modfunc(**kwargs) # this could raise an exception
else:
modfunc(mod, **kwargs) # this could raise an exception
traj_string = open(kwargs[filename_arg],'r').read()
if mod is None:
if hasattr(modfunc,'__self__'):
e = modfunc.__self__.GetEnv()
else:
e = modfunc.im_self.GetEnv() # for pre-Python2.6
else:
e = mod.GetEnv()
return openravepy.RaveCreateTrajectory(e,'').deserialize(traj_string)
# Set the transparency of a robot
示例2: test_tmpnam
# 需要导入模块: import os [as 别名]
# 或者: from os import tmpnam [as 别名]
def test_tmpnam(self):
with warnings.catch_warnings():
warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
r"test_os$")
warnings.filterwarnings("ignore", "tmpnam", DeprecationWarning)
name = os.tmpnam()
if sys.platform in ("win32",):
# The Windows tmpnam() seems useless. From the MS docs:
#
# The character string that tmpnam creates consists of
# the path prefix, defined by the entry P_tmpdir in the
# file STDIO.H, followed by a sequence consisting of the
# digit characters '0' through '9'; the numerical value
# of this string is in the range 1 - 65,535. Changing the
# definitions of L_tmpnam or P_tmpdir in STDIO.H does not
# change the operation of tmpnam.
#
# The really bizarre part is that, at least under MSVC6,
# P_tmpdir is "\\". That is, the path returned refers to
# the root of the current drive. That's a terrible place to
# put temp files, and, depending on privileges, the user
# may not even be able to open a file in the root directory.
self.assertFalse(os.path.exists(name),
"file already exists for temporary file")
else:
self.check_tempfile(name)
# Test attributes on return values from os.*stat* family.
示例3: test_tmpnam
# 需要导入模块: import os [as 别名]
# 或者: from os import tmpnam [as 别名]
def test_tmpnam(self):
if not hasattr(os, "tmpnam"):
return
with warnings.catch_warnings():
warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
r"test_os$")
warnings.filterwarnings("ignore", "tmpnam", DeprecationWarning)
name = os.tmpnam()
if sys.platform in ("win32",):
# The Windows tmpnam() seems useless. From the MS docs:
#
# The character string that tmpnam creates consists of
# the path prefix, defined by the entry P_tmpdir in the
# file STDIO.H, followed by a sequence consisting of the
# digit characters '0' through '9'; the numerical value
# of this string is in the range 1 - 65,535. Changing the
# definitions of L_tmpnam or P_tmpdir in STDIO.H does not
# change the operation of tmpnam.
#
# The really bizarre part is that, at least under MSVC6,
# P_tmpdir is "\\". That is, the path returned refers to
# the root of the current drive. That's a terrible place to
# put temp files, and, depending on privileges, the user
# may not even be able to open a file in the root directory.
self.assertFalse(os.path.exists(name),
"file already exists for temporary file")
else:
self.check_tempfile(name)
# Test attributes on return values from os.*stat* family.
示例4: test_tempnam
# 需要导入模块: import os [as 别名]
# 或者: from os import tmpnam [as 别名]
def test_tempnam(self):
'''Test for `os.tempnam` / `os.tmpnam`.'''
expect = {
'SEVERITY': {'UNDEFINED': 0, 'LOW': 0, 'MEDIUM': 6, 'HIGH': 0},
'CONFIDENCE': {'UNDEFINED': 0, 'LOW': 0, 'MEDIUM': 0, 'HIGH': 6}
}
self.check_example('tempnam.py', expect)
示例5: __init__
# 需要导入模块: import os [as 别名]
# 或者: from os import tmpnam [as 别名]
def __init__(self, args):
try:
self.device = str(args['device']).replace("'''", "")
if len(self.device) < 1:
self.device = pcap.getDefaultName()
except:
self.device = pcap.getDefaultName()
self.filter = str(args['filter']).replace("'''", "")
self.data = None
self.tempFile = os.tmpnam()
self.thread = None
示例6: test_tmpnam
# 需要导入模块: import os [as 别名]
# 或者: from os import tmpnam [as 别名]
def test_tmpnam(self):
import sys
if not hasattr(os, "tmpnam"):
return
warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
r"test_os$")
name = os.tmpnam()
if sys.platform in ("win32",):
# The Windows tmpnam() seems useless. From the MS docs:
#
# The character string that tmpnam creates consists of
# the path prefix, defined by the entry P_tmpdir in the
# file STDIO.H, followed by a sequence consisting of the
# digit characters '0' through '9'; the numerical value
# of this string is in the range 1 - 65,535. Changing the
# definitions of L_tmpnam or P_tmpdir in STDIO.H does not
# change the operation of tmpnam.
#
# The really bizarre part is that, at least under MSVC6,
# P_tmpdir is "\\". That is, the path returned refers to
# the root of the current drive. That's a terrible place to
# put temp files, and, depending on privileges, the user
# may not even be able to open a file in the root directory.
self.failIf(os.path.exists(name),
"file already exists for temporary file")
else:
self.check_tempfile(name)
# Test attributes on return values from os.*stat* family.
示例7: test_bad_os_usage
# 需要导入模块: import os [as 别名]
# 或者: from os import tmpnam [as 别名]
def test_bad_os_usage(self):
python_node = self.get_ast_node(
"""
import os
var = 'echo "TEST"'
os.popen('ls')
os.popen2('ls')
os.popen3('ls')
os.popen4('ls')
os.system(var)
os.tempnam()
os.tmpnam()
"""
)
linter = dlint.linters.BadOSUseLinter()
linter.visit(python_node)
result = linter.get_results()
expected = [
dlint.linters.base.Flake8Result(
lineno=6,
col_offset=0,
message=dlint.linters.BadOSUseLinter._error_tmpl
),
dlint.linters.base.Flake8Result(
lineno=7,
col_offset=0,
message=dlint.linters.BadOSUseLinter._error_tmpl
),
dlint.linters.base.Flake8Result(
lineno=8,
col_offset=0,
message=dlint.linters.BadOSUseLinter._error_tmpl
),
dlint.linters.base.Flake8Result(
lineno=9,
col_offset=0,
message=dlint.linters.BadOSUseLinter._error_tmpl
),
dlint.linters.base.Flake8Result(
lineno=10,
col_offset=0,
message=dlint.linters.BadOSUseLinter._error_tmpl
),
dlint.linters.base.Flake8Result(
lineno=11,
col_offset=0,
message=dlint.linters.BadOSUseLinter._error_tmpl
),
dlint.linters.base.Flake8Result(
lineno=12,
col_offset=0,
message=dlint.linters.BadOSUseLinter._error_tmpl
),
]
assert result == expected