diff options
author | Papoteur <papoteur@mageia.org> | 2024-05-16 15:03:21 +0200 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2024-05-16 15:03:21 +0200 |
commit | d7b3c45d43f1a44c146e87830f50c1f2b63c220c (patch) | |
tree | dca2ac6072d17605adaf581d0f9a008de8d2c545 /MgaRepo/util.py | |
parent | 8ab430fc02d090427523c045fd0f0dca073cf69f (diff) | |
download | mgarepo-d7b3c45d43f1a44c146e87830f50c1f2b63c220c.tar mgarepo-d7b3c45d43f1a44c146e87830f50c1f2b63c220c.tar.gz mgarepo-d7b3c45d43f1a44c146e87830f50c1f2b63c220c.tar.bz2 mgarepo-d7b3c45d43f1a44c146e87830f50c1f2b63c220c.tar.xz mgarepo-d7b3c45d43f1a44c146e87830f50c1f2b63c220c.zip |
Fix reading from command output, could crash when chunks are cut at middle of an unicode character.
Diffstat (limited to 'MgaRepo/util.py')
-rw-r--r-- | MgaRepo/util.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/MgaRepo/util.py b/MgaRepo/util.py index 6d31399..635319d 100644 --- a/MgaRepo/util.py +++ b/MgaRepo/util.py @@ -20,15 +20,15 @@ def commands_getstatusoutput(cmd): """Return (status, output) of executing cmd in a shell.""" pipe = subprocess.Popen('{ ' + cmd + '; } 2>&1', stdin = subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines = True, shell = True) of = pipe.stdout.fileno() - text = '' + text = b'' pipe.stdin.close() while True: - text += os.read(of,8192).decode('utf8') + text += os.read(of,8192) status = pipe.poll() if status is not None or text == '': break if text[-1:] == '\n': text = text[:-1] - return status, text + return status, text.decode('utf8') def execcmd(*cmd, **kwargs): cmdstr = " ".join(cmd) |