From 081bd329f981f618160a9ff6d20af12935b21cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Mand=C3=A1k?= Date: Sat, 3 Oct 2015 10:14:29 +0200 Subject: [PATCH] Changed checks for `command` attribute in `run_through_shell` and `execute`. --- i3pystatus/core/command.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/i3pystatus/core/command.py b/i3pystatus/core/command.py index 57915ba..e6dfcc4 100644 --- a/i3pystatus/core/command.py +++ b/i3pystatus/core/command.py @@ -25,13 +25,14 @@ def run_through_shell(command, enable_shell=False): string since shell does all the parsing. """ - if not enable_shell and not isinstance(command, list): + if not enable_shell and isinstance(command, str): command = shlex.split(command) returncode = None stderr = None try: - proc = subprocess.Popen(command, stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=enable_shell) + proc = subprocess.Popen(command, stderr=subprocess.PIPE, + stdout=subprocess.PIPE, shell=enable_shell) out, stderr = proc.communicate() out = out.decode("UTF-8") stderr = stderr.decode("UTF-8") @@ -64,10 +65,13 @@ def execute(command, detach=False): if detach: if not isinstance(command, str): - raise TypeError("Detached mode expects a string as command.") + msg = "Detached mode expects a string as command, not {}".format( + command) + logging.getLogger("i3pystatus.core.command").error(msg) + raise AttributeError(msg) command = ["i3-msg", "exec", command] else: - if not isinstance(command, list): + if isinstance(command, str): command = shlex.split(command) try: