Python os 模块,execl() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用os.execl()

项目:mongoaudit    作者:Exploit-install    | 项目源码 | 文件源码
def _clean_upgrade(binary_ok, binary_path, path, temp_path):
    if binary_ok:
        import stat
        # save the permissions from the current binary
        old_stat = os.stat(binary_path)
        # rename the current binary in order to replace it with the latest
        os.rename(binary_path, path + "/old")
        os.rename(temp_path, binary_path)
        # set the same permissions that had the previous binary
        os.chmod(binary_path, old_stat.st_mode | stat.S_IEXEC)
        # delete the old binary
        os.remove(path + "/old")
        print("mongoaudit updated, restarting...")
        os.execl(binary_path, binary_path, *sys.argv)
    else:
        os.remove(temp_path)
        print("couldn't download the latest binary")
项目:PyIDE    作者:raggesilver    | 项目源码 | 文件源码
def createProject(self, *args):
        self.getLang()
        dialog = Gtk.FileChooserDialog("Please choose a folder", self, Gtk.FileChooserAction.SELECT_FOLDER, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, "Select", Gtk.ResponseType.OK))
        response = dialog.run()


        if response == Gtk.ResponseType.OK:

            projectPath = dialog.get_filename()
            self.projectPath = projectPath
            with open(os.path.join(projectPath, '.pyide-project.json'), 'w+') as f:
                defaultSettings = {
                    'path': projectPath,
                    'name': projectPath.split('/')[len(projectPath.split('/')) - 1],
                    'language': self.language
                }
                json.dump(defaultSettings, f, indent=4, sort_keys=True, separators=(',', ':'))

            self.createMainFile()

            os.execl(sys.executable, *([sys.executable]+sys.argv+[projectPath]))

        dialog.destroy()
项目:Prism    作者:Stumblinbear    | 项目源码 | 文件源码
def restart(self):
        """ Safely restart prism """
        import os
        import sys
        import psutil
        import logging

        try:
            p = psutil.Process(os.getpid())
            for handler in p.open_files() + p.connections():
                os.close(handler.fd)
        except Exception as e:
            logging.error(e)

        python = sys.executable
        os.execl(python, python, *sys.argv)
项目:ambassador    作者:datawire    | 项目源码 | 文件源码
def fork_and_exec():
  """ This routine forks and execs a new child process and keeps track of its PID. Before we fork,
      set the current restart epoch in an env variable that processes can read if they care. """

  global restart_epoch
  os.environ['RESTART_EPOCH'] = str(restart_epoch)
  print ("forking and execing new child process at epoch {}".format(restart_epoch))
  restart_epoch += 1

  child_pid = os.fork()
  if child_pid == 0:
    # Child process
    os.execl(sys.argv[1], sys.argv[1])
  else:
    # Parent process
    print ("forked new child process with PID={}".format(child_pid))
    pid_list.append(child_pid)
项目:dd-trace-py    作者:DataDog    | 项目源码 | 文件源码
def main():
    if len(sys.argv) < 2 or sys.argv[1] == "-h":
        print(USAGE)
        return

    log.debug("sys.argv: %s", sys.argv)

    root_dir = _ddtrace_root()
    log.debug("ddtrace root: %s", root_dir)

    bootstrap_dir = os.path.join(root_dir, 'bootstrap')
    log.debug("ddtrace bootstrap: %s", bootstrap_dir)

    _add_bootstrap_to_pythonpath(bootstrap_dir)
    log.debug("PYTHONPATH: %s", os.environ['PYTHONPATH'])
    log.debug("sys.path: %s", sys.path)

    executable = sys.argv[1]

    # Find the executable path
    executable = spawn.find_executable(executable)
    log.debug("program executable: %s", executable)

    os.execl(executable, executable, *sys.argv[2:])
项目:Arduino_Semi-Tesla    作者:jpdik    | 项目源码 | 文件源码
def restart_program():
    """Restarts the current program.
    Note: this function does not return. Any cleanup action (like
    saving data) must be done before calling this function."""
    python = sys.executable
    os.execl(python, python, * sys.argv)
