2022-12-30 13:05:15 +00:00
|
|
|
from subprocess import check_output, Popen, PIPE
|
2019-09-06 16:00:15 +00:00
|
|
|
import sys
|
|
|
|
|
2020-03-04 16:31:54 +00:00
|
|
|
def execute(cmd, shell=False):
|
2019-09-06 16:00:15 +00:00
|
|
|
if sys.version_info.major == 3:
|
2020-03-04 16:31:54 +00:00
|
|
|
output = check_output(cmd, encoding='UTF-8', shell=shell)
|
2019-09-06 16:00:15 +00:00
|
|
|
else:
|
2020-03-04 16:31:54 +00:00
|
|
|
output = check_output(cmd, shell=shell)
|
|
|
|
return output.rstrip()
|
2020-03-03 17:30:17 +00:00
|
|
|
|
2022-12-30 13:05:15 +00:00
|
|
|
def execute_live(cmd):
|
|
|
|
process = Popen(cmd, stdout=PIPE)
|
|
|
|
for line in iter(process.stdout.readline, b''):
|
|
|
|
print(line.decode('utf-8'), end='')
|
|
|
|
process.stdout.close()
|
|
|
|
process.wait()
|
|
|
|
|
|
|
|
def filter_none(list_to_filter):
|
|
|
|
return [x for x in list_to_filter if x is not None]
|