4646## @{
4747
4848def handle_process_output (process ,stdout_handler ,stderr_handler ,finalizer ):
49- """Registers for notifications to lean that process output is ready to read, and dispatches lines to
50- the respective line handlers. We are able to handle carriage returns in case progress is sent by that
49+ """Registers for notifications to lean that process output is ready to read, and dispatches lines to
50+ the respective line handlers. We are able to handle carriage returns in case progress is sent by that
5151 mean. For performance reasons, we only apply this to stderr.
5252 This function returns once the finalizer returns
5353 :return: result of finalizer
@@ -77,7 +77,7 @@ def read_line_slow(stream):
7777def dispatch_line (fno ):
7878stream ,handler ,readline = fdmap [fno ]
7979# this can possibly block for a while, but since we wake-up with at least one or more lines to handle,
80- # we are good ...
80+ # we are good ...
8181line = readline (stream ).decode (defenc )
8282if line and handler :
8383handler (line )
@@ -93,13 +93,13 @@ def deplete_buffer(fno, wg=None):
9393# end deplete buffer
9494if wg :
9595wg .done ()
96- # end
96+ # end
9797
98- fdmap = {process .stdout .fileno () : (process .stdout ,stdout_handler ,read_line_fast ),
99- process .stderr .fileno () : (process .stderr ,stderr_handler ,read_line_slow ) }
98+ fdmap = {process .stdout .fileno (): (process .stdout ,stdout_handler ,read_line_fast ),
99+ process .stderr .fileno (): (process .stderr ,stderr_handler ,read_line_slow )}
100100
101101if hasattr (select ,'poll' ):
102- # poll is preferred, as select is limited to file handles up to 1024 ... . This could otherwise be
102+ # poll is preferred, as select is limited to file handles up to 1024 ... . This could otherwise be
103103# an issue for us, as it matters how many handles or own process has
104104poll = select .poll ()
105105READ_ONLY = select .POLLIN | select .POLLPRI | select .POLLHUP | select .POLLERR
@@ -137,18 +137,18 @@ def deplete_buffer(fno, wg=None):
137137wg = WaitGroup ()
138138for fno in fdmap .keys ():
139139wg .add (1 )
140- t = threading .Thread (target = lambda :deplete_buffer (fno ,wg ))
140+ t = threading .Thread (target = lambda :deplete_buffer (fno ,wg ))
141141t .start ()
142142# end
143- # NOTE: Just joining threads can possibly fail as there is a gap between .start() and when it's
143+ # NOTE: Just joining threads can possibly fail as there is a gap between .start() and when it's
144144# actually started, which could make the wait() call to just return because the thread is not yet
145145# active
146146wg .wait ()
147147# end
148148
149149return finalizer (process )
150150
151-
151+
152152def dashify (string ):
153153return string .replace ('_' ,'-' )
154154