Python os 模块,mkfifo() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用os.mkfifo()

项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__(self, name, end=0, mode=0666):
        """Open a pair of pipes, name.in and name.out for communication
        with another process.  One process should pass 1 for end, and the
        other 0.  Data is marshalled with pickle."""
        self.in_name, self.out_name = name +'.in',  name +'.out',
        try: os.mkfifo(self.in_name,mode)
        except OSError: pass
        try: os.mkfifo(self.out_name,mode)
        except OSError: pass

        # NOTE: The order the ends are opened in is important - both ends
        # of pipe 1 must be opened before the second pipe can be opened.
        if end:
            self.inp = open(self.out_name,'r')
            self.out = open(self.in_name,'w')
        else:
            self.out = open(self.out_name,'w')
            self.inp = open(self.in_name,'r')
        self._open = True
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
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)
项目:roboschool    作者:openai    | 项目源码 | 文件源码
def __init__(self, scene, game_server_guid, player_n):
        """
        It doesn't know env_id yet, it creates pipes and waits for client to send his env_id.
        """
        self.scene = scene
        assert isinstance(game_server_guid, str)
        assert isinstance(player_n, int)
        self.player_n = player_n
        self.prefix = MULTIPLAYER_FILES_DIR + "/multiplayer_%s_player%02i" % (game_server_guid, player_n)
        self.sh_pipe_actready_filename = self.prefix + "_actready"
        self.sh_pipe_obsready_filename = self.prefix + "_obsready"
        try: os.unlink(self.sh_pipe_actready_filename)
        except: pass
        os.mkfifo(self.sh_pipe_actready_filename)
        try: os.unlink(self.sh_pipe_obsready_filename)
        except: pass
        os.mkfifo(self.sh_pipe_obsready_filename)
        print("Waiting %s" % self.prefix)
        self.need_reset = True
        self.need_response_tuple = False
项目:intel-manager-for-lustre    作者:intel-hpdd    | 项目源码 | 文件源码
def open_fifo(self):
        try:
            os.mkfifo(self.copytool.event_fifo)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise e

        pids = lsof(file=self.copytool.event_fifo)
        readers = set()
        writers = set()
        for pid, files in pids.items():
            for file, info in files.items():
                if 'r' in info['mode']:
                    readers.add(pid)
                if 'w' in info['mode']:
                    writers.add(pid)

        if readers:
            raise FifoReaderConflict(readers)

        self.reader_fd = os.open(self.copytool.event_fifo,
                                 os.O_RDONLY | os.O_NONBLOCK)
        copytool_log.info("Opened %s for reading" % self.copytool.event_fifo)
项目:libkak    作者:danr    | 项目源码 | 文件源码
def setup_reply_channel(self_or_session):
        r = Remote._resolve(self_or_session)
        r_pre = r.pre
        r.pre = lambda f: r_pre(f) + '''
                    __reply_fifo_dir=$(mktemp -d)
                    __reply_fifo="${__reply_fifo_dir}/fifo"
                    mkfifo ${__reply_fifo}
                '''
        r.post = '''
            \ncat ${__reply_fifo}
            rm ${__reply_fifo}
            rmdir ${__reply_fifo_dir}
        ''' + r.post
        r.arg_config['reply_fifo'] = ('__reply_fifo', Args.string)
        r.required_names.add('reply_fifo')
        return r
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
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)
项目:cpy2py    作者:maxfischer2781    | 项目源码 | 文件源码
def __init__(self, fifo_dir_path=None, is_master=True):
        self.is_master = is_master
        self._fifo_dir_path = fifo_dir_path
        if fifo_dir_path is None:
            self._fifo_dir_path = tempfile.mkdtemp()
            atexit.register(shutil.rmtree, self._fifo_dir_path)
        if is_master:
            self._fifo_read_path = os.path.join(self._fifo_dir_path, 'cpy2py_s2c.ipc')
            self._fifo_write_path = os.path.join(self._fifo_dir_path, 'cpy2py_c2s.ipc')
            os.mkfifo(self._fifo_read_path)
            os.mkfifo(self._fifo_write_path)
        else:
            self._fifo_read_path = os.path.join(self._fifo_dir_path, 'cpy2py_c2s.ipc')
            self._fifo_write_path = os.path.join(self._fifo_dir_path, 'cpy2py_s2c.ipc')
        self._fifo_read = None
        self._fifo_write = None
项目:challenges    作者:py-study-group    | 项目源码 | 文件源码
def write(self, msg):
        # create the pipe if necessary
        try:
            os.mkfifo(self.filename)
        except OSError as oe:
            if oe.errno != errno.EEXIST:
                raise
        # open it up for reading if necessary
        if not self.FIFO:
             self.FIFO = open(self.filename, 'w')
        print(msg, file=self.FIFO)


