--- IPython/genutils.py 2010-07-26 00:33:01.000000000 -0600 +++ ../ipython-0.10.1-patched/IPython/genutils.py 2010-10-16 10:27:01.000000000 -0600 @@ -51,7 +51,14 @@ from IPython.generics import result_display import IPython.ipapi from IPython.external.path import path -if os.name == "nt": + +def os_name(): + if os.name == 'java': + return os._name + else: + return os.name + +if os_name() == "nt": from IPython.winconsole import get_console_size try: @@ -368,7 +375,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,10 +945,10 @@ raise KeyError return homedir except KeyError: - if os.name == 'posix': + if os_name() == 'posix': raise HomeDirError,'undefined $HOME, IPython can not proceed.' - elif os.name == 'nt': - # For some strange reason, win9x returns 'nt' for os.name. + elif os_name() == 'nt': + # For some strange reason, win9x returns 'nt' for os_name(). try: homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH']) if not isdir(homedir): @@ -969,7 +976,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: @@ -982,7 +989,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' @@ -1496,7 +1503,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) @@ -1519,9 +1526,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: @@ -1549,7 +1556,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 @@ -1633,7 +1640,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 @@ -1647,7 +1654,7 @@ # 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 @@ -1691,7 +1698,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