1- import { BaseDebugServer } from " ../DebugServers/BaseDebugServer" ;
2- import { LocalDebugServer } from " ../DebugServers/LocalDebugServer" ;
3- import { IPythonProcess , IPythonThread , IDebugServer } from " ../Common/Contracts" ;
4- import { DebugSession , OutputEvent } from " vscode-debugadapter" ;
5- import { DebugProtocol } from " vscode-debugprotocol" ;
6- import * as path from " path" ;
7- import * as child_process from " child_process" ;
8- import { LaunchRequestArguments } from " ../Common/Contracts" ;
9- import { DebugClient , DebugType } from " ./DebugClient" ;
10- import * as fs from "fs" ;
11- import { open } from " ../../common/open" ;
12- let fsExtra = require ( " fs-extra" ) ;
13- let tmp = require ( " tmp" ) ;
14- let prependFile = require ( " prepend-file" ) ;
15- let LineByLineReader = require ( " line-by-line" ) ;
1+ import { BaseDebugServer } from ' ../DebugServers/BaseDebugServer' ;
2+ import { LocalDebugServer } from ' ../DebugServers/LocalDebugServer' ;
3+ import { IPythonProcess , IPythonThread , IDebugServer } from ' ../Common/Contracts' ;
4+ import { DebugSession , OutputEvent } from ' vscode-debugadapter' ;
5+ import { DebugProtocol } from ' vscode-debugprotocol' ;
6+ import * as path from ' path' ;
7+ import * as child_process from ' child_process' ;
8+ import { LaunchRequestArguments } from ' ../Common/Contracts' ;
9+ import { DebugClient , DebugType } from ' ./DebugClient' ;
10+ import * as fs from 'fs' ;
11+ import { open } from ' ../../common/open' ;
12+ let fsExtra = require ( ' fs-extra' ) ;
13+ let tmp = require ( ' tmp' ) ;
14+ let prependFile = require ( ' prepend-file' ) ;
15+ let LineByLineReader = require ( ' line-by-line' ) ;
1616
17- const PTVS_FILES = [ " visualstudio_ipython_repl.py" , " visualstudio_py_debugger.py" ,
18- " visualstudio_py_launcher.py" , " visualstudio_py_repl.py" , " visualstudio_py_util.py" ] ;
19- const VALID_DEBUG_OPTIONS = [ " WaitOnAbnormalExit" ,
20- " WaitOnNormalExit" ,
21- " RedirectOutput" ,
22- " DebugStdLib" ,
23- " BreakOnSystemExitZero" ,
24- " DjangoDebugging" ] ;
17+ const PTVS_FILES = [ ' visualstudio_ipython_repl.py' , ' visualstudio_py_debugger.py' ,
18+ ' visualstudio_py_launcher.py' , ' visualstudio_py_repl.py' , ' visualstudio_py_util.py' ] ;
19+ const VALID_DEBUG_OPTIONS = [ ' WaitOnAbnormalExit' ,
20+ ' WaitOnNormalExit' ,
21+ ' RedirectOutput' ,
22+ ' DebugStdLib' ,
23+ ' BreakOnSystemExitZero' ,
24+ ' DjangoDebugging' ] ;
2525
2626export class LocalDebugClient extends DebugClient {
2727 protected args : LaunchRequestArguments ;
@@ -50,9 +50,9 @@ export class LocalDebugClient extends DebugClient {
5050 }
5151
5252 if ( this . pyProc ) {
53- try { this . pyProc . send ( " EXIT" ) ; }
53+ try { this . pyProc . send ( ' EXIT' ) ; }
5454 catch ( ex ) { }
55- try { this . pyProc . stdin . write ( " EXIT" ) ; }
55+ try { this . pyProc . stdin . write ( ' EXIT' ) ; }
5656 catch ( ex ) { }
5757 try { this . pyProc . disconnect ( ) ; }
5858 catch ( ex ) { }
@@ -61,29 +61,29 @@ export class LocalDebugClient extends DebugClient {
6161 }
6262 private getPTVSToolsFilePath ( ) : string {
6363 let currentFileName = module . filename ;
64- let ptVSToolsPath = path . join ( path . dirname ( currentFileName ) , ".." , ".." , ".." , ".." , " pythonFiles" , " PythonTools" ) ;
65- return path . join ( ptVSToolsPath , " visualstudio_py_launcher.py" ) ;
64+ let ptVSToolsPath = path . join ( path . dirname ( currentFileName ) , '..' , '..' , '..' , '..' , ' pythonFiles' , ' PythonTools' ) ;
65+ return path . join ( ptVSToolsPath , ' visualstudio_py_launcher.py' ) ;
6666 }
6767 private displayError ( error : any ) {
68- let errorMsg = typeof error === " string" ? error : ( ( error . message && error . message . length > 0 ) ? error . message : "" ) ;
68+ let errorMsg = typeof error === ' string' ? error : ( ( error . message && error . message . length > 0 ) ? error . message : '' ) ;
6969 if ( errorMsg . length > 0 ) {
70- this . debugSession . sendEvent ( new OutputEvent ( errorMsg , " stderr" ) ) ;
70+ this . debugSession . sendEvent ( new OutputEvent ( errorMsg , ' stderr' ) ) ;
7171 }
7272 }
7373 public LaunchApplicationToDebug ( dbgServer : IDebugServer , processErrored : ( error : any ) => void ) : Promise < any > {
7474 return new Promise < any > ( ( resolve , reject ) => {
7575 let fileDir = path . dirname ( this . args . program ) ;
7676 let processCwd = fileDir ;
77- if ( typeof this . args . cwd === " string" && this . args . cwd . length > 0 ) {
77+ if ( typeof this . args . cwd === ' string' && this . args . cwd . length > 0 ) {
7878 processCwd = this . args . cwd ;
7979 }
8080 let fileNameWithoutPath = path . basename ( this . args . program ) ;
81- let pythonPath = " python" ;
82- if ( typeof this . args . pythonPath === " string" && this . args . pythonPath . trim ( ) . length > 0 ) {
81+ let pythonPath = ' python' ;
82+ if ( typeof this . args . pythonPath === ' string' && this . args . pythonPath . trim ( ) . length > 0 ) {
8383 pythonPath = this . args . pythonPath ;
8484 }
8585 let environmentVariables = this . args . env ? this . args . env : { } ;
86- let newEnvVars = { } ;
86+ let newEnvVars = { } ;
8787 if ( environmentVariables ) {
8888 for ( let setting in environmentVariables ) {
8989 if ( ! newEnvVars [ setting ] ) {
@@ -96,15 +96,15 @@ export class LocalDebugClient extends DebugClient {
9696 }
9797 }
9898 }
99- if ( ! environmentVariables . hasOwnProperty ( " PYTHONIOENCODING" ) ) {
100- environmentVariables [ " PYTHONIOENCODING" ] = " UTF-8" ;
101- newEnvVars [ " PYTHONIOENCODING" ] = " UTF-8" ;
99+ if ( ! environmentVariables . hasOwnProperty ( ' PYTHONIOENCODING' ) ) {
100+ environmentVariables [ ' PYTHONIOENCODING' ] = ' UTF-8' ;
101+ newEnvVars [ ' PYTHONIOENCODING' ] = ' UTF-8' ;
102102 }
103103 let currentFileName = module . filename ;
104104 let ptVSToolsFilePath = this . getPTVSToolsFilePath ( ) ;
105105 let launcherArgs = this . buildLauncherArguments ( ) ;
106106
107- let args = [ ptVSToolsFilePath , processCwd , dbgServer . port . toString ( ) , " 34806ad9-833a-4524-8cd6-18ca4aa74f14" ] . concat ( launcherArgs ) ;
107+ let args = [ ptVSToolsFilePath , processCwd , dbgServer . port . toString ( ) , ' 34806ad9-833a-4524-8cd6-18ca4aa74f14' ] . concat ( launcherArgs ) ;
108108 if ( this . args . console === 'externalTerminal' ) {
109109 const isSudo = Array . isArray ( this . args . debugOptions ) && this . args . debugOptions . some ( opt => opt === 'Sudo' ) ;
110110 open ( { wait : false , app : [ pythonPath ] . concat ( args ) , cwd : processCwd , env : environmentVariables , sudo : isSudo } ) . then ( proc => {
@@ -125,16 +125,16 @@ export class LocalDebugClient extends DebugClient {
125125 const command = isSudo ? 'sudo' : pythonPath ;
126126 const commandArgs = isSudo ? [ pythonPath ] . concat ( args ) : args ;
127127 const options = { cwd : processCwd , env : environmentVariables } ;
128- const termArgs : DebugProtocol . RunInTerminalRequestArguments = {
129- kind : 'integrated' ,
130- title : " Python Debug Console" ,
131- cwd : processCwd ,
132- args : [ command ] . concat ( commandArgs ) ,
128+ const termArgs : DebugProtocol . RunInTerminalRequestArguments = {
129+ kind : 'integrated' ,
130+ title : ' Python Debug Console' ,
131+ cwd : processCwd ,
132+ args : [ command ] . concat ( commandArgs ) ,
133133 env : newEnvVars as { [ key : string ] : string }
134- } ;
135- this . debugSession . runInTerminalRequest ( termArgs , 5000 , ( response ) => {
136- if ( response . success ) {
137- resolve ( )
134+ } ;
135+ this . debugSession . runInTerminalRequest ( termArgs , 5000 , ( response ) => {
136+ if ( response . success ) {
137+ resolve ( ) ;
138138 } else {
139139 reject ( response ) ;
140140 }
@@ -143,47 +143,47 @@ export class LocalDebugClient extends DebugClient {
143143 }
144144
145145 this . pyProc = child_process . spawn ( pythonPath , args , { cwd : processCwd , env : environmentVariables } ) ;
146- this . pyProc . on ( " error" , error => {
146+ this . pyProc . on ( ' error' , error => {
147147 // TODO: This condition makes no sense (refactor)
148148 if ( ! this . debugServer && this . debugServer . IsRunning ) {
149149 return ;
150150 }
151151 if ( ! this . debugServer . IsRunning && typeof ( error ) === 'object' && error !== null ) {
152- //return processErrored(error);
152+ // return processErrored(error);
153153 return reject ( error ) ;
154154 }
155155 this . displayError ( error ) ;
156156 } ) ;
157- this . pyProc . stderr . setEncoding ( " utf8" ) ;
158- this . pyProc . stderr . on ( " data" , error => {
157+ this . pyProc . stderr . setEncoding ( ' utf8' ) ;
158+ this . pyProc . stderr . on ( ' data' , error => {
159159 // We generally don't need to display the errors as stderr output is being captured by debugger
160160 // and it gets sent out to the debug client
161-
161+
162162 // Either way, we need some code in here so we read the stdout of the python process
163163 // Else it just keep building up (related to issue #203 and #52)
164164 if ( this . debugServer && ! this . debugServer . IsRunning ) {
165165 return reject ( error ) ;
166166 }
167167 } ) ;
168- this . pyProc . stdout . on ( " data" , d => {
168+ this . pyProc . stdout . on ( ' data' , d => {
169169 // This is necessary so we read the stdout of the python process
170170 // Else it just keep building up (related to issue #203 and #52)
171171 let x = 0 ;
172172 } ) ;
173173
174174 // Here we wait for the application to connect to the socket server
175175 // Only once connected do we know that the application has successfully launched
176- //resolve();
176+ // resolve();
177177 this . debugServer . DebugClientConnected . then ( resolve ) ;
178178 } ) ;
179179 }
180180 protected buildLauncherArguments ( ) : string [ ] {
181- let vsDebugOptions = " WaitOnAbnormalExit,WaitOnNormalExit,RedirectOutput" ;
181+ let vsDebugOptions = ' WaitOnAbnormalExit,WaitOnNormalExit,RedirectOutput' ;
182182 if ( Array . isArray ( this . args . debugOptions ) ) {
183- vsDebugOptions = this . args . debugOptions . filter ( opt => VALID_DEBUG_OPTIONS . indexOf ( opt ) >= 0 ) . join ( "," ) ;
183+ vsDebugOptions = this . args . debugOptions . filter ( opt => VALID_DEBUG_OPTIONS . indexOf ( opt ) >= 0 ) . join ( ',' ) ;
184184 }
185185 // If internal or external console, then don't re-direct the output
186- if ( this . args . externalConsole === true || this . args . console === 'integratedTerminal' || this . args . console === 'externalTermainal' ) {
186+ if ( this . args . externalConsole === true || this . args . console === 'integratedTerminal' || this . args . console === 'externalTermainal' ) {
187187 vsDebugOptions = vsDebugOptions . split ( ',' ) . filter ( opt => opt !== 'RedirectOutput' ) . join ( ',' ) ;
188188 }
189189
0 commit comments