当前位置: 首页>>代码示例>>Python>>正文


Python os.tmpnam方法代码示例

本文整理汇总了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 
开发者ID:personalrobotics,项目名称:prpy,代码行数:22,代码来源:rave.py

示例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. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:31,代码来源:test_os.py

示例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. 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:33,代码来源:test_os.py

示例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) 
开发者ID:PyCQA,项目名称:bandit,代码行数:9,代码来源:test_functional.py

示例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 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:13,代码来源:network.py

示例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. 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:31,代码来源:test_os.py

示例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 
开发者ID:duo-labs,项目名称:dlint,代码行数:62,代码来源:test_bad_os_use.py


注:本文中的os.tmpnam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。