Skip to content
Snippets Groups Projects
Commit 25103555 authored by tuhe's avatar tuhe
Browse files

Updates

parent 6fef9d75
No related branches found
No related tags found
No related merge requests found
...@@ -10,15 +10,38 @@ import platform ...@@ -10,15 +10,38 @@ import platform
def execute_command(command, shell=True): def execute_command(command, shell=True):
if not isinstance(command, list): """
command = [command] This is a super dodgy command from way back in the early 3.x days. I *think* all uses are better served by regular
if not platform.uname()[0] == "Linux": subprocess.check_output(..., shell=True), but I am not completely sure, and various people have updated the function
result = subprocess.run(command, stdout=subprocess.PIPE, shell=shell) to make it work on linux/mac; I know that giving inputs as lists was required at some point (perhaps for args with spaces?).
out = result.stdout
else: Current behavior will be subprocess.check_output, and if that works it can just be removed. Until and unless this turns out to be
cmd = " ".join(command) useful again, I think the function is best avoided.
print(cmd) """
out = subprocess.check_output(cmd, shell=shell) # if not isinstance(command, list):
# command = [command]
#
# if not platform.uname()[0] == "Linux":
# result = subprocess.run(command, stdout=subprocess.PIPE, shell=shell)
# out = result.stdout
# else:
# cmd = " ".join(command)
# out = subprocess.check_output(cmd, shell=shell)
# s = out.decode("utf-8")
# OK = True
# return s, OK
if isinstance(command, list):
command = " ".join(command)
# if not isinstance(command, list):
# command = [command]
# if not platform.uname()[0] == "Linux":
# result = subprocess.run(command, stdout=subprocess.PIPE, shell=shell)
# out = result.stdout
# else:
# cmd = " ".join(command)
out = subprocess.check_output(command, shell=shell)
s = out.decode("utf-8") s = out.decode("utf-8")
OK = True OK = True
return s, OK return s, OK
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment