Skip to content

Commit

Permalink
fix an issue when there is a space in python path
Browse files Browse the repository at this point in the history
  • Loading branch information
smahmed776 committed Dec 26, 2023
1 parent d7462c2 commit 4812e2f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.
21 changes: 0 additions & 21 deletions playwright-test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,6 @@ export const writeLogFile = async (
);
};

export const killBackend = async () => {
let cmd: string;
switch (process.platform) {
case "win32":
cmd = `FOR /F "tokens=5" %i IN ('netstat -aon ^| find "5392"') DO Taskkill /F /PID %i`;
break;
case "darwin":
case "linux":
cmd = `kill -9 $(lsof -t -i :5392)`;
break;
default:
cmd = "";
break;
}
try {
execSync(cmd);
} catch (error) {
//
}
};

export const mockDialogMessage = async (app: ElectronApplication) => {
await app.evaluate(async ({ dialog }) => {
const originalShowMessageBoxSync = dialog.showMessageBoxSync;
Expand Down
6 changes: 3 additions & 3 deletions src/main/python/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function pipxEnsurepath(): Promise<void> {

export async function installPoetry(): Promise<void> {
const py = process.env.PY_INTERPRETER ?? "python";
await execCommand(new Command(`${py} -m pipx install poetry --force`));
await execCommand(new Command(`"${py}" -m pipx install poetry --force`));
const poetryPath = await getPoetryPath();
process.env.POETRY_PATH = poetryPath;
}
Expand Down Expand Up @@ -157,14 +157,14 @@ export function killCaptain(): boolean {

export async function listPythonPackages() {
const poetry = process.env.POETRY_PATH ?? "poetry";
return await execCommand(new Command(`${poetry} run pip freeze`), {
return await execCommand(new Command(`"${poetry}" run pip freeze`), {
quiet: true,
});
}

export async function pyvisaInfo() {
const poetry = process.env.POETRY_PATH ?? "poetry";
return await execCommand(new Command(`${poetry} run pyvisa-info`), {
return await execCommand(new Command(`"${poetry}" run pyvisa-info`), {
quiet: true,
});
}
Expand Down
8 changes: 5 additions & 3 deletions src/renderer/routes/index/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ export const Index = (): JSX.Element => {
try {
const interpreters = await window.api.checkPythonInstallation(force);
if (interpreters.length > 0) {
setSelectedInterpreter(interpreters[0].path);
await window.api.setPythonInterpreter(interpreters[0].path);
const interpreter =
interpreters.find((i) => i.default) ?? interpreters[0];
setSelectedInterpreter(interpreter.path);
await window.api.setPythonInterpreter(interpreter.path);
updateSetupStatus({
stage: "check-python-installation",
status: "completed",
message: `Python v${interpreters[0].version.major}.${interpreters[0].version.minor} found!`,
message: `Python v${interpreter.version.major}.${interpreter.version.minor} found!`,
});
return;
}
Expand Down

0 comments on commit 4812e2f

Please sign in to comment.