python类execl()的实例源码

rexmenu.py 文件源码 项目:rexmenu 作者: robmcmullen 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
admin.py 文件源码 项目:ProfSnoo 作者: snoonetIRC 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def restart(prefix, chan, params):

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

    bot.oqueue.join()

    os.execl(sys.executable, sys.executable, * sys.argv)
app.py 文件源码 项目:Arduino_Semi-Tesla 作者: jpdik 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
servidor.py 文件源码 项目:Arduino_Semi-Tesla 作者: jpdik 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
process.py 文件源码 项目:kitsuchan-2 作者: n303p4 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:RaiWalletBot 作者: SergiySW 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
__main__.py 文件源码 项目:vidcutter 作者: ozmartian 项目源码 文件源码 阅读 66 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:mal 作者: chaosking121 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def reboot():
    import os
    import sys
    python = sys.executable
    os.execl(python, python, * sys.argv)
plugins.py 文件源码 项目:mal 作者: chaosking121 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def reboot(slackMessage):
####Reboot Mal.
    import os
    import sys
    python = sys.executable
    os.execl(python, python, * sys.argv)
updater.py 文件源码 项目:aioworkers 作者: aioworkers 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def restart(self):
        atexit.register(
            os.execl, sys.executable,
            sys.executable, *sys.argv)
        self.loop.stop()
owner.py 文件源码 项目:goldmine 作者: Armored-Dragon 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
__main__.py 文件源码 项目:mongoaudit 作者: stampery 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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)
owner.py 文件源码 项目:nya-chan-bot 作者: OSAlt 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
stallmanbot.py 文件源码 项目:homemadescripts 作者: helioloureiro 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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()
stallmanbot.py 文件源码 项目:homemadescripts 作者: helioloureiro 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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
pydev_monkey.py 文件源码 项目:specto 作者: mrknow 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
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
pydev_monkey.py 文件源码 项目:specto 作者: mrknow 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
openstack_upgrade.py 文件源码 项目:equlipse 作者: konono 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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', '')
keystone_utils.py 文件源码 项目:equlipse 作者: konono 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
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', '')
keystone_utils.py 文件源码 项目:equlipse 作者: konono 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
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', '')


问题


面经


文章

微信
公众号

扫码关注公众号