notify when execution/command is completed

旧巷老猫 提交于 2019-12-21 03:41:09

问题


How do I get IPython to notify me when a command has been executed? Can I get it to use the bell/alert, or by pop-up? I'm running Anaconda on iTerm on OS X 10.8.5.


回答1:


With the newest version of iTerm, you can use the alert on next mark functionality of the shell integration.




回答2:


Finally someone created a nice library for it.

You just install it:

pip install jupyternotify

Import it in your notebook:

import jupyternotify
ip = get_ipython()
ip.register_magics(jupyternotify.JupyterNotifyMagics)

and use a magic command:

%%notify
import time
time.sleep(5)

and get a nice notification:

Git-page also shows how to load it automatically.




回答3:


Are you using IPython Notebook, or IPython from the terminal? If you are using IPython Notebook, I suggest using the notify extension available from https://github.com/sjpfenninger/ipython-extensions (write up available here)




回答4:


As an alternative, I wrote a simple module/decorator function to notify on function completed (works only on MAC)

Example:

from ipynotifyer import notifyOnComplete as nf


@nf()
def divide_by_five():
    return 5/5

@nf(timer=True)
def divide_by_ten():
    return 5/10

https://github.com/Casyfill/ipython_notifier




回答5:


Recent versions of iTerm send notifications to notification center when there is output in a non-visible tab. They fold into notification center by default, but you can change them to stay on the screen in the Notifications preferences in System Preferences.



来源:https://stackoverflow.com/questions/22004386/notify-when-execution-command-is-completed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!