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


Python os.mkfifo方法代码示例

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


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

示例1: start

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def start(self) -> None:
        self.current_frame = [0 for _ in range(self.bars)]
        self.growing_frame = b""
        try:
            # delete old contents of the pipe
            os.remove(self.cava_fifo_path)
        except FileNotFoundError:
            # the file does not exist
            pass
        try:
            os.mkfifo(self.cava_fifo_path)
        except FileExistsError:
            # the file already exists
            logging.info("%s already exists while starting", self.cava_fifo_path)

        self.cava_process = subprocess.Popen(
            ["cava", "-p", os.path.join(settings.BASE_DIR, "config/cava.config")],
            cwd=settings.BASE_DIR,
        )
        # cava_fifo = open(cava_fifo_path, 'r')
        self.cava_fifo = os.open(self.cava_fifo_path, os.O_RDONLY | os.O_NONBLOCK) 
开发者ID:raveberry,项目名称:raveberry,代码行数:23,代码来源:programs.py

示例2: prepare_run

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def prepare_run(self, *args, **kwargs):
        self._args = args
        self._kwargs = kwargs

        try:
            # tempfile.mktemp is deprecated and discouraged, but we use it here
            # to create a FIFO since the only other alternative would be to
            # create a directory and place the FIFO there, which sucks. Since
            # os.mkfifo will raise an exception anyways when the path doesn't
            # exist, it shouldn't be a big issue.
            self._filepath = tempfile.mktemp(prefix='qutebrowser-userscript-',
                                             dir=standarddir.runtime())
            # pylint: disable=no-member,useless-suppression
            os.mkfifo(self._filepath, mode=0o600)
            # pylint: enable=no-member,useless-suppression
        except OSError as e:
            self._filepath = None  # Make sure it's not used
            message.error("Error while creating FIFO: {}".format(e))
            return

        self._reader = _QtFIFOReader(self._filepath)
        self._reader.got_line.connect(self.got_cmd)  # type: ignore[arg-type] 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:24,代码来源:userscripts.py

示例3: test_smoke_one_file

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def test_smoke_one_file(self):
        db_path = "test.sqlite"
        runner = CliRunner()

        with runner.isolated_filesystem():
            fifo_name = "jsonl_fifo"

            os.mkfifo(fifo_name)

            with ProcessPoolExecutor() as executor:
                executor.submit(fifo_writer, fifo_name)
                result = runner.invoke(cmd, ["-o", db_path, "file", fifo_name, "--format", "jsonl"])

            print_traceback(result)

            assert result.exit_code == ExitCode.SUCCESS, fifo_name

            assert SimpleSQLite(db_path).fetch_num_records("jsonl_fifo") == 8 
开发者ID:thombashi,项目名称:sqlitebiter,代码行数:20,代码来源:test_file_subcommand_fifo.py

示例4: thr_inject_javascript

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def thr_inject_javascript(browser, pipe_file):
    '''
    This function reads from a pipe, a plain message interpreted as Javascript code.
    It then injects that code into the Webkit browser instance.
    From a bash script test it like this:

    $ echo "alert(\"Hello Kano\")" > /tmp/webapp.pipe

    TODO: collect and return synchronous error level? what about pipe security?
    '''
    if os.path.exists(pipe_file):
        os.unlink(pipe_file)

    os.mkfifo(pipe_file)
    while True:
        f = open(pipe_file, 'r')
        pipe_data = f.read().strip('\n')
        asynchronous_gtk_message(browser.execute_script)(pipe_data)
        f.close() 
开发者ID:KanoComputing,项目名称:kano-toolset,代码行数:21,代码来源:webapp.py

示例5: set_up_logging_file

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def set_up_logging_file():
    util.lazy_remove_file("log/out.log")
    os.mkfifo("log/out.log")
    log_ratelimit = os.getenv("LOG_RATELIMIT", None)
    if log_ratelimit is None:
        subprocess.Popen(
            [
                "sed",
                "--unbuffered",
                "s|^[0-9\-]\+\s[0-9:\.]\+\s||",
                "log/out.log",
            ]
        )
    else:
        log_filter_thread = LogFilterThread(log_ratelimit)
        log_filter_thread.daemon = True
        log_filter_thread.start() 
