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


Python os.execle方法代码示例

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


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

示例1: create_execl

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def create_execl(original_name):

    def new_execl(path, *args):
        """
        os.execl(path, arg0, arg1, ...)
        os.execle(path, arg0, arg1, ..., env)
        os.execlp(file, arg0, arg1, ...)
        os.execlpe(file, arg0, arg1, ..., env)
        """
        if _get_apply_arg_patching():
            args = patch_args(args, is_exec=True)
            send_process_created_message()

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

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

示例2: launchJupyter

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def launchJupyter(homeDir):
  """
  Method to set env vars for overriding jup config, adding
   python path and extensions, and finally launching jupyter

  """
  from xpedite.jupyter         import SHELL_PREFIX, DATA_DIR
  from xpedite.dependencies    import binPath
  LOGGER.info('')
  pyPath = os.path.dirname(binPath('python')) + os.pathsep + os.environ['PATH']
  initPath = os.path.dirname(__file__)
  jupyterEnv = os.environ
  jupyterEnv[Context.dataPathKey] = os.path.join(os.path.abspath(homeDir), DATA_DIR)
  jupyterEnv['JUPYTER_PATH'] = os.path.join(initPath, '../../../jupyter/extensions/')
  jupyterEnv['JUPYTER_CONFIG_DIR'] = os.path.join(initPath, '../../../jupyter/config/')
  jupyterEnv['XPEDITE_PATH'] = os.path.abspath(os.path.join(initPath, '../../'))
  jupyterEnv['PATH'] = pyPath
  jupyterEnv['HOME'] = tempfile.mkdtemp(prefix=SHELL_PREFIX, dir='/tmp')
  ip = socket.gethostbyname(socket.gethostname())
  jupyterBinary = binPath('jupyter')
  os.execle(jupyterBinary, 'Xpedite', 'notebook', '--no-browser', '--ip='+ip, '--notebook-dir='+homeDir, jupyterEnv) 
开发者ID:Morgan-Stanley,项目名称:Xpedite,代码行数:23,代码来源:driver.py

示例3: patch_new_process_functions_with_warning

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def patch_new_process_functions_with_warning():
    monkey_patch_os('execl', create_warn_multiproc)
    monkey_patch_os('execle', create_warn_multiproc)
    monkey_patch_os('execlp', create_warn_multiproc)
    monkey_patch_os('execlpe', create_warn_multiproc)
    monkey_patch_os('execv', create_warn_multiproc)
    monkey_patch_os('execve', create_warn_multiproc)
    monkey_patch_os('execvp', create_warn_multiproc)
    monkey_patch_os('execvpe', create_warn_multiproc)
    monkey_patch_os('spawnl', create_warn_multiproc)
    monkey_patch_os('spawnle', create_warn_multiproc)
    monkey_patch_os('spawnlp', create_warn_multiproc)
    monkey_patch_os('spawnlpe', create_warn_multiproc)
    monkey_patch_os('spawnv', create_warn_multiproc)
    monkey_patch_os('spawnve', create_warn_multiproc)
    monkey_patch_os('spawnvp', create_warn_multiproc)
    monkey_patch_os('spawnvpe', create_warn_multiproc)
    monkey_patch_os('posix_spawn', create_warn_multiproc)

    if not IS_JYTHON:
        if not IS_WINDOWS:
            monkey_patch_os('fork', create_warn_multiproc)
            try:
                import _posixsubprocess
                monkey_patch_module(_posixsubprocess, 'fork_exec', create_warn_fork_exec)
            except ImportError:
                pass
        else:
            # Windows
            try:
                import _subprocess
            except ImportError:
                import _winapi as _subprocess
            monkey_patch_module(_subprocess, 'CreateProcess', create_CreateProcessWarnMultiproc) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:36,代码来源:pydev_monkey.py

