dda-devops-build/src/main/python/ddadevops/python_util.py
2022-12-30 13:05:15 +00:00

19 lines
573 B
Python

from subprocess import check_output, Popen, PIPE
import sys
def execute(cmd, shell=False):
if sys.version_info.major == 3:
output = check_output(cmd, encoding='UTF-8', shell=shell)
else:
output = check_output(cmd, shell=shell)
return output.rstrip()
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]