• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tempfile.tempfile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tempfile.tempfile函数的典型用法代码示例。如果您正苦于以下问题:Python tempfile函数的具体用法?Python tempfile怎么用?Python tempfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_clear_files

    def test_clear_files(self):
        self.marionette.navigate(multiple)
        input = self.input

        with contextlib.nested(tempfile(), tempfile()) as (a, b):
            input.send_keys(a.name)
            input.send_keys(b.name)

        self.assertEqual(len(self.get_files(input)), 2)
        input.clear()
        self.assertEqual(len(self.get_files(input)), 0)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:11,代码来源:test_file_upload.py


示例2: test_sets_multiple_files

    def test_sets_multiple_files(self):
        self.marionette.navigate(multiple)
        input = self.input

        exp = None
        with contextlib.nested(tempfile(), tempfile()) as (a, b):
            input.send_keys(a.name)
            input.send_keys(b.name)
            exp = [a.name, b.name]

        files = self.get_file_names(input)
        self.assertEqual(len(files), 2)
        self.assertFileNamesEqual(files, exp)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:13,代码来源:test_file_upload.py


示例3: apply_command

    def apply_command(self, command):
        """Apply a starlab command to this story and return the result.

        Uses the current story as input to the given command.
        :param command: The starlab command to run
        :type command: a string as it would appear on the command line
                       or a list suitable for subprocess.Popen()

        :returns: the output of command
        :rtype: Story instance
        """
        if isinstance(command, str):
            command = command.split(" ")
        elif isinstance(command, list):
            pass
        else:
            raise TypeError('command should be a string or list')

        story_lines = []
        with tempfile() as f:
            f.write(str(self).encode())
            f.seek(0)
            with Popen(command, stdout=PIPE, stdin=f,
                        universal_newlines=True, bufsize=1) as process:
                for line in process.stdout:
                    story_lines.append(line.rstrip())

        thestory = self.from_buf(story_lines)

        # if the command was an integration, we'll get a list
        if isinstance(thestory, list):
            # include the initial conditions
            thestory.insert(0, self)
        return thestory
开发者ID:tachycline,项目名称:pystarlab,代码行数:34,代码来源:starlab.py


示例4: get_suggestion_native_modules

    def get_suggestion_native_modules(self):
        NODE_MODULES_LIST = os.path.join(pkg_path,'node_modules.list')
        try:
            if os.path.exists(NODE_MODULES_LIST) :
                source = open(NODE_MODULES_LIST)
                results= json.loads(source.read())
                source.close()
            else :
                # load native node modules from node
                f = tempfile()
                f.write('console.log(Object.keys(process.binding("natives")))')
                f.seek(0)
                jsresult = (Popen(['node'], stdout=PIPE, stdin=f)).stdout.read().replace("'", '"')
                f.close()
                # write list to list file
                results = json.loads(jsresult)
                source = open(NODE_MODULES_LIST,'w')
                source.write(jsresult)
                source.close()

            result = [[(lambda ni=ni: [ni, ni]) for ni in results],
                    ["native: " + ni for ni in results]]
            return result
        
        except Exception:
           return [[], []]
开发者ID:pianist829,项目名称:sublime-node-require,代码行数:26,代码来源:require_node.py


示例5: test_clear_file

    def test_clear_file(self):
        self.marionette.navigate(single)
        input = self.input

        with tempfile() as f:
            input.send_keys(f.name)

        self.assertEqual(len(self.get_files(input)), 1)
        input.clear()
        self.assertEqual(len(self.get_files(input)), 0)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:10,代码来源:test_file_upload.py


示例6: test_sets_one_file

    def test_sets_one_file(self):
        self.marionette.navigate(single)
        input = self.input

        exp = None
        with tempfile() as f:
            input.send_keys(f.name)
            exp = [f.name]

        files = self.get_file_names(input)
        self.assertEqual(len(files), 1)
        self.assertFileNamesEqual(files, exp)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:12,代码来源:test_file_upload.py


示例7: htmlvalidator

def htmlvalidator(page):
    document, errors = tidy_document(page,
        options={'numeric-entities':1})
    f = tempfile()
    for line in errors.splitlines():
        if _is_html_error(line):
            print("################")
            print("Blocking error: '%s'" % line)
            print("all tidy_document errors:")
            print(errors)
            print("################")
            raise HtmlValidationFailed(line)
开发者ID:kakwa,项目名称:ldapcherry,代码行数:12,代码来源:test_LdapCherry.py


