Skip to content

Commit

Permalink
scylla_node: encode stdout and stderr if not text
Browse files Browse the repository at this point in the history
if there are no sstables, and we expect bytes as the output, we should
encode the encoded json into bytes before returning it. otherwise we'd
have exception like:

```
AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?
```

when trying to decode the returned stdout.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov authored and fruch committed Jan 23, 2024
1 parent 6209d9d commit c2bba25
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ccmlib/scylla_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,10 @@ def do_invoke(sstables):
if not sstables:
empty_dump = {'sstables': {'anonymous': []}}
stdout, stderr = json.dumps(empty_dump), ''
return (stdout, stderr)
if text:
return stdout, stderr
else:
return stdout.encode('utf-8'), stderr.encode('utf-8')
common_args = [scylla_path, "sstable", command] + additional_args
env = self._get_environ()
res = subprocess.run(common_args + sstables, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=text, check=False, env=env)
Expand Down

0 comments on commit c2bba25

Please sign in to comment.