@@ -27,7 +27,7 @@ protected function getInstallPath()
27
27
$ currentUser = $ this ->system ->getCurrentUser ();
28
28
29
29
if ('Administrator ' === $ currentUser ) {
30
- return ' C:\ProgramData \jupyter-php ' ;
30
+ return $ this -> getProgramDataPath () . ' \jupyter-php ' ;
31
31
} else {
32
32
return $ this ->system ->getCurrentUserHome () . '\.jupyter-php ' ;
33
33
}
@@ -48,8 +48,8 @@ protected function installKernel()
48
48
$ currentUser = $ this ->system ->getCurrentUser ();
49
49
50
50
$ kernelSpecPath = ('Administrator ' === $ currentUser ) ?
51
- ' C:\ProgramData \jupyter\kernels\jupyter-php ' :
52
- $ this ->system -> getCurrentUserHome () . '\AppData\Roaming \jupyter\kernels\jupyter-php ' ;
51
+ $ this -> getProgramDataPath () . ' \jupyter\kernels\jupyter-php ' :
52
+ $ this ->getAppDataPath () . '\jupyter\kernels\jupyter-php ' ;
53
53
54
54
$ this ->system ->ensurePath ($ kernelSpecPath );
55
55
file_put_contents ($ kernelSpecPath . '\kernel.json ' , $ kernelDef );
@@ -73,4 +73,22 @@ protected function executeSilentComposerCommand($installPath)
73
73
74
74
return $ composerStatus ;
75
75
}
76
+
77
+ private function getProgramDataPath ()
78
+ {
79
+ if (function_exists ('getenv ' ) && false !== getenv ('PROGRAMDATA ' )) {
80
+ return getenv ('PROGRAMDATA ' );
81
+ } else {
82
+ throw new \RuntimeException ('Unable to obtain the program data directory. ' );
83
+ }
84
+ }
85
+
86
+ private function getAppDataPath ()
87
+ {
88
+ if (function_exists ('getenv ' ) && false !== getenv ('APPDATA ' )) {
89
+ return getenv ('APPDATA ' );
90
+ } else {
91
+ throw new \RuntimeException ('Unable to obtain the app data directory. ' );
92
+ }
93
+ }
76
94
}
0 commit comments