update black

This commit is contained in:
Grey_D
2023-03-17 15:16:20 +08:00
parent 9d53f7d479
commit 0d928517a1
12 changed files with 102 additions and 45 deletions

View File

@@ -1,15 +1,15 @@
import os, subprocess
def execute_cmd(cmd:str) -> str:
def execute_cmd(cmd: str) -> str:
"""
Execute the command in the mac terminal.
Parameters
----------
cmd: str
The command to be executed.
Returns
----------
output: str
@@ -17,17 +17,17 @@ def execute_cmd(cmd:str) -> str:
"""
try:
# execute the command in the system terminal
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr = None, shell=True)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=None, shell=True)
output = ""
# some tools may take time to execute. Wait until the output is finished.
while True:
line_output = p.stdout.readline()
if line_output:
output += line_output.decode("utf-8")
if line_output == b'' and p.poll() is not None:
if line_output == b"" and p.poll() is not None:
break
return output
except Exception as e:
print("Error in executing the command:", e)
return None
return None