Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
44 lines (36 loc) · 1.53 KB

File metadata and controls

44 lines (36 loc) · 1.53 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
"""
StartWithLocalPython
Executes active document with local installed python interpreter
instead of using the python script plugin delivered engine.
Usage:
Local python_interpreter path needs to be modified.
Open python file and run script.
Output will be printed to console window.
"""
from Npp import notepad, console, MESSAGEBOXFLAGS
import subprocess
import shlex
import os
python_interpreter = {
MESSAGEBOXFLAGS.RESULTYES : u'D:\\ProgramData\\Python\\Python37_64\\python.exe',
MESSAGEBOXFLAGS.RESULTNO : u'D:\\ProgramData\\Python\\Python27_64\\python.exe'}
def run_command(command, __cwd):
_startupinfo = subprocess.STARTUPINFO()
_startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(shlex.split(command),
startupinfo=_startupinfo,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=__cwd)
_stdout, _stderr = process.communicate()
console.show()
if _stdout: console.write(_stdout)
if _stderr: console.write(_stderr)
file = notepad.getCurrentFilename()
_cwd, _ = os.path.split(file)
answer = notepad.messageBox(('Yes = Python 37_64\n\n'
'No = Python 27_64\n\n'
'Cancel = No execution'),'Select python interpreter',3)
if answer != MESSAGEBOXFLAGS.RESULTCANCEL:
run_command('"{}" -u "{}"'.format(python_interpreter[answer], file), _cwd)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.