當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。