Skip to content

Commit

Permalink
adding encoding for snap info output
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocazzolato committed Nov 5, 2019
1 parent 97ca251 commit c2e437f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions services/services-generator
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class SystemdManager:
@staticmethod
def get_service_status_active(service):
cmd = 'systemctl status -o short {} | grep "Active:"'.format(service)
lines = subprocess.check_output(cmd, shell=True).splitlines()
lines = subprocess.check_output(cmd, shell=True, universal_newlines=True).splitlines()
if not len(lines) == 1:
logging.error('Incorrect out(service)put format for systemctl status: {}'.format(lines))
return
return lines[0].split(' ')[1]
return lines[0].split()[1]

@staticmethod
def stop_service(service):
Expand Down
4 changes: 2 additions & 2 deletions services/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, name):

def _get_info(self):
line = 'snap info {}'.format(self.name)
return subprocess.check_output(line, shell=True).splitlines()
return subprocess.check_output(line, shell=True, universal_newlines=True).splitlines()

def _get_channel_info(self, line, channel):
parts = line.split()
Expand Down Expand Up @@ -47,6 +47,6 @@ def get_info_by_channel(self):
for channel in Snap.SUPPORTED_CHANNELS:
channel_id = '{}:'.format(channel)
if line.strip().startswith(channel_id):
info[channel] = self._get_channel_info(line, channel)
info[channel] = self._get_channel_info(line.strip(), channel)

return info

0 comments on commit c2e437f

Please sign in to comment.