开发者ID:mendix,项目名称:cf-mendix-buildpack,代码行数:19,代码来源:logs.py

示例6: test_copytree_named_pipe

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def test_copytree_named_pipe(self):
        os.mkdir(TESTFN)
        try:
            subdir = os.path.join(TESTFN, "subdir")
            os.mkdir(subdir)
            pipe = os.path.join(subdir, "mypipe")
            os.mkfifo(pipe)
            try:
                shutil.copytree(TESTFN, TESTFN2)
            except shutil.Error as e:
                errors = e.args[0]
                self.assertEqual(len(errors), 1)
                src, dst, error_msg = errors[0]
                self.assertEqual("`%s` is a named pipe" % pipe, error_msg)
            else:
                self.fail("shutil.Error should have been raised")
        finally:
            shutil.rmtree(TESTFN, ignore_errors=True)
            shutil.rmtree(TESTFN2, ignore_errors=True) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:test_shutil.py

示例7: send_video_frame

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def send_video_frame(self, frame):
        """Send frame of shape (height, width, 3)
        with values between 0 and 1.
        Raises an OSError when the stream is closed.

        :param frame: array containing the frame.
        :type frame: numpy array with shape (height, width, 3)
            containing values between 0.0 and 1.0
        """
        if self.video_pipe is None:
            if not os.path.exists('/tmp/videopipe'):
                os.mkfifo('/tmp/videopipe')
            self.video_pipe = os.open('/tmp/videopipe', os.O_WRONLY)

        assert frame.shape == (self.height, self.width, 3)

        frame = np.clip(255*frame, 0, 255).astype('uint8')
        try:
            os.write(self.video_pipe, frame.tostring())
        except OSError:
            # The pipe has been closed. Reraise and handle it further
            # downstream
            raise 
开发者ID:317070,项目名称:python-twitch-stream,代码行数:25,代码来源:outputvideo.py

示例8: setUp

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def setUp(self):
        self.td = TemporaryDirectory()
        self.addCleanup(self.td.cleanup)
        
        self.file_path = os.path.join(self.td.name, 'afile')
        with open(self.file_path, 'w') as f:
            f.write('Blah')
        
        self.dir_path = os.path.join(self.td.name, 'adir')
        os.mkdir(self.dir_path)
        
        self.link_path = os.path.join(self.td.name, 'alink')
        self.pipe_path = os.path.join(self.td.name, 'apipe')
        self.socket_path = os.path.join(self.td.name, 'asocket')
        if os.name == 'posix':
            # Symlinks are rarely usable on Windows, because a special
            # permission is needed to create them.
            os.symlink(self.file_path, self.link_path)
            os.mkfifo(self.pipe_path)
            self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
            self.sock.bind(self.socket_path)

        self.nonexistant_path = os.path.join(self.td.name, 'doesntexist') 
开发者ID:jupyter,项目名称:testpath,代码行数:25,代码来源:test_asserts.py

示例9: test_copytree_named_pipe

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def test_copytree_named_pipe(self):
            os.mkdir(TESTFN)
            try:
                subdir = os.path.join(TESTFN, "subdir")
                os.mkdir(subdir)
                pipe = os.path.join(subdir, "mypipe")
                os.mkfifo(pipe)
                try:
                    shutil.copytree(TESTFN, TESTFN2)
                except shutil.Error as e:
                    errors = e.args[0]
                    self.assertEqual(len(errors), 1)
                    src, dst, error_msg = errors[0]
                    self.assertEqual("`%s` is a named pipe" % pipe, error_msg)
                else:
                    self.fail("shutil.Error should have been raised")
            finally:
                shutil.rmtree(TESTFN, ignore_errors=True)
                shutil.rmtree(TESTFN2, ignore_errors=True) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:21,代码来源:test_shutil.py

