Skip to content

Commit

Permalink
Now read process not process.raw
Browse files Browse the repository at this point in the history
  • Loading branch information
JE-Chen committed Sep 26, 2023
1 parent f40bb36 commit cab8f9f
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os
import queue
import shutil
import subprocess
import sys
import threading
Expand All @@ -14,8 +12,6 @@
from je_editor.utils.venv_check.check_venv import check_and_choose_venv

from automation_editor.automation_editor_ui.show_code_window.code_window import CodeWindow
from automation_editor.utils.exception.exception_tags import compiler_not_found_error
from automation_editor.utils.exception.exceptions import ITEExecException


class TaskProcessManager(object):
Expand All @@ -24,7 +20,7 @@ def __init__(
main_window: CodeWindow,
task_done_trigger_function: typing.Callable = None,
error_trigger_function: typing.Callable = None,
program_buffer_size: int = 1024000,
program_buffer_size: int = 1024,
program_encoding: str = "utf-8"
):
super().__init__()
Expand Down Expand Up @@ -57,7 +53,7 @@ def renew_path(self) -> None:

def start_test_process(self, package: str, exec_str: str):
self.renew_path()
self.process = subprocess.Popen(
self.process: subprocess.Popen = subprocess.Popen(
[
self.compiler_path,
"-m",
Expand Down Expand Up @@ -144,13 +140,14 @@ def print_and_clear_queue(self):

def read_program_output_from_process(self):
while self.still_run_program:
program_output_data = self.process.stdout.raw.read(self.program_buffer_size).decode(self.program_encoding)
self.process: subprocess.Popen
program_output_data = self.process.stdout.read(self.program_buffer_size).decode(self.program_encoding)
if program_output_data.strip() != "":
self.run_output_queue.put(program_output_data)

def read_program_error_output_from_process(self):
while self.still_run_program:
program_error_output_data = self.process.stderr.raw.read(self.program_buffer_size).decode(
program_error_output_data = self.process.stderr.read(self.program_buffer_size).decode(
self.program_encoding)
if program_error_output_data.strip() != "":
self.run_error_queue.put(program_error_output_data)

0 comments on commit cab8f9f

Please sign in to comment.