run os command
This commit is contained in:
parent
d8f255e8ea
commit
384d7c9a11
0
oshipka/util/__init__.py
Normal file
0
oshipka/util/__init__.py
Normal file
19
oshipka/util/os.py
Normal file
19
oshipka/util/os.py
Normal file
@ -0,0 +1,19 @@
|
||||
import subprocess
|
||||
|
||||
|
||||
def run_cmd(command):
|
||||
process = subprocess.Popen(command.split(),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
)
|
||||
return '\n'.join([str(line) for line in iter(process.stdout.readline, '')])
|
||||
|
||||
|
||||
def print_cmd(command):
|
||||
for line in run_cmd(command):
|
||||
print(line, end='')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print_cmd("env")
|
Loading…
Reference in New Issue
Block a user