##// END OF EJS Templates
Move crash handling to the application level and simplify class structure....
Move crash handling to the application level and simplify class structure. Starting to try to take real advantage of the refactoring, to have generic crash handling. This also lets us initialize the app without needing all the self.attempt() wrappers, since now there's a good system-wide crash handler at the app level (not inside the shell instance). I didn't yet remove the attempt() method because we may have occasional uses for it (we still do, but in one place only). I also removed some extra class layers that weren't quite needed. Creating classes solely for the purpose of passing parameters makes the code (IMO) harder to understand, I kept getting lost in parts of the class hierarchy. I think these changes provide the same flexibility but with easier to follow code (less things to remember, basically). What I tried to do was to use argument passing instead of inheritance for all cases I saw where the inheritance wasn't really adding new functionality. In some cases, this actually allowed me to remove methods that were effectively duplicated in the subclasses.

File last commit:

r2156:ed44a843 merge
r2403:08d6ac78
Show More
ipython_win_post_install.py
98 lines | 3.0 KiB | text/x-python | PythonLexer
/ scripts / ipython_win_post_install.py
#!python
"""Windows-specific part of the installation"""
import os, sys, shutil
pjoin = os.path.join
def mkshortcut(target,description,link_file,*args,**kw):
"""make a shortcut if it doesn't exist, and register its creation"""
create_shortcut(target, description, link_file,*args,**kw)
file_created(link_file)
def install():
"""Routine to be run by the win32 installer with the -install switch."""
from IPython.core.release import version
# Get some system constants
prefix = sys.prefix
python = pjoin(prefix, 'python.exe')
# Lookup path to common startmenu ...
ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'), 'IPython')
# Create IPython entry ...
if not os.path.isdir(ip_start_menu):
os.mkdir(ip_start_menu)
directory_created(ip_start_menu)
# Create .py and .bat files to make things available from
# the Windows command line. Thanks to the Twisted project
# for this logic!
programs = [
'ipython',
'iptest',
'ipcontroller',
'ipengine',
'ipcluster',
'ipythonx',
'ipython-wx',
'irunner'
]
scripts = pjoin(prefix,'scripts')
for program in programs:
raw = pjoin(scripts, program)
bat = raw + '.bat'
py = raw + '.py'
# Create .py versions of the scripts
shutil.copy(raw, py)
# Create .bat files for each of the scripts
bat_file = file(bat,'w')
bat_file.write("@%s %s %%*" % (python, py))
bat_file.close()
# Now move onto setting the Start Menu up
ipybase = pjoin(scripts, 'ipython')
link = pjoin(ip_start_menu, 'IPython.lnk')
cmd = '"%s"' % ipybase
mkshortcut(python,'IPython',link,cmd)
link = pjoin(ip_start_menu, 'pysh.lnk')
cmd = '"%s" -p sh' % ipybase
mkshortcut(python,'IPython (command prompt mode)',link,cmd)
link = pjoin(ip_start_menu, 'scipy.lnk')
cmd = '"%s" -p scipy' % ipybase
mkshortcut(python,'IPython (scipy profile)',link,cmd)
link = pjoin(ip_start_menu, 'ipcontroller.lnk')
cmd = '"%s" -xy' % pjoin(scripts, 'ipcontroller')
mkshortcut(python,'IPython controller',link,cmd)
link = pjoin(ip_start_menu, 'ipengine.lnk')
cmd = '"%s"' % pjoin(scripts, 'ipengine')
mkshortcut(python,'IPython engine',link,cmd)
# Create documentation shortcuts ...
t = prefix + r'\share\doc\ipython\manual\ipython.pdf'
f = ip_start_menu + r'\Manual in PDF.lnk'
mkshortcut(t,r'IPython Manual - PDF-Format',f)
t = prefix + r'\share\doc\ipython\manual\html\index.html'
f = ip_start_menu + r'\Manual in HTML.lnk'
mkshortcut(t,'IPython Manual - HTML-Format',f)
def remove():
"""Routine to be run by the win32 installer with the -remove switch."""
pass
# main()
if len(sys.argv) > 1:
if sys.argv[1] == '-install':
install()
elif sys.argv[1] == '-remove':
remove()
else:
print "Script was called with option %s" % sys.argv[1]