def run_sync(self, command):
        command = CrossPlatformCodecs.encode_process_command(command)

        with Dir.cd(self.working_dir):
            self.process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=self.path, shell=True)
            self.pid = self.process.pid
            (stdout, stderr) = self.process.communicate()
            self.failed = self.process.returncode == 127 or stderr

        return (CrossPlatformCodecs.force_decode(stdout), CrossPlatformCodecs.force_decode(stderr))
    def run_sync(self, command):
        command = CrossPlatformCodecs.encode_process_command(command)

        with Dir.cd(self.working_dir):
            self.process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=self.path, shell=True)
            self.pid = self.process.pid
            (stdout, stderr) = self.process.communicate()
            self.failed = self.process.returncode == 127 or stderr

        return (CrossPlatformCodecs.force_decode(stdout), CrossPlatformCodecs.force_decode(stderr))
    def _pid_exists(self):
        if not self.pid:
            return False

        if sublime.platform() == "windows":
            taskkill = subprocess.Popen([
                'C:\\Windows\\system32\\tasklist.exe', '/FI',
                'PID eq %s' % self.pid, '/FO', 'CSV'
            ],
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE,
                                        shell=True)
            (stdout, stderr) = taskkill.communicate()

            failed = taskkill.returncode == 127 or stderr
            found = str(self.pid) in CrossPlatformCodecs.force_decode(stdout)

            return found or failed
        else:
            try:
                os.kill(self.pid, 0)
            except OSError as err:
                if err.errno == errno.ESRCH:
                    return False
                elif err.errno == errno.EPERM:
                    return True
                else:
                    raise
            else:
                return True
 def _pipe_stream(self, stream, fn):
     output_text = ""
     while True:
         line = stream.readline()
         if not line:
             break
         output_line = CrossPlatformCodecs.decode_line(line)
         output_text += output_line
         fn(output_line)
     return output_text
 def _pipe_stream(self, stream, fn):
     output_text = ""
     while True:
         line = stream.readline()
         if not line:
             break
         output_line = CrossPlatformCodecs.decode_line(line)
         output_text += output_line
         fn(output_line)
     return output_text
def insert_in_output_view(view, content, in_new_tab):
    if view is None:
        return

    if in_new_tab and view.is_loading():
        set_timeout(lambda: insert_in_output_view(view, content, in_new_tab), 10)
    else:
        decoded_contenet = content if is_sublime_text_3 else CrossPlatformCodecs.force_decode(content)

        view.set_read_only(False)
        view.run_command("view_insert", { "size": view.size(), "content": decoded_contenet })
        view.set_viewport_position((0, view.size()), True)
        view.set_read_only(True)
Beispiel #7
0
def insert_in_output_view(view, content, in_new_tab):
    if view is None:
        return

    if in_new_tab and view.is_loading():
        set_timeout(lambda: insert_in_output_view(view, content, in_new_tab),
                    10)
    else:
        decoded_contenet = content if is_sublime_text_3 else CrossPlatformCodecs.force_decode(
            content)

        view.set_read_only(False)
        view.run_command("view_insert", {
            "size": view.size(),
            "content": decoded_contenet
        })
        view.set_viewport_position((0, view.size()), True)
        view.set_read_only(True)
    def _pid_exists(self):
        if not self.pid:
            return False

        if sublime.platform() == "windows":
            taskkill = subprocess.Popen(['C:\\Windows\\system32\\tasklist.exe', '/FI', 'PID eq %s' % self.pid, '/FO', 'CSV'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
            (stdout, stderr) = taskkill.communicate()

            failed = taskkill.returncode == 127 or stderr
            found = str(self.pid) in CrossPlatformCodecs.force_decode(stdout)

            return found or failed
        else:
            try:
                os.kill(self.pid, 0)
            except OSError as err:
                if err.errno == errno.ESRCH:
                    return False
                elif err.errno == errno.EPERM:
                    return True
                else:
                    raise
            else:
                return True