Python os.tmpnam() Examples
The following are 11
code examples of os.tmpnam().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: rave.py From prpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #2
Source File: test_os.py From ironpython2 with Apache License 2.0 | 5 votes |
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.
Example #3
Source File: test_os.py From BinderFilter with MIT License | 5 votes |
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.
Example #4
Source File: test_os.py From oss-ftp with MIT License | 5 votes |
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.
Example #5
Source File: test_functional.py From bandit with Apache License 2.0 | 5 votes |
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)
Example #6
Source File: network.py From peach with Mozilla Public License 2.0 | 5 votes |
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
Example #7
Source File: test_os.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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.
Example #8
Source File: test_os.py From medicare-demo with Apache License 2.0 | 5 votes |
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.
Example #9
Source File: test_os.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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.
Example #10
Source File: test_os.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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.
Example #11
Source File: test_bad_os_use.py From dlint with BSD 3-Clause "New" or "Revised" License | 4 votes |
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