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


Python os.tempnam方法代码示例

本文整理汇总了Python中os.tempnam方法的典型用法代码示例。如果您正苦于以下问题:Python os.tempnam方法的具体用法?Python os.tempnam怎么用?Python os.tempnam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os的用法示例。


在下文中一共展示了os.tempnam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plist_save

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def plist_save(filename, data, binary = False):
	import plistlib
	if not binary:
		plistlib.writePlist(data, filename)
		return 0
	import warnings
	warnings.filterwarnings("ignore")
	tmpname = os.tempnam(None, 'plist.')
	plistlib.writePlist(data, tmpname)
	plutil('-convert', 'binary1', '-o', filename, tmpname)
	os.remove(tmpname)
	return 0


#----------------------------------------------------------------------
# testing case
#---------------------------------------------------------------------- 
开发者ID:skywind3000,项目名称:collection,代码行数:19,代码来源:shell.py

示例2: singular

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def singular(cmd, isAll=False, debug=False):
  assert check("Singular")
  if isinstance(cmd, str):
    cmd = [cmd]
  s = ";\n".join(cmd) + ";"
  if debug:
    print("[+] Throughout to Singular Commands: {!r}".format(cmd))
  tmpname = os.tempnam()
  open(tmpname, "w").write(s)
  p = Popen(["Singular", "-bq", tmpname], stdin=PIPE, stdout=PIPE)
  d, _ = p.communicate()
  os.remove(tmpname)
  if isAll:
    return d.split("\n")[:-1]
  else:
    return d.split("\n")[:-1][-1] 
开发者ID:scryptos,项目名称:scryptoslib,代码行数:18,代码来源:singular.py

示例3: _get_preview_filename

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def _get_preview_filename(self):
        import warnings
        warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, "application")
        if compat.PYTHON2:
            out_name = os.tempnam(None, 'wxg') + '.py'
        else:
            # create a temporary file at either the output path or the project path
            error = None
            if not self.filename:
                error = "Save project first; a temporary file will be created in the same directory."
            else:
                dirname, basename = os.path.split(self.filename)
                basename, extension = os.path.splitext(basename)
                if not os.path.exists(dirname):
                    error = "Directory '%s' not found"%dirname
                elif not os.path.isdir(dirname):
                    error = "'%s' is not a directory"%dirname
            if error:
                misc.error_message(error)
                return None
            while True:
                out_name = os.path.join(dirname, "_%s_%d.py"%(basename,random.randrange(10**8, 10**9)))
                if not os.path.exists(out_name): break
        return out_name 
开发者ID:wxGlade,项目名称:wxGlade,代码行数:26,代码来源:application.py

示例4: get_consensus_through_pbdagcon

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def get_consensus_through_pbdagcon(seq1, weight1, seq2, weight2):
    fname = os.tempnam("/tmp") + '.fasta'
    with open(fname, 'w') as f:
        for i in range(min(10, weight1)): # max cutoff at 10
            f.write(">test1_{0}\n{1}\n".format(i, seq1))
        for i in range(min(10, weight2)): # max cutoff at 10
            f.write(">test2_{0}\n{1}\n".format(i, seq2))

    cmd = "ice_pbdagcon.py --maxScore 10 {0} {0}.g_con g_con".format(fname)
    if subprocess.check_call(cmd, shell=True) == -1:
        raise Exception("Trouble running cmd: ").with_traceback(cmd)

    gcon_filename = fname + '.g_con.fasta'
    gref_filename = fname + '.g_con_ref.fasta'
    if os.path.exists(gcon_filename) and os.stat(gcon_filename).st_size > 0:
        return str(SeqIO.parse(open(gcon_filename), 'fasta').next().seq)
    elif os.path.exists(gref_filename):
        return str(SeqIO.parse(open(gref_filename), 'fasta').next().seq)
    else:
        raise Exception("Could not get results from running cmd:").with_traceback(cmd) 
开发者ID:Magdoll,项目名称:Cogent,代码行数:22,代码来源:splice_align.py

示例5: tempnam_no_warning

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def tempnam_no_warning(*args):
    """
    An os.tempnam with the warning turned off, because sometimes
    you just need to use this and don't care about the stupid
    security warning.
    """
    return os.tempnam(*args) 
开发者ID:linuxscout,项目名称:mishkal,代码行数:9,代码来源:fixture.py

