Update Akeno/utils/scripts.py
Browse files- Akeno/utils/scripts.py +15 -3
Akeno/utils/scripts.py
CHANGED
@@ -118,9 +118,21 @@ async def shell_exec(
|
|
118 |
stdout=asyncio.subprocess.PIPE,
|
119 |
stderr=asyncio.subprocess.PIPE,
|
120 |
) -> Tuple[int, str, str]:
|
121 |
-
"""Executes shell command and returns tuple with return code, decoded stdout and stderr"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
process = await asyncio.create_subprocess_shell(
|
123 |
-
cmd=command,
|
|
|
|
|
|
|
|
|
124 |
)
|
125 |
|
126 |
try:
|
@@ -130,7 +142,7 @@ async def shell_exec(
|
|
130 |
raise e
|
131 |
|
132 |
return process.returncode, stdout.decode(), stderr.decode()
|
133 |
-
|
134 |
|
135 |
def time_formatter(milliseconds: int) -> str:
|
136 |
"""Time Formatter"""
|
|
|
118 |
stdout=asyncio.subprocess.PIPE,
|
119 |
stderr=asyncio.subprocess.PIPE,
|
120 |
) -> Tuple[int, str, str]:
|
121 |
+
"""Executes shell command and returns tuple with return code, decoded stdout, and stderr."""
|
122 |
+
|
123 |
+
if executable is None:
|
124 |
+
# Set a default shell based on the platform
|
125 |
+
if sys.platform == "win32":
|
126 |
+
executable = "cmd.exe"
|
127 |
+
else:
|
128 |
+
executable = "/bin/bash"
|
129 |
+
|
130 |
process = await asyncio.create_subprocess_shell(
|
131 |
+
cmd=command,
|
132 |
+
stdout=stdout,
|
133 |
+
stderr=stderr,
|
134 |
+
shell=True,
|
135 |
+
executable=executable
|
136 |
)
|
137 |
|
138 |
try:
|
|
|
142 |
raise e
|
143 |
|
144 |
return process.returncode, stdout.decode(), stderr.decode()
|
145 |
+
|
146 |
|
147 |
def time_formatter(milliseconds: int) -> str:
|
148 |
"""Time Formatter"""
|