Commandes du système Python Run
import subprocess
def run_cmd(cmd, verbose=False, *args, **kwargs):
"""
Run system command as a subprocess
"""
process = subprocess.Popen(cmd,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
text = True,
shell = True)
std_out, std_err = process.communicate()
if verbose:
print(std_out.strip(), std_err)
run_cmd('echo "Hello, World!"', verbose = True)
Scarlet Macaw