import-js.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:sublime-import-js 作者: Galooshi 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号