3
3
import subprocess
4
4
import sys
5
5
from threading import Thread
6
+ from typing import Union
6
7
7
8
from je_auto_control .utils .logging .loggin_instance import autocontrol_logger
8
9
@@ -21,7 +22,7 @@ def __init__(
21
22
self .read_program_error_output_from_thread = None
22
23
self .read_program_output_from_thread = None
23
24
self .still_run_shell : bool = True
24
- self .process = None
25
+ self .process : Union [ subprocess . Popen , None ] = None
25
26
self .run_output_queue : queue = queue .Queue ()
26
27
self .run_error_queue : queue = queue .Queue ()
27
28
self .program_encoding : str = shell_encoding
@@ -115,16 +116,16 @@ def print_and_clear_queue(self) -> None:
115
116
116
117
def read_program_output_from_process (self ) -> None :
117
118
while self .still_run_shell :
118
- program_output_data = self .process .stdout .raw . read (
119
+ program_output_data = self .process .stdout .readline (
119
120
self .program_buffer ) \
120
- .decode (self .program_encoding )
121
+ .decode (self .program_encoding , "replace" )
121
122
self .run_output_queue .put_nowait (program_output_data )
122
123
123
124
def read_program_error_output_from_process (self ) -> None :
124
125
while self .still_run_shell :
125
- program_error_output_data = self .process .stderr .raw . read (
126
+ program_error_output_data = self .process .stderr .readline (
126
127
self .program_buffer ) \
127
- .decode (self .program_encoding )
128
+ .decode (self .program_encoding , "replace" )
128
129
self .run_error_queue .put_nowait (program_error_output_data )
129
130
130
131
0 commit comments