eric6/DebugClients/Python/DebugUtilities.py

changeset 8228
772103b14c18
parent 8221
0572a215bd2f
child 8273
698ae46f40a4
equal deleted inserted replaced
8227:349308e84eeb 8228:772103b14c18
192 with open(program) as f: 192 with open(program) as f:
193 for line in f: 193 for line in f:
194 line = line.strip() 194 line = line.strip()
195 if line: 195 if line:
196 for name in PYTHON_NAMES: # __IGNORE_WARNING_Y110__ 196 for name in PYTHON_NAMES: # __IGNORE_WARNING_Y110__
197 if line.startswith( 197 if (
198 '#!/usr/bin/env {0}'.format(name) 198 line.startswith(
199 '#!/usr/bin/env {0}'.format(name)) or
200 (line.startswith('#!') and name in line)
199 ): 201 ):
200 return True
201 elif line.startswith('#!') and name in line:
202 return True 202 return True
203 return False 203 return False
204 else: 204 else:
205 return False 205 return False
206 except UnicodeDecodeError: 206 except UnicodeDecodeError:
306 program = os.path.basename(args[0]).lower() 306 program = os.path.basename(args[0]).lower()
307 for pyname in PYTHON_NAMES: 307 for pyname in PYTHON_NAMES:
308 if pyname in program: 308 if pyname in program:
309 break 309 break
310 else: 310 else:
311 if not isWindowsPlatform() and startsWithShebang(args[0]): 311 if (
312 # insert our interpreter as first argument 312 (not isWindowsPlatform() and startsWithShebang(args[0])) or
313 args.insert(0, sys.executable) 313 (isWindowsPlatform() and args[0].lower().endswith(".py"))
314 elif isWindowsPlatform() and args[0].lower().endswith(".py"): 314 ):
315 # it is a Python script; insert our interpreter as first argument 315 # 1. insert our interpreter as first argument if not Windows
316 # 2. insert our interpreter as first argument if on Windows and
317 # it is a Python script
316 args.insert(0, sys.executable) 318 args.insert(0, sys.executable)
317 319
318 # extract list of interpreter arguments, i.e. all arguments before the 320 # extract list of interpreter arguments, i.e. all arguments before the
319 # first one not starting with '-'. 321 # first one not starting with '-'.
320 interpreter = args.pop(0) 322 interpreter = args.pop(0)

eric ide

mercurial