├── .gitignore ├── LICENSE ├── README.md ├── ipython_anybar.py └── screen_start.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | 55 | # Sphinx documentation 56 | docs/_build/ 57 | 58 | # PyBuilder 59 | target/ 60 | 61 | #Ipython Notebook 62 | .ipynb_checkpoints 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Ermakov Petr 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ipython-anybar 2 | 3 | Now you can see when your cell is performed ;) 4 | 5 | Notification of the end of code execution. 6 | 7 | *If you liked this extension, put a* **star** *this repo* 8 | 9 | ## How to install extension? 10 | 11 | Run in ipython this command: 12 | 13 | ```%install_ext https://raw.githubusercontent.com/ermakovpetr/ipython-anybar/master/ipython_anybar.py``` 14 | 15 | ## How to run extension? 16 | 17 | Run AnyBar 18 | 19 | ```ANYBAR_PORT=1740 open -na AnyBar``` 20 | 21 | Run in ipython two commands: 22 | 23 | ```%load_ext ipython_anybar``` 24 | 25 | and any of these commands 26 | 27 | 1. ```%ipython_anybar_connect``` *default host and port = localhost, 1738* 28 | 2. ```%ipython_anybar_connect [anybar port]``` *default host = localhost* 29 | 3. ```%ipython_anybar_connect [my mac host] [anybar port]``` 30 | 31 | 32 | 33 | ## Requirements 34 | * Python package on computer/server with ipython: **pyAnyBar** 35 | 36 | You can install it: `pip install pyanybar` 37 | 38 | More info this: https://github.com/philipbl/pyAnyBar 39 | 40 | * **For Mac**: **AnyBar** 41 | 42 | You can install it: `brew cask install anybar` 43 | 44 | More info this: https://github.com/tonsky/AnyBar 45 | 46 | * **For Linux with Unity**: see this port https://github.com/limpbrains/somebar 47 | 48 | ## Enjoy 49 | 50 | *Write your suggestions for improvement and bug reports in this repo* 51 | -------------------------------------------------------------------------------- /ipython_anybar.py: -------------------------------------------------------------------------------- 1 | from anybar import AnyBar 2 | from IPython.core.magic import register_line_magic 3 | 4 | 5 | class LineWatcher(object): 6 | 7 | def __init__(self): 8 | self.start_flag = False 9 | self.anybar = None 10 | 11 | def connect(self, host='localhost', port='1738'): 12 | if self.anybar: 13 | self.anybar.change('green') 14 | self.anybar = AnyBar(port=int(port), address=host) 15 | print('Connect to {host}:{port}'.format(host=host, port=int(port))) 16 | 17 | def start(self): 18 | self.start_flag = True 19 | if self.anybar: 20 | self.anybar.change('red') 21 | 22 | def stop(self): 23 | if self.start_flag: 24 | self.start_flag = False 25 | if self.anybar: 26 | self.anybar.change('green') 27 | 28 | 29 | antbar_watcher = None 30 | 31 | 32 | def load_ipython_extension(ip): 33 | global antbar_watcher 34 | antbar_watcher = LineWatcher() 35 | ip.events.register('pre_run_cell', antbar_watcher.start) 36 | ip.events.register('post_run_cell', antbar_watcher.stop) 37 | 38 | 39 | def unload_ipython_extension(ip): 40 | ip.events.unregister('pre_run_cell', antbar_watcher.start) 41 | ip.events.unregister('post_run_cell', antbar_watcher.stop) 42 | if antbar_watcher: 43 | del antbar_watcher 44 | 45 | 46 | @register_line_magic 47 | def ipython_anybar_connect(line): 48 | parametrs = line.strip().split() 49 | if len(parametrs) == 2: 50 | antbar_watcher.connect(*parametrs) 51 | elif len(parametrs) == 1: 52 | antbar_watcher.connect(port=parametrs[0]) 53 | else: 54 | antbar_watcher.connect() 55 | -------------------------------------------------------------------------------- /screen_start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ermakovpetr/ipython-anybar/977e9edab411a01b4d5e9488c9dd3ab9b2ff6b95/screen_start.png --------------------------------------------------------------------------------