diff --git a/bumblebee/modules/gpmdp.py b/bumblebee/modules/gpmdp.py index ef74fbe..36988e8 100644 --- a/bumblebee/modules/gpmdp.py +++ b/bumblebee/modules/gpmdp.py @@ -52,13 +52,7 @@ class Module(bumblebee.engine.Module): status = bumblebee.util.execute("gpmdp-remote status") except RuntimeError: pass - try: - unicode_status = status.decode('utf-8') - unicode_info = info.decode('utf-8') - except AttributeError: - unicode_status = status - unicode_info = info - self._status = unicode_status.split("\n")[0].lower() - self._tags = unicode_info.split("\n")[0] + self._status = status.split("\n")[0].lower() + self._tags = info.split("\n")[0] # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/bumblebee/util.py b/bumblebee/util.py index 0e85184..9efa146 100644 --- a/bumblebee/util.py +++ b/bumblebee/util.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import shlex import logging import subprocess @@ -18,11 +20,13 @@ def execute(cmd, wait=True): out, _ = proc.communicate() if proc.returncode != 0: raise RuntimeError("{} exited with {}".format(cmd, proc.returncode)) - if type(out) == str: - rv = out - else: + + if hasattr(out, "decode"): rv = out.decode("utf-8") - logging.info("command returned '{}'".format("" if not rv else rv)) + else: + rv = out + + logging.info(u"command returned '{}'".format("" if not rv else rv)) return rv def bytefmt(num):