diff -Naurb ./IPython/ColorANSI.py ../ipython-0.10.2_patched/IPython/ColorANSI.py --- ./IPython/ColorANSI.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/ColorANSI.py 2011-09-22 19:50:17.231558715 -0400 @@ -14,6 +14,7 @@ import os from IPython.ipstruct import Struct +from IPython.genutils import os_name def make_color_table(in_class): """Build a set of color attributes in a class. @@ -87,7 +88,7 @@ NoColor = '' # for color schemes in color-less terminals. - if os.name == 'nt' and os.environ.get('TERM','dumb') == 'emacs': + if (os_name() == 'nt' and os.environ.get('TERM','dumb') == 'emacs') or os.name == 'java': # (X)emacs on W32 gets confused with \001 and \002 so we remove them Normal = '\033[0m' # Reset normal coloring _base = '\033[%sm' # Template for all other colors diff -Naurb ./IPython/completer.py ../ipython-0.10.2_patched/IPython/completer.py --- ./IPython/completer.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/completer.py 2011-09-22 19:32:10.966261453 -0400 @@ -70,6 +70,7 @@ import re import shlex import sys +from IPython.genutils import sys_platform import IPython.rlineimpl as readline import itertools from IPython.ipstruct import Struct @@ -256,7 +257,7 @@ self.dumb_terminal = term in ['dumb','emacs'] # Special handling of backslashes needed in win32 platforms - if sys.platform == "win32": + if sys_platform() == "win32": self.clean_glob = self._clean_glob_win32 else: self.clean_glob = self._clean_glob @@ -313,7 +314,7 @@ # don't want to treat as delimiters in filename matching # when escaped with backslash - if sys.platform == 'win32': + if sys_platform() == 'win32': protectables = ' ' else: protectables = ' ()' diff -Naurb ./IPython/ConfigLoader.py ../ipython-0.10.2_patched/IPython/ConfigLoader.py --- ./IPython/ConfigLoader.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/ConfigLoader.py 2011-09-22 18:32:01.715857190 -0400 @@ -81,7 +81,7 @@ try: incfile = filefind(incfilename,incpath) except IOError: - if os.name in ['nt','dos']: + if os_name() in ['nt','dos']: try: # Try again with '.ini' extension incfilename += '.ini' diff -Naurb ./IPython/CrashHandler.py ../ipython-0.10.2_patched/IPython/CrashHandler.py --- ./IPython/CrashHandler.py 2011-03-13 00:05:53.000000000 -0500 +++ ../ipython-0.10.2_patched/IPython/CrashHandler.py 2011-09-22 19:09:46.914125485 -0400 @@ -168,8 +168,8 @@ rpt_add('*'*75+'\n\n'+'IPython post-mortem report\n\n') rpt_add('IPython version: %s \n\n' % Release.version) - rpt_add('Platform info : os.name -> %s, sys.platform -> %s' % - (os.name,sys.platform) ) + rpt_add('Platform info : os_name -> %s, sys.platform -> %s' % + (os_name(),sys.platform) ) rpt_add(sec_sep+'Current user configuration structure:\n\n') rpt_add(pformat(self.IP.rc.dict())) rpt_add(sec_sep+'Crash traceback:\n\n' + traceback) @@ -211,8 +211,8 @@ rpt_add('*'*75+'\n\n'+'IPython post-mortem report\n\n') rpt_add('IPython version: %s \n\n' % Release.version) - rpt_add('Platform info : os.name -> %s, sys.platform -> %s' % - (os.name,sys.platform) ) + rpt_add('Platform info : os_name -> %s, sys.platform -> %s' % + (os_name(),sys.platform) ) rpt_add(sec_sep+'Current user configuration structure:\n\n') rpt_add(pformat(self.IP.rc.dict())) rpt_add(sec_sep+'Crash traceback:\n\n' + traceback) diff -Naurb ./IPython/Extensions/ipipe.py ../ipython-0.10.2_patched/IPython/Extensions/ipipe.py --- ./IPython/Extensions/ipipe.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/Extensions/ipipe.py 2011-09-22 19:32:10.946260973 -0400 @@ -86,6 +86,7 @@ skip_doctest = True # ignore top-level docstring as a doctest. import sys, os, os.path, stat, glob, new, csv, datetime, types +from IPython.genutils import sys_platform import itertools, mimetypes, StringIO try: # Python 2.3 compatibility @@ -1121,7 +1122,7 @@ def __repr__(self): return "ifile(%s)" % path._base.__repr__(self) - if sys.platform == "win32": + if sys_platform() == "win32": defaultattrs = (None, "type", "size", "modestr", "mdate") else: defaultattrs = (None, "type", "size", "modestr", "owner", "group", "mdate") diff -Naurb ./IPython/Extensions/ipy_profile_sh.py ../ipython-0.10.2_patched/IPython/Extensions/ipy_profile_sh.py --- ./IPython/Extensions/ipy_profile_sh.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/Extensions/ipy_profile_sh.py 2011-09-22 19:32:10.976261693 -0400 @@ -9,6 +9,7 @@ from IPython import ipapi import os,re,textwrap +from IPython.genutils import os_name, sys_platform # The import below effectively obsoletes your old-style ipythonrc[.ini], # so consider yourself warned! @@ -96,7 +97,7 @@ syscmds = db.get("syscmdlist") # lowcase aliases on win32 only - if os.name == 'posix': + if os_name() == 'posix': mapper = lambda s:s else: def mapper(s): return s.lower() @@ -118,7 +119,7 @@ ip.load("IPython.external.mglob") # win32 is crippled w/o cygwin, try to help it a little bit - if sys.platform == 'win32': + if sys_platform() == 'win32': if 'cygwin' in os.environ['PATH'].lower(): # use the colors of cygwin ls (recommended) ip.defalias('d', 'ls -F --color=auto') diff -Naurb ./IPython/Extensions/ipy_rehashdir.py ../ipython-0.10.2_patched/IPython/Extensions/ipy_rehashdir.py --- ./IPython/Extensions/ipy_rehashdir.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/Extensions/ipy_rehashdir.py 2011-09-22 18:32:01.715857190 -0400 @@ -20,6 +20,7 @@ import os,re,fnmatch,sys +from IPython.genutils import os_name def selflaunch(ip,line): """ Launch python script with 'this' interpreter @@ -90,7 +91,7 @@ path = map(os.path.abspath,arg.split(';')) alias_table = self.shell.alias_table - if os.name == 'posix': + if os_name() == 'posix': isexec = lambda fname:os.path.isfile(fname) and \ os.access(fname,os.X_OK) else: @@ -108,7 +109,7 @@ try: # write the whole loop for posix/Windows so we don't have an if in # the innermost part - if os.name == 'posix': + if os_name() == 'posix': for pdir in path: os.chdir(pdir) for ff in os.listdir(pdir): diff -Naurb ./IPython/Extensions/ipy_signals.py ../ipython-0.10.2_patched/IPython/Extensions/ipy_signals.py --- ./IPython/Extensions/ipy_signals.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/Extensions/ipy_signals.py 2011-09-22 19:32:10.926260493 -0400 @@ -10,6 +10,7 @@ """ import signal,os,sys +from IPython.genutils import sys_platform import IPython.ipapi import subprocess @@ -55,8 +56,7 @@ o.allow_new_attr (True ) o.verbose = 0 - ip.IP.system = (sys.platform == 'win32' and new_ipsystem_win32 or + ip.IP.system = (sys_platform() == 'win32' and new_ipsystem_win32 or new_ipsystem_posix) init() - \ No newline at end of file diff -Naurb ./IPython/Extensions/jobctrl.py ../ipython-0.10.2_patched/IPython/Extensions/jobctrl.py --- ./IPython/Extensions/jobctrl.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/Extensions/jobctrl.py 2011-09-22 19:32:10.976261693 -0400 @@ -49,7 +49,7 @@ import IPython.ipapi -if os.name == 'nt': +if genutils.os_name() == 'nt': def kill_process(pid): os.system('taskkill /F /PID %d' % pid) else: @@ -188,7 +188,7 @@ except ValueError: magic_tasks(self,line) -if sys.platform == 'win32': +if genutils.sys_platform() == 'win32': shell_internal_commands = 'break chcp cls copy ctty date del erase dir md mkdir path prompt rd rmdir start time type ver vol'.split() PopenExc = WindowsError else: diff -Naurb ./IPython/external/path.py ../ipython-0.10.2_patched/IPython/external/path.py --- ./IPython/external/path.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/external/path.py 2011-09-22 18:32:01.715857190 -0400 @@ -30,6 +30,7 @@ from __future__ import generators import sys, warnings, os, fnmatch, glob, shutil, codecs +from IPython.genutils import os_name # deprecated in python 2.6 warnings.filterwarnings('ignore', r'.*md5.*') import md5 @@ -38,7 +39,7 @@ __all__ = ['path'] # Platform-specific support for path.owner -if os.name == 'nt': +if os_name() == 'nt': try: import win32security except ImportError: @@ -836,7 +837,7 @@ On Windows, this returns a name of the form ur'DOMAIN\User Name'. On Windows, a group can own a file or directory. """ - if os.name == 'nt': + if os_name() == 'nt': if win32security is None: raise Exception("path.owner requires win32all to be installed") desc = win32security.GetFileSecurity( diff -Naurb ./IPython/frontend/prefilterfrontend.py ../ipython-0.10.2_patched/IPython/frontend/prefilterfrontend.py --- ./IPython/frontend/prefilterfrontend.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/frontend/prefilterfrontend.py 2011-09-22 19:32:11.006262415 -0400 @@ -22,6 +22,7 @@ # Imports #------------------------------------------------------------------------------- import sys +from IPython.genutils import sys_platform import pydoc import os import re @@ -118,7 +119,7 @@ self._ip.system = self.system_call # XXX: Muck around with magics so that they work better # in our environment - if not sys.platform.startswith('win'): + if not sys_platform().startswith('win'): self.ipython0.magic_ls = mk_system_call(self.system_call, 'ls -CF') # And now clean up the mess created by ipython0 diff -Naurb ./IPython/frontend/process/killableprocess.py ../ipython-0.10.2_patched/IPython/frontend/process/killableprocess.py --- ./IPython/frontend/process/killableprocess.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/frontend/process/killableprocess.py 2011-09-22 19:32:10.956261213 -0400 @@ -49,6 +49,7 @@ import subprocess from subprocess import PIPE import sys +from IPython.genutils import sys_platform import os import types @@ -66,7 +67,7 @@ def __str__(self): return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode) -mswindows = (sys.platform == "win32") +mswindows = (sys_platform() == "win32") skip = False diff -Naurb ./IPython/frontend/wx/console_widget.py ../ipython-0.10.2_patched/IPython/frontend/wx/console_widget.py --- ./IPython/frontend/wx/console_widget.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/frontend/wx/console_widget.py 2011-09-22 19:32:10.966261453 -0400 @@ -25,10 +25,11 @@ from wx.py import editwindow import time import sys +from IPython.genutils import sys_platform import string LINESEP = '\n' -if sys.platform == 'win32': +if sys_platform() == 'win32': LINESEP = '\n\r' import re @@ -43,7 +44,7 @@ _INPUT_MARKER = 29 _DEFAULT_SIZE = 10 -if sys.platform == 'darwin': +if sys_platform() == 'darwin': _DEFAULT_SIZE = 12 _DEFAULT_STYLE = { @@ -239,7 +240,7 @@ if refresh: current_time = time.time() if current_time - self._last_refresh_time > 0.03: - if sys.platform == 'win32': + if sys_platform() == 'win32': wx.SafeYield() else: wx.Yield() diff -Naurb ./IPython/frontend/wx/wx_frontend.py ../ipython-0.10.2_patched/IPython/frontend/wx/wx_frontend.py --- ./IPython/frontend/wx/wx_frontend.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/frontend/wx/wx_frontend.py 2011-09-22 19:32:10.996262174 -0400 @@ -26,6 +26,7 @@ import re import __builtin__ import sys +from IPython.genutils import sys_platform from threading import Lock import wx @@ -528,7 +529,7 @@ # Under windows scintilla seems to be doing funny # stuff to the line returns here, but the getter for # input_buffer filters this out. - if sys.platform == 'win32': + if sys_platform() == 'win32': self.input_buffer = self.input_buffer old_prompt_num = self.current_prompt_pos has_executed = PrefilterFrontEnd._on_enter(self, @@ -573,7 +574,7 @@ if not self._input_state in ('readline', 'raw_input'): return end_line = self.GetCurrentLine() - if not sys.platform == 'win32': + if not sys_platform() == 'win32': end_line += 1 for i in range(self.current_prompt_line, end_line): if i in self._markers: diff -Naurb ./IPython/genutils.py ../ipython-0.10.2_patched/IPython/genutils.py --- ./IPython/genutils.py 2011-03-13 00:58:51.000000000 -0500 +++ ../ipython-0.10.2_patched/IPython/genutils.py 2011-09-22 19:32:11.016262656 -0400 @@ -20,13 +20,38 @@ import doctest except ImportError: pass + import os +# workaround for os.name and jython +def os_name(): + if os.name == 'java': + return os._name + else: + return os.name + import platform import re import shlex import shutil import subprocess + import sys +# workaround for sys.platform and jython +def sys_platform(): + if 'java' in sys.platform.lower(): + import java.lang.System + j_os_name = java.lang.System.getProperty('os.name').lower() + if 'win' in j_os_name: + return 'win32' + elif 'linux' in j_os_name: + return 'linux2' + elif 'mac' in j_os_name: + return 'darwin' + else: + return os_name() + else: + return sys.platform + import tempfile import time import types @@ -44,6 +69,7 @@ # Curses on Solaris may not be complete, so we can't use it there USE_CURSES = hasattr(curses,'initscr') + # Other IPython utilities import IPython from IPython.Itpl import Itpl,itpl,printpl @@ -51,7 +77,8 @@ from IPython.generics import result_display import IPython.ipapi from IPython.external.path import path -if os.name == "nt": + +if os_name() == "nt": from IPython.winconsole import get_console_size try: @@ -113,7 +140,7 @@ import IPython.rlineimpl as readline # Remake Term to use the readline i/o facilities -if sys.platform == 'win32' and readline.have_readline: +if sys_platform() == 'win32' and readline.have_readline: Term = IOTerm(cout=readline._outputfile,cerr=readline._outputfile) @@ -323,7 +350,7 @@ cwd = os.getcwd().replace('\\','/') drivepart = '' tail = cwd - if sys.platform == 'win32': + if sys_platform() == 'win32': if len(cwd) < 4: return cwd drivepart,tail = os.path.splitdrive(cwd) @@ -368,7 +395,7 @@ platutils.set_term_title("IPy " + abbrev_cwd()) # override shell() for win32 to deal with network shares -if os.name in ('nt','dos'): +if os_name() in ('nt','dos'): shell_ori = shell @@ -938,7 +965,7 @@ raise KeyError return homedir.decode(sys.getfilesystemencoding()) except KeyError: - if os.name == 'posix': + if os_name() == 'posix': # Last-ditch attempt at finding a suitable $HOME, on systems where # it may not be defined in the environment but the system shell # still knows it - reported once as: @@ -950,7 +977,7 @@ return homedir.decode(sys.getfilesystemencoding()) else: raise HomeDirError('Undefined $HOME, IPython cannot proceed.') - elif os.name == 'nt': + elif os_name() == 'nt': # For some strange reason, win9x returns 'nt' for os.name. try: homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH']) @@ -979,7 +1006,7 @@ raise except: return 'C:\\' - elif os.name == 'dos': + elif os_name() == 'dos': # Desperate, may do absurd things in classic MacOS. May work under DOS. return 'C:\\' else: @@ -992,7 +1019,7 @@ This uses the logic in `get_home_dir` to find the home directory and the adds either .ipython or _ipython to the end of the path. """ - if os.name == 'posix': + if os_name() == 'posix': ipdir_def = '.ipython' else: ipdir_def = '_ipython' @@ -1506,7 +1533,7 @@ backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'} - bak_filename = filename + backup_suffixes[os.name] + bak_filename = filename + backup_suffixes[os_name()] original = open(filename).read() shutil.copy2(filename,bak_filename) @@ -1529,9 +1556,9 @@ Makes some attempts at finding an OS-correct one.""" - if os.name == 'posix': + if os_name() == 'posix': default_pager_cmd = 'less -r' # -r for color control sequences - elif os.name in ['nt','dos']: + elif os_name() in ['nt','dos']: default_pager_cmd = 'type' if pager_cmd is None: @@ -1559,7 +1586,7 @@ #---------------------------------------------------------------------------- # (X)emacs on W32 doesn't like to be bypassed with msvcrt.getch() -if os.name == 'nt' and os.environ.get('TERM','dumb') != 'emacs': +if os_name() == 'nt' and os.environ.get('TERM','dumb') != 'emacs': import msvcrt def page_more(): """ Smart pausing between pages @@ -1643,7 +1670,7 @@ # Ugly kludge, but calling curses.initscr() flat out crashes in emacs TERM = os.environ.get('TERM','dumb') - if TERM in ['dumb','emacs'] and os.name != 'nt': + if TERM in ['dumb','emacs'] and os_name() != 'nt': print strng return # chop off the topmost part of the string we don't want to see @@ -1657,14 +1684,14 @@ # terminals. If someone later feels like refining it, it's not hard. numlines = max(num_newlines,int(len_str/80)+1) - if os.name == "nt": + if os_name() == "nt": screen_lines_def = get_console_size(defaulty=25)[1] else: screen_lines_def = 25 # default value if we can't auto-determine # auto-determine screen size if screen_lines <= 0: - if (TERM=='xterm' or TERM=='xterm-color') and sys.platform != 'sunos5': + if (TERM=='xterm' or TERM=='xterm-color') and sys_platform() != 'sunos5': use_curses = USE_CURSES else: # curses causes problems on many terminals other than xterm. @@ -1701,7 +1728,7 @@ # sets retval to 1, at the end we resort to our own page_dumb() pager. pager_cmd = get_pager_cmd(pager_cmd) pager_cmd += ' ' + get_pager_start(pager_cmd,start) - if os.name == 'nt': + if os_name() == 'nt': if pager_cmd.startswith('type'): # The default WinXP 'type' command is failing on complex strings. retval = 1 diff -Naurb ./IPython/Gnuplot2.py ../ipython-0.10.2_patched/IPython/Gnuplot2.py --- ./IPython/Gnuplot2.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/Gnuplot2.py 2011-09-22 18:32:01.705857046 -0400 @@ -25,7 +25,7 @@ import Gnuplot as Gnuplot_ori import Numeric -from IPython.genutils import popkey,xsys +from IPython.genutils import popkey,xsys,os_name # needed by hardcopy(): gp = Gnuplot_ori.gp @@ -330,7 +330,7 @@ # set null output so nothing goes to screen. hardcopy() restores output self('set term dumb') # I don't know how to prevent screen output in Windows - if os.name == 'posix': + if os_name() == 'posix': self('set output "/dev/null"') new_items = zip_items(items,titles) diff -Naurb ./IPython/GnuplotRuntime.py ../ipython-0.10.2_patched/IPython/GnuplotRuntime.py --- ./IPython/GnuplotRuntime.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/GnuplotRuntime.py 2011-09-22 19:32:11.026262896 -0400 @@ -53,7 +53,7 @@ 'pm3d_config','eps_fix_bbox'] import os,tempfile,sys -from IPython.genutils import getoutput +from IPython.genutils import getoutput,os_name,sys_platform #--------------------------------------------------------------------------- # Notes on mouse support for Gnuplot.py @@ -89,7 +89,7 @@ del tmpname,gnu_out # Default state for persistence of new gnuplot instances -if os.name in ['nt','dos'] or sys.platform == 'cygwin': +if os_name() in ['nt','dos'] or sys_platform() == 'cygwin': gnuplot_persist = 0 else: gnuplot_persist = 1 diff -Naurb ./IPython/hooks.py ../ipython-0.10.2_patched/IPython/hooks.py --- ./IPython/hooks.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/hooks.py 2011-09-22 19:32:10.906260013 -0400 @@ -45,6 +45,7 @@ import os,bisect import sys +from IPython.genutils import sys_platform from genutils import Term,shell from pprint import PrettyPrinter @@ -251,9 +252,9 @@ """ from IPython.clipboard import (osx_clipboard_get, tkinter_clipboard_get, win32_clipboard_get) - if sys.platform == 'win32': + if sys_platform() == 'win32': chain = [win32_clipboard_get, tkinter_clipboard_get] - elif sys.platform == 'darwin': + elif sys_platform() == 'darwin': chain = [osx_clipboard_get, tkinter_clipboard_get] else: chain = [tkinter_clipboard_get] diff -Naurb ./IPython/iplib.py ../ipython-0.10.2_patched/IPython/iplib.py --- ./IPython/iplib.py 2011-03-13 00:17:17.000000000 -0500 +++ ../ipython-0.10.2_patched/IPython/iplib.py 2011-09-22 19:32:10.916260253 -0400 @@ -194,7 +194,7 @@ warn(warning) wait() - if sys.platform =='win32': + if sys_platform() =='win32': inif = 'ipythonrc.ini' else: inif = 'ipythonrc' @@ -745,7 +745,7 @@ # Make some aliases automatically # Prepare list of shell aliases to auto-define - if os.name == 'posix': + if os_name() == 'posix': auto_alias = ('mkdir mkdir', 'rmdir rmdir', 'mv mv -i','rm rm -i','cp cp -i', 'cat cat','less less','clear clear', @@ -768,7 +768,7 @@ ) # The BSDs don't ship GNU ls, so they don't understand the # --color switch out of the box - if 'bsd' in sys.platform: + if 'bsd' in sys_platform(): ls_extra = ( # ls normal files only 'lf ls -lF | grep ^-', # ls symbolic links @@ -779,7 +779,7 @@ 'lx ls -lF | grep ^-..x', ) auto_alias = auto_alias + ls_extra - elif os.name in ['nt','dos']: + elif os_name() in ['nt','dos']: auto_alias = ('ls dir /on', 'ddir dir /ad /on', 'ldir dir /ad /on', 'mkdir mkdir','rmdir rmdir','echo echo', @@ -1297,7 +1297,7 @@ If called with no arguments, it acts as a toggle.""" if not self.has_readline: - if os.name == 'posix': + if os_name() == 'posix': warn("The auto-indent feature requires the readline library") self.autoindent = 0 return @@ -1443,7 +1443,7 @@ self.strdispatchers['complete_command'] = sdisp self.Completer.custom_completers = sdisp # Platform-specific configuration - if os.name == 'nt': + if os_name() == 'nt': self.readline_startup_hook = readline.set_pre_input_hook else: self.readline_startup_hook = readline.set_startup_hook @@ -2828,7 +2828,7 @@ print >> sys.stderr, badline else: # regular file execution try: - if sys.platform == 'win32' and sys.version_info < (2,5,1): + if sys_platform() == 'win32' and sys.version_info < (2,5,1): # Work around a bug in Python for Windows. The bug was # fixed in in Python 2.5 r54159 and 54158, but that's still # SVN Python as of March/07. For details, see: diff -Naurb ./IPython/ipmaker.py ../ipython-0.10.2_patched/IPython/ipmaker.py --- ./IPython/ipmaker.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/ipmaker.py 2011-09-22 18:32:01.705857046 -0400 @@ -127,7 +127,7 @@ IP.usage = interactive_usage # Platform-dependent suffix. - if os.name == 'posix': + if os_name() == 'posix': rc_suffix = '' else: rc_suffix = '.ini' @@ -539,7 +539,7 @@ try: ed = os.environ['EDITOR'] except KeyError: - if os.name == 'posix': + if os_name() == 'posix': ed = 'vi' # the only one guaranteed to be there! else: ed = 'notepad' # same in Windows! diff -Naurb ./IPython/kernel/core/prompts.py ../ipython-0.10.2_patched/IPython/kernel/core/prompts.py --- ./IPython/kernel/core/prompts.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/kernel/core/prompts.py 2011-09-22 18:32:01.705857046 -0400 @@ -108,7 +108,7 @@ USER = os.environ.get("USER") HOSTNAME = socket.gethostname() HOSTNAME_SHORT = HOSTNAME.split(".")[0] -ROOT_SYMBOL = "$#"[os.name=='nt' or os.getuid()==0] +ROOT_SYMBOL = "$#"[os_name()=='nt' or os.getuid()==0] prompt_specials_color = { # Prompt/history count diff -Naurb ./IPython/kernel/core/util.py ../ipython-0.10.2_patched/IPython/kernel/core/util.py --- ./IPython/kernel/core/util.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/kernel/core/util.py 2011-09-22 18:32:01.705857046 -0400 @@ -14,6 +14,7 @@ #------------------------------------------------------------------------------- import os +from IPython.genutils import os_name import sys @@ -131,7 +132,7 @@ os.system(cmd) # Override shell() for win32 to deal with network shares. -if os.name in ('nt', 'dos'): +if os_name() in ('nt', 'dos'): system_shell_ori = system_shell diff -Naurb ./IPython/kernel/multiengineclient.py ../ipython-0.10.2_patched/IPython/kernel/multiengineclient.py --- ./IPython/kernel/multiengineclient.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/kernel/multiengineclient.py 2011-09-22 19:32:10.996262174 -0400 @@ -17,6 +17,7 @@ #------------------------------------------------------------------------------- import sys +from IPython.genutils import sys_platform import cPickle as pickle from types import FunctionType import linecache @@ -192,7 +193,7 @@ def __repr__(self): output = [] # These colored prompts were not working on Windows - if sys.platform == 'win32': + if sys_platform() == 'win32': blue = normal = red = green = '' else: blue = TermColors.Blue diff -Naurb ./IPython/kernel/scripts/ipcluster.py ../ipython-0.10.2_patched/IPython/kernel/scripts/ipcluster.py --- ./IPython/kernel/scripts/ipcluster.py 2011-03-13 00:08:47.000000000 -0500 +++ ../ipython-0.10.2_patched/IPython/kernel/scripts/ipcluster.py 2011-09-22 19:32:11.006262415 -0400 @@ -34,14 +34,16 @@ get_ipython_dir, get_log_dir, get_security_dir, - num_cpus + num_cpus, + os_name, + sys_platform ) from IPython.kernel.fcutil import have_crypto # Create various ipython directories if they don't exist. # This must be done before IPython.kernel.config is imported. from IPython.iplib import user_setup -if os.name == 'posix': +if os_name() == 'posix': rc_suffix = '' else: rc_suffix = '.ini' @@ -185,7 +187,7 @@ class ControllerLauncher(ProcessLauncher): def __init__(self, extra_args=None): - if sys.platform == 'win32': + if sys_platform() == 'win32': # This logic is needed because the ipcontroller script doesn't # always get installed in the same way or in the same location. from IPython.kernel.scripts import ipcontroller @@ -207,7 +209,7 @@ class EngineLauncher(ProcessLauncher): def __init__(self, extra_args=None): - if sys.platform == 'win32': + if sys_platform() == 'win32': # This logic is needed because the ipcontroller script doesn't # always get installed in the same way or in the same location. from IPython.kernel.scripts import ipengine diff -Naurb ./IPython/kernel/scripts/ipcontroller.py ../ipython-0.10.2_patched/IPython/kernel/scripts/ipcontroller.py --- ./IPython/kernel/scripts/ipcontroller.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/kernel/scripts/ipcontroller.py 2011-09-22 18:32:01.705857046 -0400 @@ -42,8 +42,8 @@ # Create various ipython directories if they don't exist. # This must be done before IPython.kernel.config is imported. from IPython.iplib import user_setup -from IPython.genutils import get_ipython_dir, get_log_dir, get_security_dir -if os.name == 'posix': +from IPython.genutils import get_ipython_dir, get_log_dir, get_security_dir, os_name +if os_name() == 'posix': rc_suffix = '' else: rc_suffix = '.ini' diff -Naurb ./IPython/kernel/scripts/ipengine.py ../ipython-0.10.2_patched/IPython/kernel/scripts/ipengine.py --- ./IPython/kernel/scripts/ipengine.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/kernel/scripts/ipengine.py 2011-09-22 18:32:01.705857046 -0400 @@ -37,8 +37,8 @@ # Create various ipython directories if they don't exist. # This must be done before IPython.kernel.config is imported. from IPython.iplib import user_setup -from IPython.genutils import get_ipython_dir, get_log_dir, get_security_dir -if os.name == 'posix': +from IPython.genutils import get_ipython_dir, get_log_dir, get_security_dir, os_name +if os_name() == 'posix': rc_suffix = '' else: rc_suffix = '.ini' diff -Naurb ./IPython/Magic.py ../ipython-0.10.2_patched/IPython/Magic.py --- ./IPython/Magic.py 2011-03-13 00:17:17.000000000 -0500 +++ ../ipython-0.10.2_patched/IPython/Magic.py 2011-09-22 19:32:10.936260733 -0400 @@ -2482,7 +2482,7 @@ import IPython.rlineimpl as readline - if not readline.have_readline and sys.platform == "win32": + if not readline.have_readline and sys_platform() == "win32": msg = """\ Proper color support under MS Windows requires the pyreadline library. You can find it at: @@ -2709,7 +2709,7 @@ alias_table = self.shell.alias_table syscmdlist = [] - if os.name == 'posix': + if os_name() == 'posix': isexec = lambda fname:os.path.isfile(fname) and \ os.access(fname,os.X_OK) else: @@ -2726,7 +2726,7 @@ try: # write the whole loop for posix/Windows so we don't have an if in # the innermost part - if os.name == 'posix': + if os_name() == 'posix': for pdir in path: os.chdir(pdir) for ff in os.listdir(pdir): @@ -3445,7 +3445,7 @@ print "Nuking legacy files:",legacy [p.remove() for p in legacy] - suffix = (sys.platform == 'win32' and '.ini' or '') + suffix = (sys_platform() == 'win32' and '.ini' or '') (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n') diff -Naurb ./IPython/platutils.py ../ipython-0.10.2_patched/IPython/platutils.py --- ./IPython/platutils.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/platutils.py 2011-09-22 19:32:11.026262896 -0400 @@ -13,13 +13,15 @@ #***************************************************************************** import os +from IPython.genutils import os_name import sys +from IPython.genutils import sys_platform import warnings # Import the platform-specific implementations -if os.name == 'posix': +if os_name() == 'posix': import platutils_posix as _platutils -elif sys.platform == 'win32': +elif sys_platform() == 'win32': import platutils_win32 as _platutils else: import platutils_dummy as _platutils diff -Naurb ./IPython/Prompts.py ../ipython-0.10.2_patched/IPython/Prompts.py --- ./IPython/Prompts.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/Prompts.py 2011-09-22 19:32:10.886259533 -0400 @@ -117,7 +117,7 @@ USER = os.environ.get("USER") HOSTNAME = socket.gethostname() HOSTNAME_SHORT = HOSTNAME.split(".")[0] -ROOT_SYMBOL = "$#"[os.name=='nt' or os.getuid()==0] +ROOT_SYMBOL = "$#"[os_name()=='nt' or os.getuid()==0] prompt_specials_color = { # Prompt/history count @@ -320,7 +320,7 @@ if '~' in cwd and len(cwd) == depth+1: depth += 1 drivepart = '' - if sys.platform == 'win32' and len(cwd) > depth: + if sys_platform() == 'win32' and len(cwd) > depth: drivepart = os.path.splitdrive(full_cwd)[0] out = drivepart + '/'.join(cwd[-depth:]) diff -Naurb ./IPython/rlineimpl.py ../ipython-0.10.2_patched/IPython/rlineimpl.py --- ./IPython/rlineimpl.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/IPython/rlineimpl.py 2011-09-22 19:32:10.906260013 -0400 @@ -8,6 +8,7 @@ """ import sys +from IPython.genutils import sys_platform try: from readline import * @@ -21,7 +22,7 @@ except ImportError: have_readline = False -if sys.platform == 'win32' and have_readline: +if sys_platform() == 'win32' and have_readline: try: _outputfile=_rl.GetOutputFile() except AttributeError: @@ -31,7 +32,7 @@ # Test to see if libedit is being used instead of GNU readline. # Thanks to Boyd Waters for this patch. uses_libedit = False -if sys.platform == 'darwin' and have_readline: +if sys_platform() == 'darwin' and have_readline: import commands # Boyd's patch had a 'while True' here, I'm always a little worried about # infinite loops with such code, so for now I'm taking a more conservative diff -Naurb ./IPython/Shell.py ../ipython-0.10.2_patched/IPython/Shell.py --- ./IPython/Shell.py 2011-03-13 01:34:43.000000000 -0500 +++ ../ipython-0.10.2_patched/IPython/Shell.py 2011-09-22 19:32:10.986261933 -0400 @@ -20,6 +20,7 @@ import inspect import os import sys +from IPython.genutils import sys_platform import thread import threading import time @@ -817,7 +818,7 @@ else: self.gtk.idle_add(self.on_timer) - if sys.platform != 'win32': + if sys_platform() != 'win32': try: if self.gtk.gtk_version[0] >= 2: self.gtk.gdk.threads_init() diff -Naurb ./setupbase.py ../ipython-0.10.2_patched/setupbase.py --- ./setupbase.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/setupbase.py 2011-09-22 19:32:10.956261213 -0400 @@ -24,6 +24,7 @@ #------------------------------------------------------------------------------- import os, sys +from IPython.genutils import sys_platform from glob import glob @@ -288,7 +289,7 @@ print_raw("BUILDING IPYTHON") print_status('python', sys.version) print_status('platform', sys.platform) - if sys.platform == 'win32': + if sys_platform() == 'win32': print_status('Windows version', sys.getwindowsversion()) print_raw("") diff -Naurb ./setup.py ../ipython-0.10.2_patched/setup.py --- ./setup.py 2010-10-12 03:13:29.000000000 -0400 +++ ../ipython-0.10.2_patched/setup.py 2011-09-22 18:32:01.755857769 -0400 @@ -30,7 +30,7 @@ from distutils.core import setup # Local imports -from IPython.genutils import target_update +from IPython.genutils import target_update, os_name from setupbase import ( setup_args, @@ -47,12 +47,12 @@ # Handle OS specific things #------------------------------------------------------------------------------- -if os.name == 'posix': +if os_name() == 'posix': os_name = 'posix' -elif os.name in ['nt','dos']: +elif os_name() in ['nt','dos']: os_name = 'windows' else: - print 'Unsupported operating system:',os.name + print 'Unsupported operating system:',os_name() sys.exit(1) # Under Windows, 'sdist' has not been supported. Now that the docs build with