示例4: install_fonts

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def install_fonts(restart=False):
    # do not import from rafcon.gui.constants, as this script can be used standalone
    font_names_to_be_installed = ["SourceSansPro", "FontAwesome5Free", "RAFCON"]

    user_otf_fonts_folder = join(resources.xdg_user_data_folder, "fonts")

    font_installed = False
    try:
        for font_name in font_names_to_be_installed:
            # A font is a folder one or more font faces
            rel_font_folder = join("type1", font_name)
            fonts_folder = resources.get_data_file_path("fonts", rel_font_folder)
            num_faces_to_be_installed = len([name for name in os.listdir(fonts_folder) if name.endswith(".otf")])
            num_faces_installed = installed_font_faces_for_font(font_name)

            if num_faces_to_be_installed <= num_faces_installed:
                logger.debug("Font '{0}' already installed".format(font_name))
                continue

            specific_user_otf_fonts_folder = join(user_otf_fonts_folder, rel_font_folder)
            logger.info("Installing font '{0}' to {1}".format(font_name, specific_user_otf_fonts_folder))
            copy_tree(fonts_folder, specific_user_otf_fonts_folder, update=1)
            font_installed = True
    except IOError as e:
        logger.error("Could not install fonts, IOError: {}".format(e))
        return

    if font_installed:
        logger.info("Running font detection ...")
        if not update_font_cache(user_otf_fonts_folder):
            logger.warning("Could not run font detection using 'fc-cache'. RAFCON might not find the correct fonts.")
        if restart:
            python = sys.executable
            environ = dict(**os.environ)
            # Passing this to the new RAFCON environment will prevent further checks and thus restarts
            environ["RAFCON_CHECK_INSTALLATION"] = "False"
            args_and_env = list(sys.argv)
            args_and_env.append(environ)
            logger.info("Restarting RAFCON ...")
            os.execle(python, python, *args_and_env) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:42,代码来源:installation.py

示例5: restarter

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def restarter(client: UserBotClient) -> None:
    executable = sys.executable.replace(' ', '\\ ')
    args = [executable, '-m', 'userbot']
    if client.disabled_commands:
        disabled_list = ", ".join(client.disabled_commands.keys())
        os.environ['userbot_disabled_commands'] = disabled_list
    if os.environ.get('userbot_afk', False):
        plugins_data.dump_AFK()
    client._kill_running_processes()

    if sys.platform.startswith('win'):
        os.spawnle(os.P_NOWAIT, executable, *args, os.environ)
    else:
        os.execle(executable, *args, os.environ) 
开发者ID:TG-UserBot,项目名称:TG-UserBot,代码行数:16,代码来源:helpers.py

示例6: restart_script

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def restart_script() -> None:
    """Restart the current script."""
    executable = sys.executable.replace(' ', '\\ ')
    args = [executable, '-m', 'userbot']
    if sys.platform.startswith('win'):
        os.spawnle(os.P_NOWAIT, executable, *args, os.environ)
    else:
        os.execle(executable, *args, os.environ)
    sys.exit(0) 
开发者ID:TG-UserBot,项目名称:TG-UserBot,代码行数:11,代码来源:pluginManager.py

示例7: start

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def start(self):
        proxy = Proxy(
            parent=self.parent, log=self.parent.log, gateway_address=self.parent.address
        )
        command = proxy.get_start_command(is_child_process=False)
        env = proxy.get_start_env()
        exe = command[0]
        args = command[1:]
        os.execle(exe, "dask-gateway-proxy", *args, env) 
开发者ID:dask,项目名称:dask-gateway,代码行数:11,代码来源:core.py

示例8: restarter

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def restarter(client: UserBotClient) -> None:
    args = [sys.executable, "-m", "userbot"]
    if client.disabled_commands:
        disabled_list = ", ".join(client.disabled_commands.keys())
        os.environ['userbot_disabled_commands'] = disabled_list
    if os.environ.get('userbot_afk', False):
        plugins_data.dump_AFK()
    client._kill_running_processes()

    if sys.platform.startswith('win'):
        os.spawnle(os.P_NOWAIT, sys.executable, *args, os.environ)
    else:
        os.execle(sys.executable, *args, os.environ) 
开发者ID:mkaraniya,项目名称:BotHub,代码行数:15,代码来源:helpers.py

示例9: restart_script

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def restart_script() -> None:
    """Restart the current script."""
    args = [sys.executable, "-m", "userbot"]
    if sys.platform.startswith('win'):
        os.spawnle(os.P_NOWAIT, sys.executable, *args, os.environ)
    else:
        os.execle(sys.executable, *args, os.environ)
    sys.exit(0) 
