Python os.execle() Examples
The following are 15
code examples of os.execle().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: pydev_monkey.py From PyDev.Debugger with Eclipse Public License 1.0 | 6 votes |
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
Example #2
Source File: driver.py From Xpedite with Apache License 2.0 | 6 votes |
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)
Example #3
Source File: pydev_monkey.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
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)
Example #4
Source File: installation.py From RAFCON with Eclipse Public License 1.0 | 5 votes |
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)
Example #5
Source File: helpers.py From TG-UserBot with GNU General Public License v3.0 | 5 votes |
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)
Example #6
Source File: pluginManager.py From TG-UserBot with GNU General Public License v3.0 | 5 votes |
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)
Example #7
Source File: core.py From dask-gateway with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #8
Source File: helpers.py From BotHub with Apache License 2.0 | 5 votes |
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)
Example #9
Source File: pluginManager.py From BotHub with Apache License 2.0 | 5 votes |
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)
Example #10
Source File: utils.py From dusty with MIT License | 5 votes |
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)
Example #11
Source File: utils.py From dusty with MIT License | 5 votes |
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]))
Example #12
Source File: pydev_monkey.py From filmkodi with Apache License 2.0 | 5 votes |
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
Example #13
Source File: pydev_monkey.py From filmkodi with Apache License 2.0 | 5 votes |
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)
Example #14
Source File: pydev_monkey.py From PyDev.Debugger with Eclipse Public License 1.0 | 4 votes |
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)
Example #15
Source File: pydev_monkey.py From filmkodi with Apache License 2.0 | 4 votes |
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)