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


Python os.execvpe方法代码示例

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


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

示例1: exec_fork

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def exec_fork(l, env): 
    pid = os.fork()
    if not pid:
        # Child process.
        exitval = 127
        try:
            os.execvpe(l[0], l, env)
        except OSError as e:
            exitval = exitvalmap.get(e[0], e[0])
            sys.stderr.write("scons: %s: %s\n" % (l[0], e[1]))
        os._exit(exitval)
    else:
        # Parent process.
        pid, stat = os.waitpid(pid, 0)
        if stat & 0xff:
            return stat | 0x80
        return stat >> 8 
开发者ID:coin3d,项目名称:pivy,代码行数:19,代码来源:posix.py

示例2: _execChild

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def _execChild(self, path, uid, gid, executable, args, environment):
        """
        The exec() which is done in the forked child.
        """
        if path:
            os.chdir(path)
        if uid is not None or gid is not None:
            if uid is None:
                uid = os.geteuid()
            if gid is None:
                gid = os.getegid()
            # set the UID before I actually exec the process
            os.setuid(0)
            os.setgid(0)
            switchUID(uid, gid)
        os.execvpe(executable, args, environment) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:process.py

示例3: test_executionError

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def test_executionError(self):
        """
        Raise an error during execvpe to check error management.
        """
        cmd = self.getCommand('false')

        d = defer.Deferred()
        p = TrivialProcessProtocol(d)
        def buggyexecvpe(command, args, environment):
            raise RuntimeError("Ouch")
        oldexecvpe = os.execvpe
        os.execvpe = buggyexecvpe
        try:
            reactor.spawnProcess(p, cmd, [b'false'], env=None,
                                 usePTY=self.usePTY)

            def check(ignored):
                errData = b"".join(p.errData + p.outData)
                self.assertIn(b"Upon execvpe", errData)
                self.assertIn(b"Ouch", errData)
            d.addCallback(check)
        finally:
            os.execvpe = oldexecvpe
        return d 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:26,代码来源:test_process.py

示例4: reexec

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def reexec(self):
        """\
        Relaunch the master and workers.
        """
        if self.pidfile is not None:
            self.pidfile.rename("%s.oldbin" % self.pidfile.fname)

        self.reexec_pid = os.fork()
        if self.reexec_pid != 0:
            self.master_name = "Old Master"
            return

        environ = self.cfg.env_orig.copy()
        fds = [l.fileno() for l in self.LISTENERS]
        environ['GUNICORN_FD'] = ",".join([str(fd) for fd in fds])

        os.chdir(self.START_CTX['cwd'])
        self.cfg.pre_exec(self)

        # exec the process using the original environnement
        os.execvpe(self.START_CTX[0], self.START_CTX['args'], environ) 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:23,代码来源:arbiter.py

示例5: execute_new_nvim_process

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def execute_new_nvim_process(self, silent, nvr, options, arguments):
        if not silent:
            print(textwrap.dedent('''\
                [*] Starting new nvim process using $NVR_CMD or 'nvim'.

                    Use --nostart to avoid starting a new process.
            '''))

        args = os.environ.get('NVR_CMD')
        args = args.split(' ') if args else ['nvim']

        multiprocessing.Process(target=self.try_attach, args=(args, nvr, options, arguments)).start()

        os.environ['NVIM_LISTEN_ADDRESS'] = self.address
        try:
            os.execvpe(args[0], args, os.environ)
        except FileNotFoundError:
            print("[!] Can't start new nvim process: '{}' is not in $PATH.".format(args[0]))
            sys.exit(1) 
开发者ID:mhinz,项目名称:neovim-remote,代码行数:21,代码来源:nvr.py

示例6: spawn

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def spawn(self):
        env = self.env
        env['TERM'] = 'linux'

        self.pid, self.master = pty.fork()

        if self.pid == 0:
            if callable(self.command):
                try:
                    try:
                        self.command()
                    except:
                        sys.stderr.write(traceback.format_exc())
                        sys.stderr.flush()
                finally:
                    os._exit(0)
            else:
                os.execvpe(self.command[0], self.command, env)

        if self.main_loop is None:
            fcntl.fcntl(self.master, fcntl.F_SETFL, os.O_NONBLOCK)

        atexit.register(self.terminate) 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:25,代码来源:vterm.py

示例7: test_executionError

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def test_executionError(self):
        """
        Raise an error during execvpe to check error management.
        """
        cmd = self.getCommand('false')

        d = defer.Deferred()
        p = TrivialProcessProtocol(d)
        def buggyexecvpe(command, args, environment):
            raise RuntimeError("Ouch")
        oldexecvpe = os.execvpe
        os.execvpe = buggyexecvpe
        try:
            reactor.spawnProcess(p, cmd, ['false'], env=None,
                                 usePTY=self.usePTY)

            def check(ignored):
                errData = "".join(p.errData + p.outData)
                self.assertIn("Upon execvpe", errData)
                self.assertIn("Ouch", errData)
            d.addCallback(check)
        finally:
            os.execvpe = oldexecvpe
        return d 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:26,代码来源:test_process.py

示例8: _run

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def _run(*, port: str, db: Optional[Path]=None, timezone: str, quiet: bool):
    logger = get_logger()
    env = {
        **os.environ,
        # not sure if there is a simpler way to communicate with hug..
        # # TODO here
        _ENV_CONFIG: json.dumps({
            'timezone': timezone,
            **({} if db is None else {'db': str(db)})
        }),
    }
    args = [
        'python3',
        '-m', 'hug', # TODO eh, not sure about this. what if user had it already installed?? it's a mess..
        *(['--silent'] if quiet else []),
        '-p', port,
        '-f', __file__,
    ]
    logger.info('Running server: %s', args)
    os.execvpe('python3', args, env) 