###############################################
# Functions                                   #
###############################################
项目:super_mario    作者:tsunaki00    | 项目源码 | 文件源码
def _create_pipes(self):
        # Creates named pipe for inter-process communication
        self.pipe_name = seeding.hash_seed(None) % 2 ** 32
        self.launch_vars['pipe_name'] = self.pipe_name
        if not self.disable_out_pipe:
            self.path_pipe_out = '%s-out.%d' % (self.path_pipe_prefix, self.pipe_name)
            os.mkfifo(self.path_pipe_out)

        # Launching a thread that will listen to incoming pipe
        # Thread exits if self.is_exiting = 1 or pipe_in is closed
        if not self.disable_in_pipe:
            thread_incoming = Thread(target=self._listen_to_incoming_pipe, kwargs={'pipe_name': self.pipe_name})
            thread_incoming.start()

        # Cannot open output pipe now, otherwise it will block until
        # a reader tries to open the file in read mode - Must launch fceux first
项目:PhotoPi    作者:JulienLegrand    | 项目源码 | 文件源码
def Start():
    if(config.DEBUG or not config.LIVE_PREVIEW_ENABLE):
        return

    # Start recording live preview
    pygameEngine.DrawCenterMessage(config.LIVE_PREVIEW_MSG, True)
    print "Start recording live preview"
    if os.path.exists(config.LIVE_MOVIE_FILE):
        os.remove(config.LIVE_MOVIE_FILE)
    os.mkfifo(config.LIVE_MOVIE_FILE)

    # To avoid problem, wait
    while not os.path.exists(config.LIVE_MOVIE_FILE):
        time.sleep(.1)
    camera.RecordPreview(config.LIVE_MOVIE_FILE, config.PREVIEW_DURATION)

    # Playing live preview
    pygameEngine.DrawCenterMessage("") #Clean screen before preview
    print "Playing live preview"
    os.popen(config.CMD_LIVE_PREVIEW_PLAY.format(filename = config.LIVE_MOVIE_FILE))
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
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)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
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)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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)
项目:python-    作者:secondtonone1    | 项目源码 | 文件源码
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")
项目:python-    作者:secondtonone1    | 项目源码 | 文件源码
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")
项目:my-first-blog    作者:AnkurBegining    | 项目源码 | 文件源码
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")
项目:transfert    作者:rbernand    | 项目源码 | 文件源码
def open(self, flags):
        os.mkfifo(self._pipe)
        self._thread = threading.Thread(target=self._client.get, daemon=True, args=(self.url.path, self._pipe))
        self._thread.start()
        self._fd = os.open(self._pipe, os.O_RDONLY)
项目:kinect-2-libras    作者:inessadl    | 项目源码 | 文件源码
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")
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
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")
项目:pip-update-requirements    作者:alanhamlett    | 项目源码 | 文件源码
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")
项目:girder_worker    作者:girder    | 项目源码 | 文件源码
def setUp(self):
        super(TestStream, self).setUp()
        if os.path.exists(_pipepath):
            os.unlink(_pipepath)
        os.mkfifo(_pipepath)
项目:girder_worker    作者:girder    | 项目源码 | 文件源码
def __init__(self, path):
        self.path = path
        self._fd = None
        os.mkfifo(self.path)
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
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")
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
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")
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
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")
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
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")
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
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")
项目:jira_worklog_scanner    作者:pgarneau    | 项目源码 | 文件源码
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")
项目:zanph    作者:zanph    | 项目源码 | 文件源码
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")
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
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")
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
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")
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
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")
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
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")
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
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")
项目:ascii-art-py    作者:blinglnav    | 项目源码 | 文件源码
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")
项目:nesgym    作者:codescv    | 项目源码 | 文件源码
def _ensure_create_pipe(self, pipe_name):
        if not os.path.exists(pipe_name):
            os.mkfifo(pipe_name)
    ## ------------ end pipes --------------
项目:ivaochdoc    作者:ivaoch    | 项目源码 | 文件源码
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")
项目:ivaochdoc    作者:ivaoch    | 项目源码 | 文件源码
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")
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
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")
项目:crypto-detector    作者:Wind-River    | 项目源码 | 文件源码
def makefifo(self, cpioinfo, cpiogetpath):
        """Make a fifo called cpiogetpath.
        """
        if hasattr(os, "mkfifo"):
            os.mkfifo(cpiogetpath)
        else:
            raise ExtractError("fifo not supported by system")
项目:django    作者:alexsukhrin    | 项目源码 | 文件源码
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")
项目:RPoint    作者:george17-meet    | 项目源码 | 文件源码
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")
项目:isni-reconcile    作者:cmh2166    | 项目源码 | 文件源码
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")
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
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")
项目:habilitacion    作者:GabrielBD    | 项目源码 | 文件源码
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")
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
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")
项目:pynapl    作者:marinuso    | 项目源码 | 文件源码
def __init__(self, name=None):
        if name==None:
            # make one
            name = tempfile.mktemp()
            os.mkfifo(name, 0o600)

        self.name=name
项目:flickr_downloader    作者:Denisolt    | 项目源码 | 文件源码
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")