项目:mongoaudit    作者:stampery    | 项目源码 | 文件源码
def _clean_upgrade(binary_ok, binary_path, path, temp_path):
    if binary_ok:
        import stat
        # save the permissions from the current binary
        old_stat = os.stat(binary_path)
        # rename the current binary in order to replace it with the latest
        os.rename(binary_path, path + "/old")
        os.rename(temp_path, binary_path)
        # set the same permissions that had the previous binary
        os.chmod(binary_path, old_stat.st_mode | stat.S_IEXEC)
        # delete the old binary
        os.remove(path + "/old")
        print("mongoaudit updated, restarting...")
        os.execl(binary_path, binary_path, *sys.argv)
    else:
        os.remove(temp_path)
        print("couldn't download the latest binary")
项目:pwndemo    作者:zh-explorer    | 项目源码 | 文件源码
def dealarm_shell(tube):
    """Given a tube which is a shell, dealarm it.
    """
    tube.clean()

    tube.sendline('which python')
    if tube.recvline().startswith('/'):
        tube.sendline('''exec python -c "import signal, os; signal.alarm(0); os.execl('$SHELL','')"''')
        return tube

    tube.sendline('which perl')
    if tube.recvline().startswith('/'):
        tube.sendline('''exec perl -e "alarm 0; exec '$SHELL'"''')
        return tube

    return None
项目:voltha    作者:opencord    | 项目源码 | 文件源码
def fork_and_exec():
  """ This routine forks and execs a new child process and keeps track of its PID. Before we fork,
      set the current restart epoch in an env variable that processes can read if they care. """

  global restart_epoch
  os.environ['RESTART_EPOCH'] = str(restart_epoch)
  print "forking and execing new child process at epoch {}".format(restart_epoch)
  restart_epoch += 1

  child_pid = os.fork()
  if child_pid == 0:
    # Child process
    os.execl(sys.argv[1], sys.argv[1])
  else:
    # Parent process
    print "forked new child process with PID={}".format(child_pid)
    pid_list.append(child_pid)
项目:pyadmin    作者:tso    | 项目源码 | 文件源码
def update(event_user, event_channel, event, slack_client: Client, **kwargs):
    '''
    Pulls from git and reloads the process.
    '''
    if slack_client.admin != event_user:
        slack_client.delete_message(event)

    g = git.cmd.Git('.')
    try:
        g.pull()
    except:
        slack_client.send_message(event_channel, f'Could not git pull.')
        return

    # This will not return. Instead, the process will be immediately replaced.
    os.execl(sys.executable, *([sys.executable] + sys.argv))
项目:black_zone    作者:zh-explorer    | 项目源码 | 文件源码
def dealarm_shell(tube):
    """Given a tube which is a shell, dealarm it.
    """
    tube.clean()

    tube.sendline('which python')
    if tube.recvline().startswith('/'):
        tube.sendline('''exec python -c "import signal, os; signal.alarm(0); os.execl('$SHELL','')"''')
        return tube

    tube.sendline('which perl')
    if tube.recvline().startswith('/'):
        tube.sendline('''exec perl -e "alarm 0; exec '$SHELL'"''')
        return tube

    return None
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_settings(self, button):

        self.main_window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        launch_command = self.install_dir + '/' + self.game_name + '/settings.sh ' + \
        self.install_dir + ' ' + nebula_dir

        os.system(launch_command)

        self.config_save()
        os.execl(sys.executable, 'python', __file__, self.game_name)
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
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, 'python', __file__, self.game_name, self.exe_path)
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def notebook_page_switched(self, notebook, widget, arg):

        # Automatically check for new games (not a good idea)
        #~ if (widget.get_name() == 'goglib_tab') and (self.last_active_tab == 'gogcom_tab'):
            #~ if self.goglib_offline_mode:
                #~ if goglib_authorized:
                    #~ os.execl(sys.executable, sys.executable, *sys.argv)
            #~ else:
                #~ for i in range (self.notebook.get_n_pages()):
                    #~ try:
                        #~ if self.notebook.get_nth_page(i) == self.unauthorized_grid:
                            #~ if goglib_authorized:
                                #~ os.execl(sys.executable, sys.executable, *sys.argv)
                    #~ except:
                        #~ pass
        #~ if (self.last_active_tab == 'gogcom_tab') and goglib_authorized:
            #~ self.check_for_new_games()

        if self.last_active_tab == 'settings_tab':
            self.config_save()

        if widget.get_name() != 'goglib_tab':
            self.button_update_goglib.set_visible(False)
            self.button_online_status.set_visible(False)
        else:
            self.button_online_status.set_visible(True)
            if not self.goglib_offline_mode:
                self.button_update_goglib.set_visible(True)

        self.last_active_tab = widget.get_name()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_get_scripts(self, button):

        lib = button.get_name()

        if lib == 'goglib':
            overwrite = self.checkbutton_goglib_scripts.get_active()
        elif lib == 'mylib':
            overwrite = self.checkbutton_mylib_scripts.get_active()

        self.main_window.hide()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.hide()

        while Gtk.events_pending():
            Gtk.main_iteration()

        mylib_has_new_scripts = os.system('python2 ' + nebula_dir + '/get_scripts.py ' + lib + ' ' + str(overwrite))

        # Ugly but works
        if mylib_has_new_scripts == 0:
            print("No new scripts.")
        else:
            print("New scripts downloaded!")
            os.execl(sys.executable, 'python2', __file__)

        self.main_window.show()
        if len(self.additional_windows_list) != 0:
            for window in self.additional_windows_list:
                window.show()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_online_status(self, button):

        if self.goglib_offline_mode:
            self.goglib_offline_mode_at_start = False
        else:
            self.goglib_offline_mode_at_start = True

        self.config_save()

        os.execl(sys.executable, sys.executable, *sys.argv)
