本文整理汇总了Python中os.spawnle方法的典型用法代码示例。如果您正苦于以下问题:Python os.spawnle方法的具体用法?Python os.spawnle怎么用?Python os.spawnle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os
的用法示例。
在下文中一共展示了os.spawnle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: patch_new_process_functions_with_warning
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnle [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)
示例2: test_spawnle
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnle [as 别名]
def test_spawnle(self):
ping_cmd = os.path.join(os.environ['windir'], 'system32', 'ping')
#simple sanity check
os.spawnle(nt.P_WAIT, ping_cmd , "ping", "/?", {})
#BUG - the first parameter of spawnle should be "ping"
#nt.spawnle(nt.P_WAIT, ping_cmd , "ping", "127.0.0.1", {})
#BUG - even taking "ping" out, multiple args do not work
#pid = nt.spawnle(nt.P_NOWAIT, ping_cmd , "-n", "15", "-w", "1000", "127.0.0.1", {})
#negative cases
self.assertRaises(TypeError, os.spawnle, nt.P_WAIT, ping_cmd , "ping", "/?", None)
self.assertRaises(TypeError, os.spawnle, nt.P_WAIT, ping_cmd , "ping", "/?", {1: "xyz"})
self.assertRaises(TypeError, os.spawnle, nt.P_WAIT, ping_cmd , "ping", "/?", {"abc": 1})
示例3: restarter
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnle [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)
示例4: restart_script
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnle [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)
示例5: restarter
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnle [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)
示例6: restart_script
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnle [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)
示例7: patch_new_process_functions_with_warning
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnle [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)
示例8: patch_new_process_functions
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnle [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)
示例9: patch_new_process_functions
# 需要导入模块: import os [as 别名]
# 或者: from os import spawnle [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)