开发者ID:karlicoss,项目名称:promnesia,代码行数:22,代码来源:server.py

示例9: _execute

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def _execute(path, argv, environ):
            if environ is None:
                os.execvp(path, argv)
            else:
                os.execvpe(path, argv, environ)
            return

    # endregion 
开发者ID:remg427,项目名称:misp42splunk,代码行数:10,代码来源:external_search_command.py

示例10: exec_cc

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def exec_cc(cmd, args):
    """
    Execute with current context.
    Yes, you're right -- I'm naming it after call/cc.

    Return a generator.
        The first yielded one is the status of
        the execution of subprocess command.

        The following ones are the the buffer batches of stderr,
        each of which is a Python 'bytes' object
    """
    file = cmd
    err_in, err_out = os.pipe()
    out_in, out_out = os.pipe()
    if os.fork():
        _, status = os.wait()
        os.close(err_out)
        os.close(out_out)
        yield status
        while True:
            load = os.read(err_in, 1024)
            if not load:
                break
            yield load
    else:
        # for child process
        os.close(err_in)
        os.close(out_in)
        os.dup2(err_out, sys.stderr.fileno())
        os.dup2(out_out, sys.stdout.fileno())

        os.execvpe(file, [cmd, *args], dict(os.environ))
        # in case that os.execvp fails
        sys.exit(127) 
开发者ID:thautwarm,项目名称:restrain-jit,代码行数:37,代码来源:utils.py

示例11: reexec

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def reexec(self):
        """\
        Relaunch the master and workers.
        """
        if self.reexec_pid != 0:
            self.log.warning("USR2 signal ignored. Child exists.")
            return

        if self.master_pid != 0:
            self.log.warning("USR2 signal ignored. Parent exists")
            return

        master_pid = os.getpid()
        self.reexec_pid = os.fork()
        if self.reexec_pid != 0:
            return

        self.cfg.pre_exec(self)

        environ = self.cfg.env_orig.copy()
        fds = [l.fileno() for l in self.LISTENERS]
        environ['GUNICORN_FD'] = ",".join([str(fd) for fd in fds])
        environ['GUNICORN_PID'] = str(master_pid)

        os.chdir(self.START_CTX['cwd'])

        # exec the process using the original environnement
        os.execvpe(self.START_CTX[0], self.START_CTX['args'], environ) 
开发者ID:jpush,项目名称:jbox,代码行数:30,代码来源:arbiter.py

示例12: execute

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def execute(self, bin, *args, **kwargs):
        bin = self._bin(bin)

        if not self._is_windows:
            args = [bin] + list(args)
            if "env" in kwargs:
                return os.execvpe(bin, args, kwargs["env"])
            else:
                return os.execvp(bin, args)
        else:
            exe = subprocess.Popen([bin] + list(args), **kwargs)
            exe.communicate()
            return exe.returncode 
开发者ID:python-poetry,项目名称:poetry,代码行数:15,代码来源:env.py

示例13: test_execvpe_with_bad_arglist

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def test_execvpe_with_bad_arglist(self):
        self.assertRaises(ValueError, os.execvpe, 'notepad', [], None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:test_os.py

示例14: _spawn_posix

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0):
    log.info(' '.join(cmd))
    if dry_run:
        return
    exec_fn = search_path and os.execvp or os.execv
    exec_args = [cmd[0], cmd]
    if sys.platform == 'darwin':
        global _cfg_target, _cfg_target_split
        if _cfg_target is None:
            _cfg_target = sysconfig.get_config_var(
                                  'MACOSX_DEPLOYMENT_TARGET') or ''
            if _cfg_target:
                _cfg_target_split = [int(x) for x in _cfg_target.split('.')]
        if _cfg_target:
            # ensure that the deployment target of build process is not less
            # than that used when the interpreter was built. This ensures
            # extension modules are built with correct compatibility values
            cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target)
            if _cfg_target_split > [int(x) for x in cur_target.split('.')]:
                my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: '
                          'now "%s" but "%s" during configure'
                                % (cur_target, _cfg_target))
                raise DistutilsPlatformError(my_msg)
            env = dict(os.environ,
                       MACOSX_DEPLOYMENT_TARGET=cur_target)
            exec_fn = search_path and os.execvpe or os.execve
            exec_args.append(env)
    pid = os.fork()

    if pid == 0:  # in the child
        try:
            exec_fn(*exec_args)
        except OSError, e:
            sys.stderr.write("unable to execute %s: %s\n" %
                             (cmd[0], e.strerror))
            os._exit(1)

        sys.stderr.write("unable to execute %s for unknown reasons" % cmd[0])
        os._exit(1) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:41,代码来源:spawn.py

示例15: create_execve

# 需要导入模块: import os [as 别名]
# 或者: from os import execvpe [as 别名]
def create_execve(original_name):
    """
    os.execve(path, args, env)
    os.execvpe(file, args, env)
    """

    def new_execve(path, args, env):
        if _get_apply_arg_patching():
            args = patch_args(args, is_exec=True)
            send_process_created_message()

        return getattr(os, original_name)(path, args, env)

    return new_execve 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:16,代码来源:pydev_monkey.py


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