示例8: test_upload

    def test_upload(self):
        self.marionette.navigate(upload(self.marionette.absolute_url("file_upload")))
        url = self.marionette.get_url()

        with tempfile() as f:
            f.write("camembert")
            f.flush()
            self.input.send_keys(f.name)
            self.submit.click()

        Wait(self.marionette).until(lambda m: m.get_url() != url)
        self.assertIn("multipart/form-data", self.body.text)
开发者ID:emilio,项目名称:gecko-dev,代码行数:12,代码来源:test_file_upload.py


示例9: test_sets_multiple_indentical_files

    def test_sets_multiple_indentical_files(self):
        self.marionette.navigate(multiple)
        input = self.input

        exp = []
        with tempfile() as f:
            input.send_keys(f.name)
            input.send_keys(f.name)
            exp = f.name

        files = self.get_file_names(input)
        self.assertEqual(len(files), 2)
        self.assertFileNamesEqual(files, exp)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:13,代码来源:test_file_upload.py


示例10: get_suggestion_native_modules

    def get_suggestion_native_modules(self):
        try:
            f = tempfile()
            f.write('console.log(Object.keys(process.binding("natives")))')
            f.seek(0)
            jsresult = (Popen(['node'], stdout=PIPE, stdin=f, shell=True)).stdout.read().replace("'", '"')
            f.close()

            results = json.loads(jsresult)

            result = [[(lambda ni=ni: [ni, ni]) for ni in results],
                    ["native: " + ni for ni in results]]
            return result
        except Exception:
            return [[], []]
开发者ID:bennage,项目名称:sublime-node-require,代码行数:15,代码来源:require_node.py


示例11: test_change_event

    def test_change_event(self):
        self.marionette.navigate(single)
        self.marionette.execute_script("""
            window.changeEvs = [];
            let el = arguments[arguments.length - 1];
            el.addEventListener("change", ev => window.changeEvs.push(ev));
            console.log(window.changeEvs.length);
            """, script_args=(self.input,), sandbox=None)

        with tempfile() as f:
            self.input.send_keys(f.name)

        nevs = self.marionette.execute_script(
            "return window.changeEvs.length", sandbox=None)
        self.assertEqual(1, nevs)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:15,代码来源:test_file_upload.py


示例12: test_upload

    def test_upload(self):
        self.marionette.navigate(
            upload(self.marionette.absolute_url("file_upload")))
        url = self.marionette.get_url()

        with tempfile() as f:
            f.write("camembert")
            f.flush()
            self.input.send_keys(f.name)
            self.submit.click()

        Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
            lambda m: m.get_url() != url,
            message="URL didn't change after submitting a file upload")
        self.assertIn("multipart/form-data", self.body.text)
开发者ID:luke-chang,项目名称:gecko-1,代码行数:15,代码来源:test_file_upload.py


示例13: create_cf_databases

def create_cf_databases(stack):
	databases = [
		'uaa',
		'ccdb',
		'console',
		'notifications',
		'autoscale',
		'app_usage_service'
	]
	try:
		sql = tempfile()
		for database in databases:
			sql.write('create database if not exists ' + database + ';\n')
		sql.seek(0)
		command = [
			'mysql',
			'--host=' + output(stack, "PcfRdsAddress"),
			'--user=' + output(stack, "PcfRdsUsername"),
			'--password=' + output(stack, "PcfRdsPassword")
		]
		opsmgr.opsmgr_exec(stack, command, stdin=sql)
	finally:
		sql.close()
开发者ID:guidowb,项目名称:rebel,代码行数:23,代码来源:cf.py


示例14: __init__

	def __init__(self, panel):
		self.panel = panel
		self.tempfile = tempfile()
		self.fileno = self.tempfile.fileno
开发者ID:xjunior,项目名称:PryDebugger,代码行数:4,代码来源:PryDebugger.py


示例15: tempfile

#!/usr/bin/env python
# -*- coding:utf-8 -*-

import os


from subprocess import Popen, PIPE
from tempfile import SpooledTemporaryFile as tempfile
f = tempfile()
f.write('one\ntwo\nthree\nfour\nfive\nsix\n')
f.seek(0)
print Popen(['/bin/grep','five'],stdout=PIPE,stdin=f).stdout.read()
f.close()

开发者ID:XuChongBo,项目名称:pydemo,代码行数:13,代码来源:pipe_tempfile.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tempfile.NamedTemporaryFile类代码示例发布时间:2022-05-27
下一篇:
Python tempfile.should_receive函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap