Skip to content

Commit eb9474c

Browse files
committed
fixes #224
1 parent ecc7b88 commit eb9474c

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@
175175
"RedirectOutput",
176176
"DebugStdLib",
177177
"BreakOnSystemExitZero",
178-
"DjangoDebugging"
178+
"DjangoDebugging",
179+
"Sudo"
179180
]
180181
},
181182
"default": [

src/client/common/open.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ export function open(opts: any): Promise<childProcess.ChildProcess> {
2929
}
3030

3131
if (process.platform === 'darwin') {
32-
cmd = 'osascript';
32+
const sudoPrefix = opts.sudo === true ? 'sudo ' : '';
33+
cmd = 'osascript';
3334
args = [ '-e', 'tell application "terminal"',
3435
'-e', 'activate',
35-
'-e', 'do script "' + [opts.app].concat(appArgs).join(" ") + '"',
36+
'-e', 'do script "' + sudoPrefix + [opts.app].concat(appArgs).join(" ") + '"',
3637
'-e', 'end tell' ];
37-
3838
} else if (process.platform === 'win32') {
3939
cmd = 'cmd';
4040
args.push('/c', 'start');
@@ -52,7 +52,8 @@ export function open(opts: any): Promise<childProcess.ChildProcess> {
5252
}
5353
} else {
5454
cmd = 'gnome-terminal';
55-
args = ['-x', 'sh', '-c', `"${opts.app}" ${appArgs.join(" ")}`]
55+
const sudoPrefix = opts.sudo === true ? 'sudo ' : '';
56+
args = ['-x', 'sh', '-c', `"${sudoPrefix}${opts.app}" ${appArgs.join(" ")}`]
5657
}
5758

5859
var cp = childProcess.spawn(cmd, args, cpOpts);

src/client/debugger/DebugClients/LocalDebugClient.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ let LineByLineReader = require("line-by-line");
1515

1616
const PTVS_FILES = ["visualstudio_ipython_repl.py", "visualstudio_py_debugger.py",
1717
"visualstudio_py_launcher.py", "visualstudio_py_repl.py", "visualstudio_py_util.py"];
18+
const VALID_DEBUG_OPTIONS = ["WaitOnAbnormalExit",
19+
"WaitOnNormalExit",
20+
"RedirectOutput",
21+
"DebugStdLib",
22+
"BreakOnSystemExitZero",
23+
"DjangoDebugging"];
1824

1925
export class LocalDebugClient extends DebugClient {
2026
protected args: LaunchRequestArguments;
@@ -92,7 +98,8 @@ export class LocalDebugClient extends DebugClient {
9298

9399
let args = [ptVSToolsFilePath, processCwd, dbgServer.port.toString(), "34806ad9-833a-4524-8cd6-18ca4aa74f14"].concat(launcherArgs);
94100
if (this.args.externalConsole === true) {
95-
open({ wait: false, app: [pythonPath].concat(args), cwd: processCwd, env: environmentVariables }).then(proc => {
101+
const isSudo = Array.isArray(this.args.debugOptions) && this.args.debugOptions.some(opt => opt === 'Sudo');
102+
open({ wait: false, app: [pythonPath].concat(args), cwd: processCwd, env: environmentVariables, sudo: isSudo }).then(proc => {
96103
this.pyProc = proc;
97104
resolve();
98105
}, error => {
@@ -144,7 +151,7 @@ export class LocalDebugClient extends DebugClient {
144151
protected buildLauncherArguments(): string[] {
145152
let vsDebugOptions = "WaitOnAbnormalExit,WaitOnNormalExit,RedirectOutput";
146153
if (Array.isArray(this.args.debugOptions)) {
147-
vsDebugOptions = this.args.debugOptions.join(",");
154+
vsDebugOptions = this.args.debugOptions.filter(opt => VALID_DEBUG_OPTIONS.indexOf(opt) >= 0).join(",");
148155
}
149156

150157
let programArgs = Array.isArray(this.args.args) && this.args.args.length > 0 ? this.args.args : [];

0 commit comments

Comments
 (0)