##// END OF EJS Templates
Start webbrowser in a thread. Prevents lockup with Chrome....
Start webbrowser in a thread. Prevents lockup with Chrome. If a user has Chrome set as their default browser (system-wide or via the `BROWSER` environment variable), opening the notebook hangs because the chrome call doesn't return immediately. This solves the issue by opening the browser in a thread. Note that there remains an issue where killing the notebook will kill Chrome if the Chrome session was started by us. I haven't found a way to work around that despite attempts by making the webbrowser.open() call in a subprocess.

File last commit:

r4574:a8c54759
r5212:2178365f
Show More
ipy_gnuglobal.py
35 lines | 867 B | text/x-python | PythonLexer
"""
Add %global magic for GNU Global usage.
http://www.gnu.org/software/global/
"""
from IPython.core import ipapi
ip = ipapi.get()
import os
# alter to your liking
global_bin = 'd:/opt/global/bin/global'
def global_f(self,cmdline):
simple = 0
if '-' not in cmdline:
cmdline = '-rx ' + cmdline
simple = 1
lines = [l.rstrip() for l in os.popen( global_bin + ' ' + cmdline ).readlines()]
if simple:
parts = [l.split(None,3) for l in lines]
lines = ['%s [%s]\n%s' % (p[2].rjust(70),p[1],p[3].rstrip()) for p in parts]
print "\n".join(lines)
ip.define_magic('global', global_f)
def global_completer(self,event):
compl = [l.rstrip() for l in os.popen(global_bin + ' -c ' + event.symbol).readlines()]
return compl
ip.set_hook('complete_command', global_completer, str_key = '%global')