项目:mongoaudit    作者:Exploit-install    | 项目源码 | 文件源码
def key_handler(key):
        if key in ('q', 'Q', 'esc'):
            raise urwid.ExitMainLoop()
        elif key == 'ctrl r':
            python = sys.executable
            os.execl(python, python, *sys.argv)
项目:charm-keystone    作者:openstack    | 项目源码 | 文件源码
def openstack_upgrade():
    """Perform action-managed OpenStack upgrade.

    Upgrades packages to the configured openstack-origin version and sets
    the corresponding action status as a result.

    If the charm was installed from source we cannot upgrade it.
    For backwards compatibility a config flag (action-managed-upgrade) must
    be set for this code to run, otherwise a full service level upgrade will
    fire on config-changed."""

    if (do_action_openstack_upgrade('keystone',
                                    do_openstack_upgrade,
                                    register_configs())):
        os.execl('./hooks/config-changed-postupgrade', '')
项目:charm-keystone    作者:openstack    | 项目源码 | 文件源码
def do_openstack_upgrade_reexec(configs):
    do_openstack_upgrade(configs)
    log("Re-execing hook to pickup upgraded packages", level=INFO)
    os.execl('./hooks/config-changed-postupgrade', '')
项目:charm-keystone    作者:openstack    | 项目源码 | 文件源码
def do_openstack_upgrade_reexec(configs):
    do_openstack_upgrade(configs)
    log("Re-execing hook to pickup upgraded packages", level=INFO)
    os.execl('./hooks/config-changed-postupgrade', '')
