Show More
@@ -936,10 +936,20 b' def get_home_dir():' | |||
|
936 | 936 | # in case a user stuck some string which does NOT resolve to a |
|
937 | 937 | # valid path, it's as good as if we hadn't foud it |
|
938 | 938 | raise KeyError |
|
939 | return homedir | |
|
939 | return homedir.decode(sys.getfilesystemencoding()) | |
|
940 | 940 | except KeyError: |
|
941 | 941 | if os.name == 'posix': |
|
942 | raise HomeDirError,'undefined $HOME, IPython can not proceed.' | |
|
942 | # Last-ditch attempt at finding a suitable $HOME, on systems where | |
|
943 | # it may not be defined in the environment but the system shell | |
|
944 | # still knows it - reported once as: | |
|
945 | # https://github.com/ipython/ipython/issues/154 | |
|
946 | from subprocess import Popen, PIPE | |
|
947 | homedir = Popen('echo $HOME', shell=True, | |
|
948 | stdout=PIPE).communicate()[0].strip() | |
|
949 | if homedir: | |
|
950 | return homedir.decode(sys.getfilesystemencoding()) | |
|
951 | else: | |
|
952 | raise HomeDirError('Undefined $HOME, IPython cannot proceed.') | |
|
943 | 953 | elif os.name == 'nt': |
|
944 | 954 | # For some strange reason, win9x returns 'nt' for os.name. |
|
945 | 955 | try: |
@@ -948,7 +958,7 b' def get_home_dir():' | |||
|
948 | 958 | homedir = os.path.join(env['USERPROFILE']) |
|
949 | 959 | if not isdir(homedir): |
|
950 | 960 | raise HomeDirError |
|
951 | return homedir | |
|
961 | return homedir.decode(sys.getfilesystemencoding()) | |
|
952 | 962 | except KeyError: |
|
953 | 963 | try: |
|
954 | 964 | # Use the registry to get the 'My Documents' folder. |
@@ -964,7 +974,7 b' def get_home_dir():' | |||
|
964 | 974 | 'This is not a valid directory on your system.' % |
|
965 | 975 | homedir) |
|
966 | 976 | raise HomeDirError(e) |
|
967 | return homedir | |
|
977 | return homedir.decode(sys.getfilesystemencoding()) | |
|
968 | 978 | except HomeDirError: |
|
969 | 979 | raise |
|
970 | 980 | except: |
General Comments 0
You need to be logged in to leave comments.
Login now