示例6: test_tempnam

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def test_tempnam(self):
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", "tempnam", RuntimeWarning,
                                    r"test_os$")
            warnings.filterwarnings("ignore", "tempnam", DeprecationWarning)
            self.check_tempfile(os.tempnam())

            name = os.tempnam(test_support.TESTFN)
            self.check_tempfile(name)

            name = os.tempnam(test_support.TESTFN, "pfx")
            self.assertTrue(os.path.basename(name)[:3] == "pfx")
            self.check_tempfile(name) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_os.py

示例7: test_load_negative

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def test_load_negative(self):
        if cPickle.__name__ == "cPickle":   # pickle vs. cPickle report different exceptions, even on Cpy
            filename = os.tempnam()
            for temp in ['\x02', "No"]:
                self.write_to_file(filename, content=temp)
                f = open(filename)
                self.assertRaises(cPickle.UnpicklingError, cPickle.load, f)
                f.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_cPickle.py

示例8: get_temp_file

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def get_temp_file(keep=False, autoext=""):
    f = os.tempnam("","scapy")
    if not keep:
        conf.temp_files.append(f+autoext)
    return f 
开发者ID:medbenali,项目名称:CyberScan,代码行数:7,代码来源:utils.py

示例9: test_tempnam

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def test_tempnam(self):
        if not hasattr(os, "tempnam"):
            return
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", "tempnam", RuntimeWarning,
                                    r"test_os$")
            warnings.filterwarnings("ignore", "tempnam", DeprecationWarning)
            self.check_tempfile(os.tempnam())

            name = os.tempnam(test_support.TESTFN)
            self.check_tempfile(name)

            name = os.tempnam(test_support.TESTFN, "pfx")
            self.assertTrue(os.path.basename(name)[:3] == "pfx")
            self.check_tempfile(name) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:17,代码来源:test_os.py

示例10: test_tempnam

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [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

示例11: test_load_negative

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def test_load_negative(self):
        if cPickle.__name__ == "_pickle":   # pickle vs. cPickle report different exceptions, even on Cpy
            filename = os.tempnam()
            for temp in ['\x02', "No"]:
                self.write_to_file(filename, content=temp)
                f = open(filename)
                self.assertRaises(cPickle.UnpicklingError, cPickle.load, f)
                f.close() 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:10,代码来源:test_cPickle.py

示例12: plist_load

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def plist_load(filename):
	import plistlib
	fp = open(filename, 'rb')
	content = fp.read(8)
	fp.close()
	if content == 'bplist00':
		import warnings
		warnings.filterwarnings("ignore")
		tmpname = os.tempnam(None, 'plist.')
		plutil('-convert', 'xml1', '-o', tmpname, filename)
		data = plistlib.readPlist(tmpname)
		os.remove(tmpname)
		return data
	data = plistlib.readPlist(filename)
	return data 
开发者ID:skywind3000,项目名称:collection,代码行数:17,代码来源:shell.py

示例13: setUp

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def setUp(self):
        super(LdbTestCase, self).setUp()
        self.filename = os.tempnam()
        self.ldb = samba.Ldb(self.filename) 
开发者ID:byt3bl33d3r,项目名称:pth-toolkit,代码行数:6,代码来源:__init__.py

示例14: test_tempnam

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def test_tempnam(self):
        if not hasattr(os, "tempnam"):
            return
        warnings.filterwarnings("ignore", "tempnam", RuntimeWarning,
                                r"test_os$")
        self.check_tempfile(os.tempnam())

        name = os.tempnam(test_support.TESTFN)
        self.check_tempfile(name)

        name = os.tempnam(test_support.TESTFN, "pfx")
        self.assert_(os.path.basename(name)[:3] == "pfx")
        self.check_tempfile(name) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:15,代码来源:test_os.py

示例15: format_string

# 需要导入模块: import os [as 别名]
# 或者: from os import tempnam [as 别名]
def format_string(fp, str):
    str = re.sub("<<([^>]+)>>", "See also pychart.\\1", str)

    str2 = ""
    in_example = 0
    for l in str.split("\n"):
        if re.match("@example", l):
            in_example = 1
        if re.match("@end example", l):
            in_example = 0
        if in_example:
            str2 += l
        else:
            l = re.sub("^[ \t]*", "", l)
            str2 += l
        str2 += "\n"
    fname = os.tempnam()
    out_fp = open(fname, "w")
    out_fp.write(str2)
    out_fp.close()

    in_fp = os.popen("makeinfo --fill-column=64 --no-headers " + fname, "r")
    for l in in_fp.readlines():
        fp.write(" " * indent)
        fp.write(l)
    in_fp.close()
    os.remove(fname) 
开发者ID:Scemoon,项目名称:lpts,代码行数:29,代码来源:generate_docs.py


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