示例10: xterm_window

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def xterm_window(xvfb, tmpdir):
    """
    Create an xterm window test fixture.  This fixture opens a new xterm
    window and yields its the X window id.  Upon test completion the xterm
    process is cleaned up.
    :param xvfb:
    :return:
    """
    xterm_pipe_path = tmpdir.join('xterm_pipe').strpath
    xterm_proc = None

    try:
        os.mkfifo(xterm_pipe_path)
        xterm_proc = subprocess.Popen([
            'xterm', '-T', 'My window title', '-e',
            'echo "$WINDOWID" > "{}"; bash'.format(xterm_pipe_path)
        ])
        with open(xterm_pipe_path, 'r') as pipe:
            window_id = int(pipe.read())
        yield XtermProcessInfo(proc=xterm_proc, window_id=window_id)
    finally:
        if xterm_proc:
            xterm_proc.terminate() 
开发者ID:rshk,项目名称:python-libxdo,代码行数:25,代码来源:conftest.py

示例11: import_via_exaplus

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def import_via_exaplus(self, table_name, table_generator, prepare_sql):
        tmpdir = tempfile.mkdtemp()
        fifo_filename = os.path.join(tmpdir, 'myfifo')
        import_table_sql = '''IMPORT INTO %s FROM LOCAL CSV FILE '%s';'''%(table_name,fifo_filename)
        try:
            os.mkfifo(fifo_filename)
            write_trhead = threading.Thread(target=self._write_into_fifo, args=(fifo_filename, table_generator))
            write_trhead.start()
            sql=prepare_sql+"\n"+import_table_sql+"\n"+"commit;"
            out,err=self.query_via_exaplus(sql)
            print(out)
            print(err)
            write_trhead.join()
        finally:
            os.remove(fifo_filename)
            os.rmdir(tmpdir) 
开发者ID:exasol,项目名称:script-languages,代码行数:18,代码来源:__init__.py

示例12: _test_open

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def _test_open(self, do_open_close_reader, do_open_close_writer):
        filename = support.TESTFN

        # Use a fifo: until the child opens it for reading, the parent will
        # block when trying to open it for writing.
        support.unlink(filename)
        os.mkfifo(filename)
        self.addCleanup(support.unlink, filename)

        code = '\n'.join((
            'import os, time',
            '',
            'path = %a' % filename,
            'sleep_time = %r' % self.sleep_time,
            '',
            '# let the parent block',
            'time.sleep(sleep_time)',
            '',
            do_open_close_reader,
        ))

        proc = self.subprocess(code)
        with kill_on_error(proc):
            do_open_close_writer(filename)
            self.assertEqual(proc.wait(), 0) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:eintr_tester.py

示例13: transmit

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def transmit(self, complex_iq):
        hackrf_out = self.convert(complex_iq)
        pipe_file = mktemp()
        os.mkfifo(pipe_file)
        hackout = Popen(['hackrf_transfer', '-f', str(self.frequency), '-s', str(self.samplerate), '-b', str(self.bandwidth),
                          '-x', str(self.txvga), '-t', pipe_file], stdin=PIPE, stdout=PIPE, stderr=PIPE)
        pipe = open(pipe_file, 'wb')
        pipe.write(hackrf_out)
        pipe.close()
        hackout.wait()
        sout = hackout.communicate()
        os.unlink(pipe_file)
        return sout 
开发者ID:polygon,项目名称:spectrum_painter,代码行数:15,代码来源:radios.py

示例14: makefifo

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def makefifo(self, tarinfo, targetpath):
        """Make a fifo called targetpath.
        """
        if hasattr(os, "mkfifo"):
            os.mkfifo(targetpath)
        else:
            raise ExtractError("fifo not supported by system") 
开发者ID:war-and-code,项目名称:jawfish,代码行数:9,代码来源:tarfile.py

示例15: download_dir

# 需要导入模块: import os [as 别名]
# 或者: from os import mkfifo [as 别名]
def download_dir(tmpdir):
    downloads = tmpdir / 'downloads'
    downloads.ensure(dir=True)
    (downloads / 'subdir').ensure(dir=True)
    try:
        os.mkfifo(str(downloads / 'fifo'))
    except AttributeError:
        pass
    unwritable = downloads / 'unwritable'
    unwritable.ensure(dir=True)
    unwritable.chmod(0)

    yield downloads

    unwritable.chmod(0o755) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:17,代码来源:test_downloads_bdd.py


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