def start_or_get_daemon(self):
global daemon
if (daemon != None):
return daemon
is_windows = os.name == 'nt'
executable = 'importjsd'
try:
daemon = subprocess.Popen(
[executable, 'start', '--parent-pid', str(os.getppid())],
cwd=self.project_root(),
env=import_js_environment,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=is_windows
)
# The daemon process will print one line at startup of the command,
# something like "DAEMON active. Logs will go to [...]". We need to
# ignore this line so that we can expect json output when running
# commands.
daemon.stdout.readline()
return daemon
except FileNotFoundError as e:
if(e.strerror.find(executable) > -1):
# If the executable is in the error message, then we believe
# that the executable cannot be found and show a more helpful
# message.
sublime.error_message(no_executable_error(executable))
else:
# Something other than the executable cannot be found, so we
# pass through the original message.
sublime.error_message(e.strerror)
raise e
评论列表
文章目录