Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

prestart supplement environments in background

  • Loading branch information...
commit 8bdd6e0e3d88d6ec8b7d3b817a87978cdb8a95f3 1 parent 9165d96
@baverman authored
View
13 snaked/plugins/python/__init__.py
@@ -52,6 +52,7 @@ def init(injector):
injector.on_ready('editor-with-new-buffer-created', editor_created)
injector.on_ready('editor-with-new-buffer', editor_opened)
+ injector.on_ready('manager', start_supplement)
injector.on_done('last-buffer-editor', editor_closed)
injector.on_done('manager', quit)
@@ -103,9 +104,8 @@ def quit(manager):
outline_dialog.window.destroy()
del outline_dialog
- import plugin
- for v in plugin.environments.values():
- v.close()
+ from .utils import close_envs
+ close_envs()
def goto_definition(editor):
try:
@@ -270,9 +270,10 @@ def rerun_test(editor):
editor.message('You did not run any test yet', 'warn')
def set_python_executable(editor, name):
- from .utils import get_executable
+ from .utils import get_executable, get_env
editor.conf['PYTHON_EXECUTABLE'] = name
editor.message('Python executable was set to:\n' + get_executable(editor.conf))
+ get_env(editor.conf).prepare()
def generate_python_executable_menu(editor):
from .utils import get_virtualenvwrapper_executables
@@ -287,4 +288,6 @@ def resolve_python_executable_menu_entry(editor, entry_id):
return entry_id == editor.conf['PYTHON_EXECUTABLE'], set_python_executable,\
(editor, entry_id), entry_id
-
+def start_supplement(manager):
+ from .utils import get_env
+ get_env(manager.conf).prepare()
View
14 snaked/plugins/python/plugin.py
@@ -7,9 +7,8 @@
from snaked.signals import connect_external, connect_all
from snaked.core.completer import add_completion_provider, attach_completer
-from .utils import get_executable
+from .utils import get_env
-environments = {}
configured_projects = {}
class Plugin(object):
@@ -29,16 +28,7 @@ def init_completion(self):
@property
def env(self):
- executable = get_executable(self.editor.conf)
- env = self.editor.conf['PYTHON_EXECUTABLE_ENV']
-
- try:
- env = environments[executable]
- except KeyError:
- import supplement.remote
- env = environments[executable] = supplement.remote.Environment(executable, env)
-
- return env
+ return get_env(self.editor.conf)
@lazy_property
def project_path(self):
View
20 snaked/plugins/python/utils.py
@@ -2,6 +2,8 @@
import os
from os.path import exists, join, expanduser, isdir, realpath
+environments = {}
+
def which(binary_name):
for p in os.environ.get('PATH', '').split(os.pathsep):
path = join(p, binary_name)
@@ -53,4 +55,20 @@ def get_executable(conf):
if path:
return path
- return sys.executable
+ return sys.executable
+
+def get_env(conf):
+ executable = get_executable(conf)
+
+ try:
+ env = environments[executable]
+ except KeyError:
+ import supplement.remote
+ env = environments[executable] = supplement.remote.Environment(
+ executable, conf['PYTHON_EXECUTABLE_ENV'])
+
+ return env
+
+def close_envs():
+ for v in environments.values():
+ v.close()

0 comments on commit 8bdd6e0

Please sign in to comment.
Something went wrong with that request. Please try again.