项目:PyIDE    作者:raggesilver    | 项目源码 | 文件源码
def openProject(self, *args):
        dialog = Gtk.FileChooserDialog('Select a project folder', self, Gtk.FileChooserAction.SELECT_FOLDER,(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
        response = dialog.run()


        if response == Gtk.ResponseType.OK:
            projectPath = dialog.get_filename()

            os.execl(sys.executable, *([sys.executable]+sys.argv+[projectPath]))

        dialog.destroy()
项目:WeenieBot    作者:Beefywhale    | 项目源码 | 文件源码
def restart_logic(message, client):
    if message.author.id == client.bot_info.owner.id:
        await client.send_message(message.channel, 'Restarting... Please wait 5-10 seconds before trying to run any commands!')
        os.execl(sys.executable,  sys.executable, *sys.argv)
    else:
        await client.send_message(message.channel, 'ERROR you need to be a bot owner!')
项目:WeenieBot    作者:Beefywhale    | 项目源码 | 文件源码
def update_logic(message, client):
    if message.author.id in client.bot_info.owner.id:
        await client.send_message(message.channel, 'Updating...')
        g = git.cmd.Git()
        u = g.pull('-v')
        await client.send_message(message.channel, '```' + str(u) + '```')
        if str(u) == 'Already up-to-date.':
            await client.send_message(message.channel, 'Already Up To Date! Not restarting')
        else:
            await client.send_message(message.channel, 'Update successful restarting!')
            os.execl(sys.executable, sys.executable, *sys.argv)
    else:
        await client.send_message(message.channel, 'Error Didn\'t update maybe you aren\'t an admin?')
项目:Lonabot    作者:LonamiWebs    | 项目源码 | 文件源码
def restart(bot, update):
    if not from_admin(update):
        return

    import os
    import time
    import sys
    update.message.reply_text('Restarting {}…'.format(bot.first_name.title()))
    time.sleep(0.2)
    os.execl(sys.executable, sys.executable, *sys.argv)
项目:mm-randbot    作者:arvego    | 项目源码 | 文件源码
def update_bot(message):
    if not hasattr(update_bot, "check_sure"):
        update_bot.check_sure = True
        return

    my_bot.reply_to(message, "??, ????? ?? ??????????...")
    user_action_log(message, "remotely ran update script.")
    os.execl('/bin/bash', 'bash', 'bot_update.sh')
项目:Taigabot    作者:FrozenPigs    | 项目源码 | 文件源码
def stop(inp, nick=None, conn=None):
    """stop [reason] -- Kills the bot with [reason] as its quit message."""
    if inp:
        conn.cmd("QUIT", ["Killed by {} ({})".format(nick, inp)])
    else:
        conn.cmd("QUIT", ["Killed by {}.".format(nick)])
    time.sleep(5)
    os.execl("./bot", "bot", "stop")
项目:Taigabot    作者:FrozenPigs    | 项目源码 | 文件源码
def restart(inp, nick=None, conn=None, bot=None):
    """restart [reason] -- Restarts the bot with [reason] as its quit message."""
    for botcon in bot.conns:
        if inp:
            bot.conns[botcon].cmd("QUIT", ["Restarted by {} ({})".format(nick, inp)])
        else:
            bot.conns[botcon].cmd("QUIT", ["Restarted by {}.".format(nick)])
    time.sleep(5)
    #os.execl("./bot", "bot", "restart")
    args = sys.argv[:]
    args.insert(0, sys.executable)
    os.execv(sys.executable, args)
项目:Taigabot    作者:FrozenPigs    | 项目源码 | 文件源码
def db_init(db, bot):
    "check to see that our db has the the seen table and return a connection."
    try:
        db.execute("create table if not exists seen(name, time, quote, chan, host, primary key(name, chan))")
    except:
        for botcon in bot.conns:
            bot.conns[botcon].cmd("QUIT", ["Restarted"])
        time.sleep(5)
        #os.execl("./bot", "bot", "restart")
        args = sys.argv[:]
        args.insert(0, sys.executable)
        os.execv(sys.executable, args)
    db.commit()
    db_ready = True
项目:ICO-Moderator    作者:Plenglin    | 项目源码 | 文件源码
def on_private_message(self, msg: discord.Message):
        if re.match(r'restart', msg.content):
            await self.client.send_message(msg.channel, 'Restarting now...')
            await self.client.logout()
            os.execl(sys.executable, sys.executable, *sys.argv)

        elif re.match(r'shutdown', msg.content):
            await self.client.send_message(msg.channel, 'Shutting down...')
            await self.client.logout()
            sys.exit(0)
项目:spider    作者:luxux    | 项目源码 | 文件源码
def restart_program():
    # ????
    python = sys.executable
    os.execl(python, python, * sys.argv)
项目:rexmenu    作者:robmcmullen    | 项目源码 | 文件源码
def restart(self, *extra_args):
        python = sys.executable
        args = [sys.argv[0]]
        for arg in extra_args:
            args.append(str(arg))
        os.execl(python, python, *args)
项目:ProfSnoo    作者:snoonetIRC    | 项目源码 | 文件源码
def restart(prefix, chan, params):

    bot.do('QUIT', ' '.join(params))

    bot.oqueue.join()

    os.execl(sys.executable, sys.executable, * sys.argv)
项目:Arduino_Semi-Tesla    作者:jpdik    | 项目源码 | 文件源码
def restart_program():
    """Restarts the current program.
    Note: this function does not return. Any cleanup action (like
    saving data) must be done before calling this function."""
    python = sys.executable
    os.execl(python, python, * sys.argv)
项目:Arduino_Semi-Tesla    作者:jpdik    | 项目源码 | 文件源码
def restart_program():
    """Restarts the current program.
    Note: this function does not return. Any cleanup action (like
    saving data) must be done before calling this function."""
    python = sys.executable
    os.execl(python, python, * sys.argv)
项目:kitsuchan-2    作者:n303p4    | 项目源码 | 文件源码
def restart(self, ctx):
        """Restart the bot. Bot owner only."""
        message = "Bot is going for restart NOW!"
        logger.warning(message)
        await ctx.send(message)
        await ctx.bot.logout()
        os.execl(sys.executable, sys.executable, *sys.argv)
项目:RaiWalletBot    作者:SergiySW    | 项目源码 | 文件源码
def restart(bot, update):
    bot.sendMessage(update.message.chat_id, "Bot is restarting...")
    sleep(0.2)
    os.execl(sys.executable, sys.executable, *sys.argv)


#@restricted
项目:vidcutter    作者:ozmartian    | 项目源码 | 文件源码
def main():
    if hasattr(Qt, 'AA_EnableHighDpiScaling'):
        QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
    if hasattr(Qt, 'AA_Use96Dpi'):
        QCoreApplication.setAttribute(Qt.AA_Use96Dpi, True)
    if hasattr(Qt, 'AA_ShareOpenGLContexts'):
        QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts, True)

    if sys.platform == 'darwin':
        QApplication.setStyle('Fusion')

    atexit.register(MainWindow.cleanup)

    app = SingleApplication(vidcutter.__appid__, sys.argv)
    app.setApplicationName(vidcutter.__appname__)
    app.setApplicationVersion(vidcutter.__version__)
    app.setOrganizationDomain(vidcutter.__domain__)
    app.setQuitOnLastWindowClosed(True)

    win = MainWindow()
    app.setActivationWindow(win)
    app.messageReceived.connect(win.file_opener)

    exit_code = app.exec_()
    if exit_code == MainWindow.EXIT_CODE_REBOOT:
        if sys.platform == 'win32':
            if hasattr(win.cutter, 'mpvWidget'):
                win.close()
            QProcess.startDetached('"{}"'.format(qApp.applicationFilePath()))
        else:
            os.execl(sys.executable, sys.executable, *sys.argv)
    sys.exit(exit_code)
项目:mal    作者:chaosking121    | 项目源码 | 文件源码
def reboot():
    import os
    import sys
    python = sys.executable
    os.execl(python, python, * sys.argv)
项目:mal    作者:chaosking121    | 项目源码 | 文件源码
def reboot(slackMessage):
####Reboot Mal.
    import os
    import sys
    python = sys.executable
    os.execl(python, python, * sys.argv)
项目:aioworkers    作者:aioworkers    | 项目源码 | 文件源码
def restart(self):
        atexit.register(
            os.execl, sys.executable,
            sys.executable, *sys.argv)
        self.loop.stop()
项目:goldmine    作者:Armored-Dragon    | 项目源码 | 文件源码
def restart(self, ctx):
        """Restarts this bot.
        Usage: restart"""
        echeck_perms(ctx, ('bot_owner',))
        self.bot.store_writer.cancel()
        await self.bot.store.commit()
        if ctx.invoked_with != 'update':
            await ctx.send('I\'ll try to restart. Hopefully I come back alive :stuck_out_tongue:')
        self.logger.info('The bot is now restarting!')
        # self.bot.is_restart = True
        os.execl(sys.executable, sys.executable, *sys.argv)
项目:mongoaudit    作者:stampery    | 项目源码 | 文件源码
def key_handler(key):
        if key in ('q', 'Q', 'esc'):
            raise urwid.ExitMainLoop()
        elif key == 'ctrl r':
            python = sys.executable
            os.execl(python, python, *sys.argv)
项目:nya-chan-bot    作者:OSAlt    | 项目源码 | 文件源码
def restart(self, ctx):
        """Restarts bot."""
        try:
            p = psutil.Process(os.getpid())
            for handler in p.get_open_files() + p.connections():
                os.close(handler.fd)
        except Exception as e:
            pass
        python = sys.executable
        os.execl(python, python, *sys.argv)
项目:homemadescripts    作者:helioloureiro    | 项目源码 | 文件源码
def StartUp():
    debug("Startup")
    if os.path.exists(SCRIPTHOME):
        os.chdir(SCRIPTHOME)
        oscmd = "git pull -f"
        debug(oscmd)
        os.system(oscmd)
        botname = "stallmanbot.py"
        debug(oscmd)
        # For debugging outside of the Raspberry Pi
        # oscmd = "diff -q %s %s/homemadescripts/%s" % (botname, HOME, botname)
        # Original Raspberry Pi command
        oscmd = "diff -q %s %s/bin/%s" % (botname, HOME, botname)
        res = os.system(oscmd)
        if res:
            # new version detected
            res = os.system("%s %s check" % (sys.executable, sys.argv[0]))
            if res != 0:
                debug("Versão bugada")
                sys.exit(os.EX_OSERR)
            debug("Updating bot...")
            shutil.copy(botname, "%s/bin/%s" % (HOME, botname))
            debug("Bot version updated.")
            # check first
            debug("Calling restart")
            python = sys.executable
            os.execl(python, python, *sys.argv)

        # Update the foodporn.json file
        run_foodporn_update()
项目:homemadescripts    作者:helioloureiro    | 项目源码 | 文件源码
def Reload(cmd):
    debug(cmd.text)
    if not cmd.from_user.username == botadm:
        bot.reply_to(cmd, "Só patrão pode isso.")
        return
    try:
        debug(cmd)
        bot.reply_to(cmd, "Reloading...")
        if os.path.exists(SCRIPTHOME):
            os.chdir(SCRIPTHOME)
            oscmd = "git pull -f"
            debug(oscmd)
            os.system(oscmd)
            botname = "stallmanbot.py"
            debug(oscmd)
            oscmd = "diff -q %s %s/bin/%s" % (botname, HOME, botname)
            res = os.system(oscmd)
            if res:
                # new version detected
                res = os.system("%s %s" % (sys.executable, sys.argv[0]))
                if res != 0:
                    debug("Versão bugada")
                    bot.send_message(cmd.chat.id, "Python crashed.  Vou carregar saporra não.  Vai que...")
                    return
                debug("Updating bot...")
                shutil.copy(botname, "%s/bin/%s" % (HOME, botname))
                bot.send_message(cmd.chat.id, "Bot version updated.")
        # check first
        python = sys.executable
        os.execl(python, python, *sys.argv)
    except Exception as e:
        try:
            bot.reply_to(cmd, u"Deu merda... %s" % e)
        except Exception as z:
            print u"%s" % z
项目:specto    作者:mrknow    | 项目源码 | 文件源码
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)
        send_process_created_message()
        return getattr(os, original_name)(path, *args)
    return new_execl
项目:specto    作者:mrknow    | 项目源码 | 文件源码
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)
项目:equlipse    作者:konono    | 项目源码 | 文件源码
def openstack_upgrade():
    """Perform action-managed OpenStack upgrade.

    Upgrades packages to the configured openstack-origin version and sets
    the corresponding action status as a result.

    If the charm was installed from source we cannot upgrade it.
    For backwards compatibility a config flag (action-managed-upgrade) must
    be set for this code to run, otherwise a full service level upgrade will
    fire on config-changed."""

    if (do_action_openstack_upgrade('keystone',
                                    do_openstack_upgrade,
                                    register_configs())):
        os.execl('./hooks/config-changed-postupgrade', '')
项目:equlipse    作者:konono    | 项目源码 | 文件源码
def do_openstack_upgrade_reexec(configs):
    do_openstack_upgrade(configs)
    log("Re-execing hook to pickup upgraded packages", level=INFO)
    os.execl('./hooks/config-changed-postupgrade', '')
项目:equlipse    作者:konono    | 项目源码 | 文件源码
def do_openstack_upgrade_reexec(configs):
    do_openstack_upgrade(configs)
    log("Re-execing hook to pickup upgraded packages", level=INFO)
    os.execl('./hooks/config-changed-postupgrade', '')