Skip to content

Commit

Permalink
Use pwd in WSL to map the python server path to the same in Linux l…
Browse files Browse the repository at this point in the history
…and.

closes #155
  • Loading branch information
sedwards2009 committed Mar 31, 2019
1 parent 860c382 commit c1ae683
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions extensions/ProxySessionBackend/src/WslProxySessionBackend.ts
Expand Up @@ -107,9 +107,22 @@ class WslProxyPtyConnector extends ProxyPtyConnector {
}

protected _spawnServer(): child_process.ChildProcess {
let serverPath = path.join(SourceDir.path, "python/ptyserver2.py");
serverPath = "/mnt/" + serverPath.replace(/\\/g, "/").replace("C:", "c");
// Clever way of mapping a Windows side dir to its WSL/Linux side equivalent.
const cdResult = child_process.spawnSync("wsl.exe", ["pwd"],
{cwd: path.join(SourceDir.path, "python"), shell: true, encoding: "utf8"});

if (cdResult.status !== 0) {
_log.warn("'wsl.exe pwd' returned status code ${cdResult.status} and stdout '${cdResult.stdout}'.");
// FIXME throw new Exception();
}

const wslPath = cdResult.stdout.trim();
if (wslPath.split("\n").length !== 1) {
_log.warn("'wsl.exe pwd' gave unexpected output. stdout '${cdResult.stdout}'.");
// FIXME throw new Exception();
}

const serverPath = wslPath + "/ptyserver2.py";
_log.debug(`serverPath: ${serverPath}`);
return child_process.spawn("wsl.exe", ["PYTHONIOENCODING=utf-8:ignore", "python3", serverPath], {});
}
Expand Down

0 comments on commit c1ae683

Please sign in to comment.