Skip to content

Commit fc11d27

Browse files
committed
WIP: Refactor path discovery
1 parent 566a0c6 commit fc11d27

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

src/renderer/search_emme_pythonpath.js

+15-23
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ const listEMMEPythonPaths = () => {
7878
)
7979
})
8080
paths.push(`usr/bin/python${pythonVersion.major}`); // mainly for developers on Mac & Linux
81-
paths.push('users/erkki/testi');
8281

8382
const allPathCombinations = drives.reduce(
8483
(accumulator, d) => {
@@ -117,31 +116,24 @@ function hasPythonEnv(basePath) {
117116
if (pathExists) {
118117
try {
119118
const subPaths = fs.readdirSync(basePath)
120-
console.log(subPaths);
121119
subPaths.forEach(subPath => {
122-
if(subPath.startsWith("Emme ")) {
123-
const majorVersionFolderPath = path.join(basePath, subPath);
124-
const majorVersionFolderPathFiles = fs.readdirSync(majorVersionFolderPath);
120+
if(subPath.startsWith("Emme")) {
121+
const emmeVersionFolder = path.join(basePath, subPath);
122+
const emmeVersionFolderContents = fs.readdirSync(emmeVersionFolder);
125123

126-
console.log(majorVersionFolderPathFiles);
124+
console.log(emmeVersionFolderPathFiles);
125+
console.log(emmeVersionFolderContents);
127126

128-
// Filter away every folder except possible Emme installation folders
129-
const subVersionFolders = majorVersionFolderPathFiles.filter(file => file.startsWith("Emme-"));
130-
subVersionFolders.forEach(subVersionFolder => {
131-
// Go through the subdirectory and look for a python executable, should be in Emme-x.xx.xx.xx/Python/python.exe on Windows machines.
132-
const emmeFolderFilesPath = path.join(majorVersionFolderPath, subVersionFolder);
133-
const emmeFolderFiles = fs.readdirSync(emmeFolderFilesPath);
134-
emmeFolderFiles.forEach(emmeFolderPath => {
135-
if(emmeFolderPath.startsWith("Python")) {
136-
const pythonFolderPath = path.join(emmeFolderFilesPath, emmeFolderPath);
137-
const pythonPathFiles = fs.readdirSync(pythonFolderPath);
138-
pythonPathFiles.forEach(fileName => {
139-
if(fileName === 'python.exe') {
140-
exePaths.push(path.join(pythonFolderPath, fileName));
141-
}
142-
})
143-
}
144-
})
127+
emmeVersionFolderContents.forEach(emmeFolderPath => {
128+
if(emmeFolderPath.startsWith("Python")) {
129+
const pythonFolderPath = path.join(emmeVersionFolder, emmeFolderPath);
130+
const pythonPathFiles = fs.readdirSync(pythonFolderPath);
131+
pythonPathFiles.forEach(fileName => {
132+
if(fileName === 'python.exe') {
133+
exePaths.push(path.join(pythonFolderPath, fileName));
134+
}
135+
})
136+
}
145137
})
146138
}
147139
})

0 commit comments

Comments
 (0)