@@ -0,0 +1,1457 @@
+from anybar import AnyBar%0Afrom IPython.core.magic import register_line_magic%0A%0A%0Aclass LineWatcher(object):%0A%0A    def __init__(self):%0A        self.start_flag = False%0A        self.anybar = None%0A%0A    def connect(self, host='localhost', port='1738'):%0A        if self.anybar:%0A            self.anybar.change('green')%0A        self.anybar = AnyBar(port=int(port), address=host)%0A        print('Connect to %7Bhost%7D:%7Bport%7D'.format(host=host, port=int(port)))%0A%0A    def start(self):%0A        self.start_flag = True%0A        if self.anybar:%0A            self.anybar.change('red')%0A%0A    def stop(self):%0A        if self.start_flag:%0A            self.start_flag = False%0A            if self.anybar:%0A                self.anybar.change('green')%0A%0A%0Aantbar_watcher = None%0A%0A%0Adef load_ipython_extension(ip):%0A    global antbar_watcher%0A    antbar_watcher = LineWatcher()%0A    ip.events.register('pre_run_cell', antbar_watcher.start)%0A    ip.events.register('post_run_cell', antbar_watcher.stop)%0A%0A%0Adef unload_ipython_extension(ip):%0A    ip.events.unregister('pre_run_cell', antbar_watcher.start)%0A    ip.events.unregister('post_run_cell', antbar_watcher.stop)%0A    if antbar_watcher:%0A        del antbar_watcher%0A%0A%0A@register_line_magic%0Adef ipython_anybar_connect(line):%0A    parametrs = line.strip().split()%0A    if len(parametrs) == 2:%0A        antbar_watcher.connect(*parametrs)%0A    elif len(parametrs) == 1:%0A        antbar_watcher.connect(port=parametrs%5B0%5D)%0A    else:%0A        antbar_watcher.connect()%0A

Create ipython_anybar_ext.py