Merge charm-hw-health:str-bytes-conversion into charm-hw-health:stable/20.05

Proposed by Andrea Ieri
Status: Rejected
Rejected by: Paul Goins
Proposed branch: charm-hw-health:str-bytes-conversion
Merge into: charm-hw-health:stable/20.05
Diff against target: 19 lines (+1/-2)
1 file modified
src/files/ipmi/cron_ipmi_sensors.py (+1/-2)
Reviewer Review Type Date Requested Status
Paul Goins Approve
Zachary Zehring (community) Approve
Review via email: mp+386197@code.launchpad.net

Commit message

[cron_ipmi_sensors.py] decode subprocess bytes output into str

Closes-Bug: 1879603

To post a comment you must log in.
Revision history for this message
Zachary Zehring (zzehring) wrote :

Approved.

review: Approve
Revision history for this message
Paul Goins (vultaire) wrote :

LGTM, although bytes.decode('utf8') can simply be bytes.decode() as well; utf8 is the default.

review: Approve
Revision history for this message
Paul Goins (vultaire) wrote :

Actually, this was already merged into stable/20.05 previously as part of fixing lp#1882978. I unfortunately forgot to push the updates. I just pushed now; I'll mark this as resolved.

Unmerged commits

8c01c0d... by Joe Guo

cron_ipmi_sensors.py: rm encoding header

should defaults to utf-8.

Signed-off-by: Joe Guo <email address hidden>

56169b4... by Joe Guo

cron_ipmi_sensors.py: subprocess.check_output decode

`subprocess.check_output` always return bytes, even in python3.
decode output to str for python3.

Signed-off-by: Joe Guo <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/files/ipmi/cron_ipmi_sensors.py b/src/files/ipmi/cron_ipmi_sensors.py
2index a11f9fb..8ce5ee6 100644
3--- a/src/files/ipmi/cron_ipmi_sensors.py
4+++ b/src/files/ipmi/cron_ipmi_sensors.py
5@@ -1,5 +1,4 @@
6 #!/usr/bin/env python3
7-# -*- coding: us-ascii -*-
8
9 import os
10 import subprocess
11@@ -40,7 +39,7 @@ def gather_metrics():
12 if len(sys.argv) > 1:
13 cmdline.extend(sys.argv[1:])
14 try:
15- output = subprocess.check_output(cmdline)
16+ output = subprocess.check_output(cmdline).decode('utf8')
17 except subprocess.CalledProcessError as error:
18 output = error.stdout.decode(errors='ignore')
19 with open(TMP_OUTPUT_FILE, 'w') as fd:

Subscribers

No one subscribed via source and target branches