Skip to content

Commit

Permalink
fix bug when there is an empty line in mc admin response
Browse files Browse the repository at this point in the history
`json.loads(line)` would throw an error if line is empty (e.g. `line == ''`).
To fix it, simply check if line is truthy (i.e. not empty).

Also, `text=True` is passed `subprocess.run` to ensure `proc.stdout` is a string
and not bytes object.
  • Loading branch information
bo5o committed Mar 23, 2021
1 parent cfd711d commit 1a26139
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion minio/minioadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ def _run(self, args, multiline=False):
capture_output=True,
timeout=self._timeout,
check=True,
text=True,
)
if multiline:
return [json.loads(line) for line in proc.stdout.split("\n")]
return [json.loads(line) for line in proc.stdout.split("\n") if line]
return json.loads(proc.stdout)

def service_restart(self):
Expand Down

0 comments on commit 1a26139

Please sign in to comment.