Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

using ipython in Slicer3 show how os.environ['HOME'] is not defined #154

Closed
dmirota opened this Issue · 3 comments

2 participants

@dmirota

Currently in genutils.py at line 942 in ipython 0.10 ipython gives up trying to find the home directory which causes ipython to final to load.

At this point ipython could still try a little harder to find a home directory with something like the following:

import subprocess
p = subprocess.Popen('echo $HOME',shell=True,stdout=subprocess.PIPE)
potential_home = p.communicate()[0].strip()
if len(potential_home) > 0:
     return potential_home
else:
    raise HomeDirError,'undefined $HOME, IPython can not proceed.'

I'm not too sure if this is a Slicer 3 ( http://www.slicer.org/ ) issue or a ipython issue so I'm creating a ticket in each project. The slicer ticket: http://na-mic.org/Mantis/view.php?id=985

This issue occurred on OS X 10.6.4, Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29), Slicer 3.6.1 rev 15021

@fperez
Owner

Unfortunately the code you propose is posix-specific, and won't work on Windows. IPython is cross platform, so we need a platform-independent solution.

If you find one, by all means post it, the easiest way to have it merged is to make it as a pull request on github, but a patch on our -dev list or even here will be equally welcome.

@dmirota

Yes, you are correct my proposal is posix-specific. That's why it's within the block which checks if the OS is posix. Here is a patch:

--- genutils.py 2009-08-04 19:26:20.000000000 -0400
+++ genutils.py 2010-09-23 16:34:45.000000000 -0400
@@ -940,7 +940,13 @@
         return homedir
     except KeyError:
         if os.name == 'posix':
-            raise HomeDirError,'undefined $HOME, IPython can not proceed.'
+            import subprocess
+            p = subprocess.Popen('echo $HOME',shell=True,stdout=subprocess.PIPE)
+            potential_home = p.communicate()[0].strip()
+            if len(potential_home) > 0:
+                return potential_home
+            else:
+                raise HomeDirError,'undefined $HOME, IPython can not proceed.'
         elif os.name == 'nt':
             # For some strange reason, win9x returns 'nt' for os.name.
             try:
@fperez
Owner

Make last-ditch attempt to find $HOME when environment is broken.

Closed by 5a7eee9, thanks to gh user dmirota for report and patch.

@markvoorhies markvoorhies referenced this issue from a commit in markvoorhies/ipython
@fperez fperez Make last-ditch attempt to find $HOME when environment is broken.
Closes gh-154, thanks to gh user dmirota for report and patch.
5a7eee9
@fperez fperez referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@damianavila damianavila referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@fperez fperez Make last-ditch attempt to find $HOME when environment is broken.
Closes gh-154, thanks to gh user dmirota for report and patch.
ff9072f
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.