def execute_file_as_main(self, filename, arg_string): f = open(filename, 'rb') try: contents = f.read().replace(to_bytes("\r\n"), to_bytes("\n")) finally: f.close() args = [filename] + _command_line_to_args_list(arg_string) code = ''' import sys sys.argv = %(args)r __file__ = %(filename)r del sys exec(compile(%(contents)r, %(filename)r, 'exec')) ''' % {'filename' : filename, 'contents':contents, 'args': args} self.run_command(code, True)
import sys import os.path import traceback import time import socket try: import visualstudio_py_util as _vspu except: traceback.print_exc() print( """Internal error detected. Please copy the above traceback and report at https://github.com/Microsoft/vscode-python/issues""") sys.exit(1) LAST = _vspu.to_bytes('LAST') OUTP = _vspu.to_bytes('OUTP') LOAD = _vspu.to_bytes('LOAD') def parse_argv(): """Parses arguments for use with the launcher. Arguments are: 1. Working directory. 2. VS debugger port to connect to. 3. GUID for the debug session. 4. Debug options (not used). 5. '-m' or '-c' to override the default run-as mode. [optional]. 6. Startup script name. 7. Script arguments. """
"""Run a block of code or Python file.""" import sys import os.path import traceback import time import socket try: import visualstudio_py_util as _vspu except: traceback.print_exc() print("""Internal error detected. Please copy the above traceback and report at https://github.com/Microsoft/vscode-python/issues""") sys.exit(1) LAST = _vspu.to_bytes('LAST') OUTP = _vspu.to_bytes('OUTP') LOAD = _vspu.to_bytes('LOAD') def parse_argv(): """Parses arguments for use with the launcher. Arguments are: 1. Working directory. 2. VS debugger port to connect to. 3. GUID for the debug session. 4. Debug options (not used). 5. '-m' or '-c' to override the default run-as mode. [optional]. 6. Startup script name. 7. Script arguments. """