| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 44c6d0b commit 6e98416
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,26 +88,34 @@ def handle_process_output(process, stdout_handler, stderr_handler, finalizer, de | |||
| 88 | 88 | Set it to False if `universal_newline == True` (then streams are in text-mode) | |
| 89 | 89 | or if decoding must happen later (i.e. for Diffs). | |
| 90 | 90 | """ | |
| 91 | + if decode_streams: | ||
| 92 | + ZERO = b'' | ||
| 93 | + LF = b'\n' | ||
| 94 | + CR = b'\r' | ||
| 95 | + else: | ||
| 96 | + ZERO = u'' | ||
| 97 | + LF = u'\n' | ||
| 98 | + CR = u'\r' | ||
| 91 | 99 | ||
| 92 | 100 | def _parse_lines_from_buffer(buf): | |
| 93 | - line = b'' | ||
| 101 | + line = ZERO | ||
| 94 | 102 | bi = 0 | |
| 95 | 103 | lb = len(buf) | |
| 96 | 104 | while bi < lb: | |
| 97 | - char = _bchr(buf[bi]) | ||
| 105 | + char = buf[bi] | ||
| 98 | 106 | bi += 1 | |
| 99 | 107 | ||
| 100 | - if char in (b'\r', b'\n') and line: | ||
| 101 | - yield bi, line + b'\n' | ||
| 102 | - line = b'' | ||
| 108 | + if char in (LF, CR) and line: | ||
| 109 | + yield bi, line + LF | ||
| 110 | + line = ZERO | ||
| 103 | 111 | else: | |
| 104 | 112 | line += char | |
| 105 | 113 | # END process parsed line | |
| 106 | 114 | # END while file is not done reading | |
| 107 | 115 | # end | |
| 108 | 116 | ||
| 109 | 117 | def _read_lines_from_fno(fno, last_buf_list): | |
| 110 | - buf = os.read(fno, mmap.PAGESIZE) | ||
| 118 | + buf = fno.read(mmap.PAGESIZE) | ||
| 111 | 119 | buf = last_buf_list[0] + buf | |
| 112 | 120 | ||
| 113 | 121 | bi = 0 | |
@@ -192,8 +200,8 @@ def pump_stream(cmdline, name, stream, is_decode, handler): | |||
| 192 | 200 | else: | |
| 193 | 201 | # poll is preferred, as select is limited to file handles up to 1024 ... . This could otherwise be | |
| 194 | 202 | # an issue for us, as it matters how many handles our own process has | |
| 195 | - fdmap = {outfn: (stdout_handler, [b''], decode_streams), | ||
| 196 | - errfn: (stderr_handler, [b''], decode_streams)} | ||
| 203 | + fdmap = {outfn: (process.stdout, stdout_handler, [ZERO], decode_streams), | ||
| 204 | + errfn: (process.stderr, stderr_handler, [ZERO], decode_streams)} | ||
| 197 | 205 | ||
| 198 | 206 | READ_ONLY = select.POLLIN | select.POLLPRI | select.POLLHUP | select.POLLERR # @UndefinedVariable | |
| 199 | 207 | CLOSED = select.POLLHUP | select.POLLERR # @UndefinedVariable | |
@@ -217,7 +225,7 @@ def pump_stream(cmdline, name, stream, is_decode, handler): | |||
| 217 | 225 | if result & CLOSED: | |
| 218 | 226 | closed_streams.add(fd) | |
| 219 | 227 | else: | |
| 220 | - _dispatch_lines(fd, *fdmap[fd]) | ||
| 228 | + _dispatch_lines(*fdmap[fd]) | ||
| 221 | 229 | # end handle closed stream | |
| 222 | 230 | # end for each poll-result tuple | |
| 223 | 231 | ||
@@ -227,8 +235,8 @@ def pump_stream(cmdline, name, stream, is_decode, handler): | |||
| 227 | 235 | # end endless loop | |
| 228 | 236 | ||
| 229 | 237 | # Depelete all remaining buffers | |
| 230 | - for fno, (handler, buf_list, decode) in fdmap.items(): | ||
| 231 | - _deplete_buffer(fno, handler, buf_list, decode) | ||
| 238 | + for fno, args in fdmap.items(): | ||
| 239 | + _deplete_buffer(*args) | ||
| 232 | 240 | # end for each file handle | |
| 233 | 241 | ||
| 234 | 242 | for fno in fdmap.keys(): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,7 +34,8 @@ class CommandError(UnicodeMixin, Exception): | |||
| 34 | 34 | _msg = u"Cmd('%s') failed%s" | |
| 35 | 35 | ||
| 36 | 36 | def __init__(self, command, status=None, stderr=None, stdout=None): | |
| 37 | - assert isinstance(command, (tuple, list)), command | ||
| 37 | + if not isinstance(command, (tuple, list)): | ||
| 38 | + command = command.split() | ||
| 38 | 39 | self.command = command | |
| 39 | 40 | self.status = status | |
| 40 | 41 | if status: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -301,7 +301,8 @@ def remote_repo_creator(self): | |||
| 301 | 301 | try: | |
| 302 | 302 | gd.proc.kill() | |
| 303 | 303 | except: | |
| 304 | - pass ## Either it has died (and we're here), or it won't die, again here... | ||
| 304 | + ## Either it has died (and we're here), or it won't die, again here... | ||
| 305 | + pass | ||
| 305 | 306 | ||
| 306 | 307 | rw_repo.git.clear_cache() | |
| 307 | 308 | rw_remote_repo.git.clear_cache() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments