mirror of
https://github.com/Foltik/dotfiles
synced 2024-11-24 04:22:50 -05:00
24 lines
643 B
Python
24 lines
643 B
Python
|
import subprocess
|
||
|
|
||
|
def sudo(cmd):
|
||
|
#print(['sudo'] + cmd)
|
||
|
return subprocess.Popen(['sudo'] + cmd,
|
||
|
stderr = subprocess.PIPE,
|
||
|
stdout = subprocess.PIPE,
|
||
|
stdin = subprocess.PIPE)
|
||
|
|
||
|
def exec(cmd):
|
||
|
#print(cmd)
|
||
|
return subprocess.Popen(cmd,
|
||
|
stderr = subprocess.PIPE,
|
||
|
stdout = subprocess.PIPE,
|
||
|
stdin = subprocess.PIPE)
|
||
|
|
||
|
def communicate(proc, cmd):
|
||
|
data = proc.communicate()
|
||
|
|
||
|
if proc.returncode != 0:
|
||
|
raise Exception('Command failed: ' + data[1].decode())
|
||
|
|
||
|
return data[0].decode()
|