本文整理汇总了Python中os.execl方法的典型用法代码示例。如果您正苦于以下问题:Python os.execl方法的具体用法?Python os.execl怎么用?Python os.execl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os
的用法示例。
在下文中一共展示了os.execl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_execl
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [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
示例2: end
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def end(self, restart=False, use_current_config=False):
'''
Called when the user has requested the service to end.
'''
# If we're restarting, we need to know the arguements used to start us
args = sys.argv
if restart and use_current_config:
args = self._put_current_config_in_args(args)
for block_collection in [self.inputs, self.mixers, self.outputs]:
for name, block in block_collection.items():
block.set_pipeline_state(Gst.State.NULL)
if hasattr(self, 'mainloop'):
self.mainloop.quit()
if restart:
os.execl(sys.executable, sys.executable, *args)
示例3: restart
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def restart(self, *args, git_update=False, pip=False):
""" Shoutout to the Userg team for this."""
await self.stop()
try:
c_p = psutil.Process(os.getpid())
for handler in c_p.open_files() + c_p.connections():
os.close(handler.fd)
except Exception as c_e:
print(c_e)
if git_update:
os.system('git reset --hard')
os.system('git pull')
if pip:
os.system('pip install -U -r requirements.txt')
os.execl(sys.executable, sys.executable, '-m', self.__class__.__name__.lower())
sys.exit()
示例4: doit
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def doit(irc, target, source):
commands = ["git fetch",
"git rebase --stat --preserve-merges"]
for command in commands:
child = subprocess.Popen(command.split(),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(out, err) = child.communicate()
ret = child.returncode
await irc.message(source, "{0} returned code {1}".format(command, ret))
for line in (out + err).splitlines():
await irc.message(source, line.decode("utf-8"))
irc.eventloop.schedule(irc.quit, "Updating...")
irc.eventloop.schedule(os.execl, sys.executable, sys.executable, *sys.argv)
示例5: forward_coinservs
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def forward_coinservs(host):
""" Given a hostname, connects to a remote and tunnels all coinserver ports
to local ports. Useful for development testing. """
args = [host, "-N"]
for currency in currencies.itervalues():
if not currency.coinserv:
continue
args.append("-L {0}:127.0.0.1:{0}"
.format(currency.coinserv.config['port']))
for pp in powerpools.itervalues():
parts = urlparse(pp.monitor_address)
if parts.hostname not in ['localhost', '127.0.0.1']:
continue
args.append("-L {0}:127.0.0.1:{0}".format(parts.port))
current_app.logger.info(("/usr/bin/ssh", "/usr/bin/ssh", args))
os.execl("/usr/bin/ssh", "/usr/bin/ssh", *args)
示例6: spawn
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def spawn(*args):
if os.name == 'nt':
# do proper argument quoting since exec/spawn on Windows doesn't
bargs = args
args = []
for a in bargs:
if not a.startswith("/"):
a.replace('"', '\"')
a = '"%s"' % a
args.append(a)
argstr = ' '.join(args[1:])
# use ShellExecute instead of spawn*() because we don't want
# handles (like the controlsocket) to be duplicated
win32api.ShellExecute(0, "open", args[0], argstr, None, 1) # 1 == SW_SHOW
else:
if os.access(args[0], os.X_OK):
forkback = os.fork()
if forkback == 0:
# BUG: stop IPC!
print "execl ", args[0], args
os.execl(args[0], *args)
else:
#BUG: what should we do here?
pass
示例7: _first_stage
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def _first_stage():
R,W=os.pipe()
r,w=os.pipe()
if os.fork():
os.dup2(0,100)
os.dup2(R,0)
os.dup2(r,101)
os.close(R)
os.close(r)
os.close(W)
os.close(w)
if sys.platform == 'darwin' and sys.executable == '/usr/bin/python':
sys.executable += sys.version[:3]
os.environ['ARGV0']=sys.executable
os.execl(sys.executable,sys.executable+'(mitogen:CONTEXT_NAME)')
os.write(1,'MITO000\n'.encode())
C=_(os.fdopen(0,'rb').read(PREAMBLE_COMPRESSED_LEN),'zip')
fp=os.fdopen(W,'wb',0)
fp.write(C)
fp.close()
fp=os.fdopen(w,'wb',0)
fp.write(C)
fp.close()
os.write(1,'MITO001\n'.encode())
os.close(2)
示例8: main
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def main():
args = sys.argv[1:]
os.environ['PYTHONPATH'] = boot_dir
# 执行后面的 python 程序命令
# sys.executable 是 python 解释器程序的绝对路径 ``which python``
# >>> sys.executable
# '/usr/local/var/pyenv/versions/3.5.1/bin/python3.5'
os.execl(sys.executable, sys.executable, *args)
示例9: restart
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def restart(*args):
os.execl(sys.executable, sys.executable, "-m", os.path.relpath(utils.get_base_dir()), *args)
###################################################################################
# Blobs (mp3 files from the Internet Archive, Windows XP shutdown/startup sounds) #
###################################################################################
示例10: _do_restart
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def _do_restart(self, ok):
if ok:
self.app.stop()
os.execl(sys.executable, sys.executable, *sys.argv)
示例11: autoreset
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def autoreset():
time.sleep(600)
while not saferes:
time.sleep(0.5)
tried_to = 10000
time.sleep(30)
save("quitting - backup thread")
os.execl(sys.executable, sys.executable, *sys.argv)
示例12: restart_program
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def restart_program():
python = sys.executable
os.execl(python, python, * sys.argv)
示例13: restart_program
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def restart_program(self):
python = sys.executable
os.execl(python, python, * sys.argv)
#----------------------------------------------------------------------
示例14: cb_button_settings
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def cb_button_settings(self, button):
self.main_window.hide()
while Gtk.events_pending():
Gtk.main_iteration()
self.set_wineprefix()
self.create_link()
self.set_environ()
self.set_win_ver_command()
self.set_additions_command()
launch_command = '"' + self.install_dir + '/' + self.game_name + '/settings.sh"'
full_command = self.win_ver_command + '\n' + \
self.additions_command + '\n' + \
launch_command
os.system(full_command)
self.config_save()
self.exe_path = self.get_new_exe_path()
os.execl(sys.executable, sys.executable, __file__, self.game_name, self.exe_path)
示例15: cb_button_settings
# 需要导入模块: import os [as 别名]
# 或者: from os import execl [as 别名]
def cb_button_settings(self, button):
self.main_window.hide()
while Gtk.events_pending():
Gtk.main_iteration()
subprocess.call([self.install_dir + '/' + self.game_name + '/settings.sh', \
self.install_dir, nebula_dir])
self.config_save()
os.execl(sys.executable, sys.executable, __file__, self.game_name)