开发者ID:mkaraniya,项目名称:BotHub,代码行数:10,代码来源:pluginManager.py

示例10: exec_docker

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def exec_docker(*args):
    updated_env = copy(os.environ)
    updated_env.update(get_docker_env())
    args += (updated_env,)
    os.execle(_executable_path('docker'), 'docker', *args) 
开发者ID:gamechanger,项目名称:dusty,代码行数:7,代码来源:utils.py

示例11: pty_fork

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def pty_fork(*args):
    """Runs a subprocess with a PTY attached via fork and exec.
    The output from the PTY is streamed through log_to_client.
    This should not be necessary for most subprocesses, we
    built this to handle Compose up which only streams pull
    progress if it is attached to a TTY."""

    updated_env = copy(os.environ)
    updated_env.update(get_docker_env())
    args += (updated_env,)
    executable = args[0]
    demote_fn = demote_to_user(get_config_value(constants.CONFIG_MAC_USERNAME_KEY))

    child_pid, pty_fd = pty.fork()
    if child_pid == 0:
        demote_fn()
        os.execle(_executable_path(executable), *args)
    else:
        child_process = psutil.Process(child_pid)
        terminal = os.fdopen(pty_fd, 'r', 0)
        with streaming_to_client():
            while child_process.status() == 'running':
                output = terminal.read(1)
                log_to_client(output)
        _, exit_code = os.waitpid(child_pid, 0)
        if exit_code != 0:
            raise subprocess.CalledProcessError(exit_code, ' '.join(args[:-1])) 
开发者ID:gamechanger,项目名称:dusty,代码行数:29,代码来源:utils.py

示例12: create_execl

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def create_execl(original_name):
    def new_execl(path, *args):
        """
        os.execl(path, arg0, arg1, ...)
        os.execle(path, arg0, arg1, ..., env)
        os.execlp(file, arg0, arg1, ...)
        os.execlpe(file, arg0, arg1, ..., env)
        """
        import os
        args = patch_args(args)
        return getattr(os, original_name)(path, *args)
    return new_execl 
开发者ID:mrknow,项目名称:filmkodi,代码行数:14,代码来源:pydev_monkey.py

示例13: patch_new_process_functions_with_warning

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def patch_new_process_functions_with_warning():
    monkey_patch_os('execl', create_warn_multiproc)
    monkey_patch_os('execle', create_warn_multiproc)
    monkey_patch_os('execlp', create_warn_multiproc)
    monkey_patch_os('execlpe', create_warn_multiproc)
    monkey_patch_os('execv', create_warn_multiproc)
    monkey_patch_os('execve', create_warn_multiproc)
    monkey_patch_os('execvp', create_warn_multiproc)
    monkey_patch_os('execvpe', create_warn_multiproc)
    monkey_patch_os('spawnl', create_warn_multiproc)
    monkey_patch_os('spawnle', create_warn_multiproc)
    monkey_patch_os('spawnlp', create_warn_multiproc)
    monkey_patch_os('spawnlpe', create_warn_multiproc)
    monkey_patch_os('spawnv', create_warn_multiproc)
    monkey_patch_os('spawnve', create_warn_multiproc)
    monkey_patch_os('spawnvp', create_warn_multiproc)
    monkey_patch_os('spawnvpe', create_warn_multiproc)

    if sys.platform != 'win32':
        monkey_patch_os('fork', create_warn_multiproc)
        try:
            import _posixsubprocess
            monkey_patch_module(_posixsubprocess, 'fork_exec', create_warn_fork_exec)
        except ImportError:
            pass
    else:
        # Windows
        try:
            import _subprocess
        except ImportError:
            import _winapi as _subprocess
        monkey_patch_module(_subprocess, 'CreateProcess', create_CreateProcessWarnMultiproc) 
开发者ID:mrknow,项目名称:filmkodi,代码行数:34,代码来源:pydev_monkey.py

