Show More
@@ -306,7 +306,7 b' class SSHLauncher(BaseLauncher):' | |||||
306 | program = List(['date'], config=True) |
|
306 | program = List(['date'], config=True) | |
307 | program_args = List([], config=True) |
|
307 | program_args = List([], config=True) | |
308 | hostname = Str('', config=True) |
|
308 | hostname = Str('', config=True) | |
309 |
user = Str( |
|
309 | user = Str('', config=True) | |
310 | location = Str('') |
|
310 | location = Str('') | |
311 |
|
311 | |||
312 | def _hostname_changed(self, name, old, new): |
|
312 | def _hostname_changed(self, name, old, new): |
@@ -717,10 +717,17 b' class HomeDirError(Error):' | |||||
717 | def get_home_dir(): |
|
717 | def get_home_dir(): | |
718 | """Return the closest possible equivalent to a 'home' directory. |
|
718 | """Return the closest possible equivalent to a 'home' directory. | |
719 |
|
719 | |||
720 | We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH. |
|
720 | * On POSIX, we try $HOME. | |
721 |
|
721 | * On Windows we try: | ||
|
722 | - %HOMESHARE% | |||
|
723 | - %HOMEDRIVE\%HOMEPATH% | |||
|
724 | - %USERPROFILE% | |||
|
725 | - Registry hack | |||
|
726 | * On Dos C:\ | |||
|
727 | ||||
722 | Currently only Posix and NT are implemented, a HomeDirError exception is |
|
728 | Currently only Posix and NT are implemented, a HomeDirError exception is | |
723 |
raised for all other OSes. |
|
729 | raised for all other OSes. | |
|
730 | """ | |||
724 |
|
731 | |||
725 | isdir = os.path.isdir |
|
732 | isdir = os.path.isdir | |
726 | env = os.environ |
|
733 | env = os.environ | |
@@ -737,50 +744,70 b' def get_home_dir():' | |||||
737 | if isdir(os.path.join(root, '_ipython')): |
|
744 | if isdir(os.path.join(root, '_ipython')): | |
738 | os.environ["IPYKITROOT"] = root |
|
745 | os.environ["IPYKITROOT"] = root | |
739 | return root.decode(sys.getfilesystemencoding()) |
|
746 | return root.decode(sys.getfilesystemencoding()) | |
740 | try: |
|
747 | ||
741 | homedir = env['HOME'] |
|
748 | if os.name == 'posix': | |
742 | if not isdir(homedir): |
|
749 | # Linux, Unix, AIX, OS X | |
743 | # in case a user stuck some string which does NOT resolve to a |
|
750 | try: | |
744 | # valid path, it's as good as if we hadn't foud it |
|
751 | homedir = env['HOME'] | |
745 |
|
|
752 | except KeyError: | |
746 | return homedir.decode(sys.getfilesystemencoding()) |
|
753 | raise HomeDirError('Undefined $HOME, IPython cannot proceed.') | |
747 | except KeyError: |
|
754 | else: | |
748 | if os.name == 'posix': |
|
755 | return homedir.decode(sys.getfilesystemencoding()) | |
749 | raise HomeDirError,'undefined $HOME, IPython can not proceed.' |
|
756 | elif os.name == 'nt': | |
750 | elif os.name == 'nt': |
|
757 | # Now for win9x, XP, Vista, 7? | |
751 |
|
|
758 | # For some strange reason all of these return 'nt' for os.name. | |
752 | try: |
|
759 | # First look for a network home directory. This will return the UNC | |
753 | homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH']) |
|
760 | # path (\\server\\Users\%username%) not the mapped path (Z:\). This | |
754 | if not isdir(homedir): |
|
761 | # is needed when running IPython on cluster where all paths have to | |
755 | homedir = os.path.join(env['USERPROFILE']) |
|
762 | # be UNC. | |
756 | if not isdir(homedir): |
|
763 | try: | |
757 | raise HomeDirError |
|
764 | homedir = env['HOMESHARE'] | |
|
765 | except KeyError: | |||
|
766 | pass | |||
|
767 | else: | |||
|
768 | if isdir(homedir): | |||
758 | return homedir.decode(sys.getfilesystemencoding()) |
|
769 | return homedir.decode(sys.getfilesystemencoding()) | |
759 | except KeyError: |
|
770 | ||
760 | try: |
|
771 | # Now look for a local home directory | |
761 | # Use the registry to get the 'My Documents' folder. |
|
772 | try: | |
762 | import _winreg as wreg |
|
773 | homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH']) | |
763 | key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, |
|
774 | except KeyError: | |
764 | "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") |
|
775 | pass | |
765 | homedir = wreg.QueryValueEx(key,'Personal')[0] |
|
|||
766 | key.Close() |
|
|||
767 | if not isdir(homedir): |
|
|||
768 | e = ('Invalid "Personal" folder registry key ' |
|
|||
769 | 'typically "My Documents".\n' |
|
|||
770 | 'Value: %s\n' |
|
|||
771 | 'This is not a valid directory on your system.' % |
|
|||
772 | homedir) |
|
|||
773 | raise HomeDirError(e) |
|
|||
774 | return homedir.decode(sys.getfilesystemencoding()) |
|
|||
775 | except HomeDirError: |
|
|||
776 | raise |
|
|||
777 | except: |
|
|||
778 | return 'C:\\'.decode(sys.getfilesystemencoding()) |
|
|||
779 | elif os.name == 'dos': |
|
|||
780 | # Desperate, may do absurd things in classic MacOS. May work under DOS. |
|
|||
781 | return 'C:\\'.decode(sys.getfilesystemencoding()) |
|
|||
782 | else: |
|
776 | else: | |
783 | raise HomeDirError,'support for your operating system not implemented.' |
|
777 | if isdir(homedir): | |
|
778 | return homedir.decode(sys.getfilesystemencoding()) | |||
|
779 | ||||
|
780 | # Now the users profile directory | |||
|
781 | try: | |||
|
782 | homedir = os.path.join(env['USERPROFILE']) | |||
|
783 | except KeyError: | |||
|
784 | pass | |||
|
785 | else: | |||
|
786 | if isdir(homedir): | |||
|
787 | return homedir.decode(sys.getfilesystemencoding()) | |||
|
788 | ||||
|
789 | # Use the registry to get the 'My Documents' folder. | |||
|
790 | try: | |||
|
791 | import _winreg as wreg | |||
|
792 | key = wreg.OpenKey( | |||
|
793 | wreg.HKEY_CURRENT_USER, | |||
|
794 | "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" | |||
|
795 | ) | |||
|
796 | homedir = wreg.QueryValueEx(key,'Personal')[0] | |||
|
797 | key.Close() | |||
|
798 | except: | |||
|
799 | pass | |||
|
800 | else: | |||
|
801 | if isdir(homedir): | |||
|
802 | return homedir.decode(sys.getfilesystemencoding()) | |||
|
803 | ||||
|
804 | # If all else fails, raise HomeDirError | |||
|
805 | raise HomeDirError('No valid home directory could be found') | |||
|
806 | elif os.name == 'dos': | |||
|
807 | # Desperate, may do absurd things in classic MacOS. May work under DOS. | |||
|
808 | return 'C:\\'.decode(sys.getfilesystemencoding()) | |||
|
809 | else: | |||
|
810 | raise HomeDirError('No valid home directory could be found for your OS') | |||
784 |
|
811 | |||
785 |
|
812 | |||
786 | def get_ipython_dir(): |
|
813 | def get_ipython_dir(): |
@@ -119,8 +119,8 b' def find_packages():' | |||||
119 | add_package(packages, 'frontend.wx') |
|
119 | add_package(packages, 'frontend.wx') | |
120 | add_package(packages, 'gui') |
|
120 | add_package(packages, 'gui') | |
121 | add_package(packages, 'gui.wx') |
|
121 | add_package(packages, 'gui.wx') | |
122 |
add_package(packages, 'kernel', config= |
|
122 | add_package(packages, 'kernel', config=False, tests=True, scripts=True) | |
123 |
add_package(packages, 'kernel.core', config= |
|
123 | add_package(packages, 'kernel.core', config=False, tests=True) | |
124 | add_package(packages, 'lib', tests=True) |
|
124 | add_package(packages, 'lib', tests=True) | |
125 | add_package(packages, 'quarantine', tests=True) |
|
125 | add_package(packages, 'quarantine', tests=True) | |
126 | add_package(packages, 'scripts') |
|
126 | add_package(packages, 'scripts') |
General Comments 0
You need to be logged in to leave comments.
Login now