Skip to content

Commit

Permalink
Python3: Decode file content when reading it
Browse files Browse the repository at this point in the history
Signed-off-by: Aline Manera <[email protected]>
  • Loading branch information
alinefm committed Jan 8, 2020
1 parent 960b0d1 commit 2b4aec9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions disks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ def _get_dev_node_path(maj_min):
dm_name = '/sys/dev/block/%s/dm/name' % maj_min
if os.path.exists(dm_name):
with open(dm_name) as dm_f:
content = dm_f.read().rstrip('\n')
content = dm_f.read().decode('utf-8').rstrip('\n')
return '/dev/mapper/' + content

uevent = '/sys/dev/block/%s/uevent' % maj_min
with open(uevent) as ueventf:
content = ueventf.read()
content = ueventf.read().decode('utf-8')

data = dict(re.findall(r'(\S+)=(".*?"|\S+)', content.replace('\n', ' ')))

Expand Down
2 changes: 1 addition & 1 deletion model/libvirtstoragepool.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def prepare(self, conn):
except TimeoutExpired:
raise InvalidParameter('KCHPOOL0012E', {'path': export_path})
with open('/proc/mounts', 'rb') as f:
rawMounts = f.read()
rawMounts = f.read().decode('utf-8')
output_items = ['dev_path', 'mnt_point', 'type']
mounts = parse_cmd_output(rawMounts, output_items)
for item in mounts:
Expand Down
2 changes: 1 addition & 1 deletion model/vms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,7 @@ def _set_password_less_login(self, remote_host, user, passwd):
def read_id_rsa_pub_file():
data = None
with open(id_rsa_pub_file, 'r') as id_file:
data = id_file.read()
data = id_file.read().decode('utf-8')
return data

def create_root_ssh_key_if_required():
Expand Down
2 changes: 1 addition & 1 deletion screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def _get_test_result(self):
return

fd = open(pipe, 'r')
data = fd.read()
data = fd.read().decode('utf-8')
fd.close()

if len(data) >= self.MAX_STREAM_ATTEMPTS or bool('+' in data):
Expand Down

0 comments on commit 2b4aec9

Please sign in to comment.