示例14: patch_new_process_functions

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def patch_new_process_functions():
    # os.execl(path, arg0, arg1, ...)
    # os.execle(path, arg0, arg1, ..., env)
    # os.execlp(file, arg0, arg1, ...)
    # os.execlpe(file, arg0, arg1, ..., env)
    # os.execv(path, args)
    # os.execve(path, args, env)
    # os.execvp(file, args)
    # os.execvpe(file, args, env)
    monkey_patch_os('execl', create_execl)
    monkey_patch_os('execle', create_execl)
    monkey_patch_os('execlp', create_execl)
    monkey_patch_os('execlpe', create_execl)
    monkey_patch_os('execv', create_execv)
    monkey_patch_os('execve', create_execve)
    monkey_patch_os('execvp', create_execv)
    monkey_patch_os('execvpe', create_execve)

    # os.spawnl(mode, path, ...)
    # os.spawnle(mode, path, ..., env)
    # os.spawnlp(mode, file, ...)
    # os.spawnlpe(mode, file, ..., env)
    # os.spawnv(mode, path, args)
    # os.spawnve(mode, path, args, env)
    # os.spawnvp(mode, file, args)
    # os.spawnvpe(mode, file, args, env)

    monkey_patch_os('spawnl', create_spawnl)
    monkey_patch_os('spawnle', create_spawnl)
    monkey_patch_os('spawnlp', create_spawnl)
    monkey_patch_os('spawnlpe', create_spawnl)
    monkey_patch_os('spawnv', create_spawnv)
    monkey_patch_os('spawnve', create_spawnve)
    monkey_patch_os('spawnvp', create_spawnv)
    monkey_patch_os('spawnvpe', create_spawnve)
    monkey_patch_os('posix_spawn', create_posix_spawn)

    if not IS_JYTHON:
        if not IS_WINDOWS:
            monkey_patch_os('fork', create_fork)
            try:
                import _posixsubprocess
                monkey_patch_module(_posixsubprocess, 'fork_exec', create_fork_exec)
            except ImportError:
                pass
        else:
            # Windows
            try:
                import _subprocess
            except ImportError:
                import _winapi as _subprocess
            monkey_patch_module(_subprocess, 'CreateProcess', create_CreateProcess) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:54,代码来源:pydev_monkey.py

示例15: patch_new_process_functions

# 需要导入模块: import os [as 别名]
# 或者: from os import execle [as 别名]
def patch_new_process_functions():
    # os.execl(path, arg0, arg1, ...)
    # os.execle(path, arg0, arg1, ..., env)
    # os.execlp(file, arg0, arg1, ...)
    # os.execlpe(file, arg0, arg1, ..., env)
    # os.execv(path, args)
    # os.execve(path, args, env)
    # os.execvp(file, args)
    # os.execvpe(file, args, env)
    monkey_patch_os('execl', create_execl)
    monkey_patch_os('execle', create_execl)
    monkey_patch_os('execlp', create_execl)
    monkey_patch_os('execlpe', create_execl)
    monkey_patch_os('execv', create_execv)
    monkey_patch_os('execve', create_execve)
    monkey_patch_os('execvp', create_execv)
    monkey_patch_os('execvpe', create_execve)

    # os.spawnl(mode, path, ...)
    # os.spawnle(mode, path, ..., env)
    # os.spawnlp(mode, file, ...)
    # os.spawnlpe(mode, file, ..., env)
    # os.spawnv(mode, path, args)
    # os.spawnve(mode, path, args, env)
    # os.spawnvp(mode, file, args)
    # os.spawnvpe(mode, file, args, env)

    monkey_patch_os('spawnl', create_spawnl)
    monkey_patch_os('spawnle', create_spawnl)
    monkey_patch_os('spawnlp', create_spawnl)
    monkey_patch_os('spawnlpe', create_spawnl)
    monkey_patch_os('spawnv', create_spawnv)
    monkey_patch_os('spawnve', create_spawnve)
    monkey_patch_os('spawnvp', create_spawnv)
    monkey_patch_os('spawnvpe', create_spawnve)

    if sys.platform != 'win32':
        monkey_patch_os('fork', create_fork)
        try:
            import _posixsubprocess
            monkey_patch_module(_posixsubprocess, 'fork_exec', create_fork_exec)
        except ImportError:
            pass
    else:
        # Windows
        try:
            import _subprocess
        except ImportError:
            import _winapi as _subprocess
        monkey_patch_module(_subprocess, 'CreateProcess', create_CreateProcess) 
开发者ID:mrknow,项目名称:filmkodi,代码行数:52,代码来源:pydev_monkey.py


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